java.lang.Object
org.apache.arrow.adapter.orc.OrcReferenceManager
- All Implemented Interfaces:
ReferenceManager
A simple reference manager implementation for memory allocated by native code. The underlying
memory will be released when reference count reach zero.
-
Field Summary
Fields inherited from interface org.apache.arrow.memory.ReferenceManager
NO_OP, NO_OP_ERROR_MESSAGE
-
Method Summary
Modifier and TypeMethodDescriptionderiveBuffer
(ArrowBuf sourceBuffer, long index, long length) Derive a new ArrowBuf from a given source ArrowBuf.long
Get the total accounted size (in bytes).Get the buffer allocator associated with this reference manager.int
Return the reference count.long
getSize()
Total size (in bytes) of memory underlying this reference manager.boolean
release()
Decrement this reference manager's reference count by 1 for the associated underlying memory.boolean
release
(int decrement) Decrement this reference manager's reference count for the associated underlying memory.void
retain()
Increment this reference manager's reference count by 1 for the associated underlying memory.void
retain
(int increment) Increment this reference manager's reference count by a given amount for the associated underlying memory.retain
(ArrowBuf srcBuffer, BufferAllocator targetAllocator) Create a new ArrowBuf that is associated with an alternative allocator for the purposes of memory ownership and accounting.transferOwnership
(ArrowBuf sourceBuffer, BufferAllocator targetAllocator) Duplicate the memory accounting ownership of the backing allocation of the given ArrowBuf in another allocator.
-
Method Details
-
getRefCount
public int getRefCount()Description copied from interface:ReferenceManager
Return the reference count.- Specified by:
getRefCount
in interfaceReferenceManager
- Returns:
- reference count
-
release
public boolean release()Description copied from interface:ReferenceManager
Decrement this reference manager's reference count by 1 for the associated underlying memory. If the reference count drops to 0, it implies that ArrowBufs managed by this reference manager no longer need access to the underlying memory- Specified by:
release
in interfaceReferenceManager
- Returns:
- true if ref count has dropped to 0, false otherwise
-
release
public boolean release(int decrement) Description copied from interface:ReferenceManager
Decrement this reference manager's reference count for the associated underlying memory. If the reference count drops to 0, it implies that ArrowBufs managed by this reference manager no longer need access to the underlying memory- Specified by:
release
in interfaceReferenceManager
- Parameters:
decrement
- the count to decrease the reference count by- Returns:
- the new reference count
-
retain
public void retain()Description copied from interface:ReferenceManager
Increment this reference manager's reference count by 1 for the associated underlying memory.- Specified by:
retain
in interfaceReferenceManager
-
retain
public void retain(int increment) Description copied from interface:ReferenceManager
Increment this reference manager's reference count by a given amount for the associated underlying memory.- Specified by:
retain
in interfaceReferenceManager
- Parameters:
increment
- the count to increase the reference count by
-
retain
Description copied from interface:ReferenceManager
Create a new ArrowBuf that is associated with an alternative allocator for the purposes of memory ownership and accounting. This has no impact on the reference counting for the current ArrowBuf except in the situation where the passed in Allocator is the same as the current buffer. This operation has no impact on the reference count of this ArrowBuf. The newly created ArrowBuf with either have a reference count of 1 (in the case that this is the first time this memory is being associated with the target allocator or in other words allocation manager currently doesn't hold a mapping for the target allocator) or the current value of the reference count for the target allocator-reference manager combination + 1 in the case that the provided allocator already had an association to this underlying memory.The underlying allocation (
AllocationManager
) will not be copied.- Specified by:
retain
in interfaceReferenceManager
- Parameters:
srcBuffer
- source ArrowBuftargetAllocator
- The target allocator to create an association with.- Returns:
- A new ArrowBuf which shares the same underlying memory as this ArrowBuf.
-
deriveBuffer
Description copied from interface:ReferenceManager
Derive a new ArrowBuf from a given source ArrowBuf. The new derived ArrowBuf will share the same reference count as rest of the ArrowBufs associated with this reference manager.- Specified by:
deriveBuffer
in interfaceReferenceManager
- Parameters:
sourceBuffer
- source ArrowBufindex
- index (relative to source ArrowBuf) new ArrowBuf should be derived fromlength
- length (bytes) of data in underlying memory that derived buffer will have access to in underlying memory- Returns:
- derived buffer
-
transferOwnership
public OwnershipTransferResult transferOwnership(ArrowBuf sourceBuffer, BufferAllocator targetAllocator) Description copied from interface:ReferenceManager
Duplicate the memory accounting ownership of the backing allocation of the given ArrowBuf in another allocator. This will generate a new ArrowBuf that carries an association with the same underlying memory (AllocationManager
s) as the given ArrowBuf.- Specified by:
transferOwnership
in interfaceReferenceManager
- Parameters:
sourceBuffer
- source ArrowBuftargetAllocator
- The target allocator to create an association with- Returns:
OwnershipTransferResult
with info on transfer result and new buffer
-
getAllocator
Description copied from interface:ReferenceManager
Get the buffer allocator associated with this reference manager.- Specified by:
getAllocator
in interfaceReferenceManager
- Returns:
- buffer allocator.
-
getSize
public long getSize()Description copied from interface:ReferenceManager
Total size (in bytes) of memory underlying this reference manager.- Specified by:
getSize
in interfaceReferenceManager
- Returns:
- Size (in bytes) of the memory chunk.
-
getAccountedSize
public long getAccountedSize()Description copied from interface:ReferenceManager
Get the total accounted size (in bytes).- Specified by:
getAccountedSize
in interfaceReferenceManager
- Returns:
- accounted size.
-