Class OrcReferenceManager

java.lang.Object
org.apache.arrow.adapter.orc.OrcReferenceManager
All Implemented Interfaces:
ReferenceManager

public class OrcReferenceManager extends Object implements ReferenceManager
A simple reference manager implementation for memory allocated by native code. The underlying memory will be released when reference count reach zero.
  • Method Details

    • getRefCount

      public int getRefCount()
      Description copied from interface: ReferenceManager
      Return the reference count.
      Specified by:
      getRefCount in interface ReferenceManager
      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 interface ReferenceManager
      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 interface ReferenceManager
      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 interface ReferenceManager
    • 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 interface ReferenceManager
      Parameters:
      increment - the count to increase the reference count by
    • retain

      public ArrowBuf retain(ArrowBuf srcBuffer, BufferAllocator targetAllocator)
      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 interface ReferenceManager
      Parameters:
      srcBuffer - source ArrowBuf
      targetAllocator - The target allocator to create an association with.
      Returns:
      A new ArrowBuf which shares the same underlying memory as this ArrowBuf.
    • deriveBuffer

      public ArrowBuf deriveBuffer(ArrowBuf sourceBuffer, long index, long length)
      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 interface ReferenceManager
      Parameters:
      sourceBuffer - source ArrowBuf
      index - index (relative to source ArrowBuf) new ArrowBuf should be derived from
      length - 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 (AllocationManagers) as the given ArrowBuf.
      Specified by:
      transferOwnership in interface ReferenceManager
      Parameters:
      sourceBuffer - source ArrowBuf
      targetAllocator - The target allocator to create an association with
      Returns:
      OwnershipTransferResult with info on transfer result and new buffer
    • getAllocator

      public BufferAllocator getAllocator()
      Description copied from interface: ReferenceManager
      Get the buffer allocator associated with this reference manager.
      Specified by:
      getAllocator in interface ReferenceManager
      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 interface ReferenceManager
      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 interface ReferenceManager
      Returns:
      accounted size.