Class BlockAllocatorImpl
- java.lang.Object
-
- com.amazonaws.athena.connector.lambda.data.BlockAllocatorImpl
-
- All Implemented Interfaces:
BlockAllocator
,AutoCloseable
public class BlockAllocatorImpl extends Object implements BlockAllocator
Basic BlockAllocator which uses reference counting to perform garbage collection of Apache Arrow resources.- See Also:
BlockAllocator
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.amazonaws.athena.connector.lambda.data.BlockAllocator
BlockAllocator.BatchGenerator
-
-
Constructor Summary
Constructors Constructor Description BlockAllocatorImpl()
Default constructor.BlockAllocatorImpl(String id)
Constructs a BlockAllocatorImpl with the given id.BlockAllocatorImpl(String id, long memoryLimit)
Constructs a BlockAllocatorImpl with the given id and memory byte limit.BlockAllocatorImpl(String id, org.apache.arrow.memory.RootAllocator rootAllocator)
Constructs a BlockAllocatorImpl with the given id and a shared RootAllocatorBlockAllocatorImpl(org.apache.arrow.memory.RootAllocator rootAllocator)
Default constructor that takes in a shared RootAllocator
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes all Apache Arrow Resources allocated via this BlockAllocator and then attempts to close the underlying Apache Arrow Allocator which would actually free memory.protected void
closeBatches()
Attempts to close all batches allocated by this BlockAllocator.protected void
closeBlocks()
Attempts to close all Blocks allocated by this BlockAllocator.protected void
closeBuffers()
Attempts to close all buffers allocated by this BlockAllocator.Block
createBlock(org.apache.arrow.vector.types.pojo.Schema schema)
Creates a block and registers it for later clean up if the block isn't explicitly closed by the caller.org.apache.arrow.memory.ArrowBuf
createBuffer(int size)
Creates an ArrowBuf and registers it for later clean up if the ArrowBuff isn't explicitly closed by the caller.protected org.apache.arrow.memory.BufferAllocator
getRawAllocator()
Provides access to the underlying Apache Arrow Allocator.long
getUsage()
Returns number of bytes in the Apache Arrow Pool that are used.boolean
isClosed()
Indicates if this BlockAllocator has been closed.org.apache.arrow.vector.ipc.message.ArrowRecordBatch
registerBatch(BlockAllocator.BatchGenerator generator)
Creates an ArrowRecordBatch and registers it for later clean up if the ArrowRecordBatch isn't explicitly closed by the caller.
-
-
-
Constructor Detail
-
BlockAllocatorImpl
public BlockAllocatorImpl()
Default constructor.
-
BlockAllocatorImpl
public BlockAllocatorImpl(org.apache.arrow.memory.RootAllocator rootAllocator)
Default constructor that takes in a shared RootAllocator
-
BlockAllocatorImpl
public BlockAllocatorImpl(String id)
Constructs a BlockAllocatorImpl with the given id.- Parameters:
id
- The id used to identify this BlockAllocatorImpl
-
BlockAllocatorImpl
public BlockAllocatorImpl(String id, org.apache.arrow.memory.RootAllocator rootAllocator)
Constructs a BlockAllocatorImpl with the given id and a shared RootAllocator- Parameters:
id
- The id used to identify this BlockAllocatorImplrootAllocator
- the shared RootAllocator
-
BlockAllocatorImpl
public BlockAllocatorImpl(String id, long memoryLimit)
Constructs a BlockAllocatorImpl with the given id and memory byte limit.- Parameters:
id
- The id used to identify this BlockAllocatorImplmemoryLimit
- The max memory, in bytes, that this BlockAllocator is allows to use.
-
-
Method Detail
-
createBlock
public Block createBlock(org.apache.arrow.vector.types.pojo.Schema schema)
Creates a block and registers it for later clean up if the block isn't explicitly closed by the caller.- Specified by:
createBlock
in interfaceBlockAllocator
- Parameters:
schema
- The schema of the Apache Arrow Block.- Returns:
- THe resulting Block.
- See Also:
BlockAllocator
-
createBuffer
public org.apache.arrow.memory.ArrowBuf createBuffer(int size)
Creates an ArrowBuf and registers it for later clean up if the ArrowBuff isn't explicitly closed by the caller.- Specified by:
createBuffer
in interfaceBlockAllocator
- Parameters:
size
- The number of bytes to reserve for the requested buffer.- Returns:
- THe resulting Apache Arrow Buffer..
- See Also:
BlockAllocator
-
registerBatch
public org.apache.arrow.vector.ipc.message.ArrowRecordBatch registerBatch(BlockAllocator.BatchGenerator generator)
Creates an ArrowRecordBatch and registers it for later clean up if the ArrowRecordBatch isn't explicitly closed by the caller.- Specified by:
registerBatch
in interfaceBlockAllocator
- Parameters:
generator
- The generator which is expected to create an ArrowRecordBatch.- Returns:
- THe resulting Apache Arrow Batch..
- See Also:
BlockAllocator
-
getRawAllocator
protected org.apache.arrow.memory.BufferAllocator getRawAllocator()
Provides access to the underlying Apache Arrow Allocator.- See Also:
BlockAllocator
-
closeBlocks
protected void closeBlocks()
Attempts to close all Blocks allocated by this BlockAllocator.
-
closeBuffers
protected void closeBuffers()
Attempts to close all buffers allocated by this BlockAllocator.
-
closeBatches
protected void closeBatches()
Attempts to close all batches allocated by this BlockAllocator.
-
getUsage
public long getUsage()
Returns number of bytes in the Apache Arrow Pool that are used. This is not the same as the actual reserved memory usage you may be familiar with from your operating system.- Specified by:
getUsage
in interfaceBlockAllocator
- Returns:
- The number of bytes that have been used (e.g. assigned to an Apache Arrow Resource like a block, batch, or buffer).
- See Also:
BlockAllocator
-
close
public void close()
Closes all Apache Arrow Resources allocated via this BlockAllocator and then attempts to close the underlying Apache Arrow Allocator which would actually free memory. This operation may fail if the underlying Apache Arrow Allocator was used to allocate resources without registering them to this BlockAllocator and those resources were not freed prior to calling close.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceBlockAllocator
- See Also:
BlockAllocator
-
isClosed
public boolean isClosed()
Indicates if this BlockAllocator has been closed.- Specified by:
isClosed
in interfaceBlockAllocator
- Returns:
- True if close has been called, False otherwise.
- See Also:
BlockAllocator
-
-