Package org.apache.parquet.bytes
Class TrackingByteBufferAllocator
- java.lang.Object
-
- org.apache.parquet.bytes.TrackingByteBufferAllocator
-
- All Implemented Interfaces:
AutoCloseable,ByteBufferAllocator
public final class TrackingByteBufferAllocator extends Object implements ByteBufferAllocator, AutoCloseable
A wrapperByteBufferAllocatorimplementation that tracks whether all allocated buffers are released. It throws the related exception atclose()if any buffer remains un-released. It also clears the buffers at release so if they continued being used it'll generate errors.To be used for testing purposes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTrackingByteBufferAllocator.ByteBufferAllocationStacktraceExceptionstatic classTrackingByteBufferAllocator.LeakDetectorHeapByteBufferAllocatorExceptionstatic classTrackingByteBufferAllocator.LeakedByteBufferExceptionstatic classTrackingByteBufferAllocator.ReleasingUnallocatedByteBufferException
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteBufferallocate(int size)voidclose()booleanisDirect()Indicates if this allocator will produce ByteBuffers backed by direct memory.voidrelease(ByteBuffer b)For RefCounted implementations using direct memory, the release method needs to be called to free references to the allocated memory.static TrackingByteBufferAllocatorwrap(ByteBufferAllocator allocator)
-
-
-
Method Detail
-
wrap
public static TrackingByteBufferAllocator wrap(ByteBufferAllocator allocator)
-
allocate
public ByteBuffer allocate(int size)
- Specified by:
allocatein interfaceByteBufferAllocator
-
release
public void release(ByteBuffer b) throws TrackingByteBufferAllocator.ReleasingUnallocatedByteBufferException
Description copied from interface:ByteBufferAllocatorFor RefCounted implementations using direct memory, the release method needs to be called to free references to the allocated memory.- Specified by:
releasein interfaceByteBufferAllocator- Parameters:
b- a ByteBuffer- Throws:
TrackingByteBufferAllocator.ReleasingUnallocatedByteBufferException
-
isDirect
public boolean isDirect()
Description copied from interface:ByteBufferAllocatorIndicates if this allocator will produce ByteBuffers backed by direct memory.- Specified by:
isDirectin interfaceByteBufferAllocator- Returns:
- true if direct memory backed buffers will be created by this allocator, else false
-
close
public void close() throws TrackingByteBufferAllocator.LeakedByteBufferException- Specified by:
closein interfaceAutoCloseable- Throws:
TrackingByteBufferAllocator.LeakedByteBufferException
-
-