Class HeapMemoryAllocator
- java.lang.Object
-
- org.apache.druid.frame.allocation.HeapMemoryAllocator
-
- All Implemented Interfaces:
MemoryAllocator
public class HeapMemoryAllocator extends Object implements MemoryAllocator
Allocator that usesByteBuffer.allocate(int)to create chunks in the JVM heap.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<ResourceHolder<org.apache.datasketches.memory.WritableMemory>>allocate(long size)Allocates a block of memory of capacity {@param size}.longavailable()Returns the number of bytes available for allocations.longcapacity()Returns the number of bytes managed by this allocator.static HeapMemoryAllocatorunlimited()Create an allocator that is "unlimited", which, of course, means it is limited only by available JVM heap.
-
-
-
Method Detail
-
unlimited
public static HeapMemoryAllocator unlimited()
Create an allocator that is "unlimited", which, of course, means it is limited only by available JVM heap.
-
allocate
public Optional<ResourceHolder<org.apache.datasketches.memory.WritableMemory>> allocate(long size)
Description copied from interface:MemoryAllocatorAllocates a block of memory of capacity {@param size}. Returns empty if no more memory is available. The memory can be freed by closing the returnedResourceHolder. The returned WritableMemory object will use little-endian byte order.- Specified by:
allocatein interfaceMemoryAllocator
-
available
public long available()
Description copied from interface:MemoryAllocatorReturns the number of bytes available for allocations. May returnLong.MAX_VALUEif there is no inherent limit. This generally does not mean you can actually allocate 9 exabytes.- Specified by:
availablein interfaceMemoryAllocator
-
capacity
public long capacity()
Description copied from interface:MemoryAllocatorReturns the number of bytes managed by this allocator. When no memory has been allocated yet, this is identical toMemoryAllocator.available(). May returnLong.MAX_VALUEif there is no inherent limit. This generally does not mean you can actually allocate 9 exabytes.- Specified by:
capacityin interfaceMemoryAllocator
-
-