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 wrapper
ByteBufferAllocator implementation that tracks whether all allocated buffers are released. It
throws the related exception at close() 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 ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic class -
Method Summary
Modifier and TypeMethodDescriptionallocate(int size) voidclose()booleanisDirect()Indicates if this allocator will produce ByteBuffers backed by direct memory.voidFor RefCounted implementations using direct memory, the release method needs to be called to free references to the allocated memory.static TrackingByteBufferAllocatorwrap(ByteBufferAllocator allocator)
-
Method Details
-
wrap
-
allocate
- 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
- Specified by:
closein interfaceAutoCloseable- Throws:
TrackingByteBufferAllocator.LeakedByteBufferException
-