Class ReusableByteArray

java.lang.Object
org.apache.arrow.vector.util.ReusableByteArray
All Implemented Interfaces:
ReusableBuffer<byte[]>
Direct Known Subclasses:
Text

public class ReusableByteArray extends Object implements ReusableBuffer<byte[]>
A wrapper around byte arrays for repeated writing.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected byte[]
     
    protected static final byte[]
     
    protected int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    ReusableByteArray(byte[] data)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    byte[]
    Get the buffer backing this ReusableBuffer.
    long
    Get the number of bytes in the byte array.
    int
     
    void
    set(byte[] srcBytes, long start, long len)
     
    void
    set(ArrowBuf srcBytes, long start, long len)
    Set the buffer to the contents of the given ArrowBuf.
    protected void
    setCapacity(int len, boolean keepData)
    Sets the capacity of this object to at least len bytes.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • EMPTY_BYTES

      protected static final byte[] EMPTY_BYTES
    • bytes

      protected byte[] bytes
    • length

      protected int length
  • Constructor Details

    • ReusableByteArray

      public ReusableByteArray()
    • ReusableByteArray

      public ReusableByteArray(byte[] data)
  • Method Details

    • getLength

      public long getLength()
      Get the number of bytes in the byte array.
      Specified by:
      getLength in interface ReusableBuffer<byte[]>
      Returns:
      the number of bytes in the byte array
    • getBuffer

      public byte[] getBuffer()
      Description copied from interface: ReusableBuffer
      Get the buffer backing this ReusableBuffer.
      Specified by:
      getBuffer in interface ReusableBuffer<byte[]>
    • set

      public void set(ArrowBuf srcBytes, long start, long len)
      Description copied from interface: ReusableBuffer
      Set the buffer to the contents of the given ArrowBuf. The internal buffer must resize if it cannot fit the contents of the data.
      Specified by:
      set in interface ReusableBuffer<byte[]>
      Parameters:
      srcBytes - the data to copy from
      start - the first position of the new data
      len - the number of bytes of the new data
    • set

      public void set(byte[] srcBytes, long start, long len)
      Specified by:
      set in interface ReusableBuffer<byte[]>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setCapacity

      protected void setCapacity(int len, boolean keepData)
      Sets the capacity of this object to at least len bytes. If the current buffer is longer, then the capacity and existing content of the buffer are unchanged. If len is larger than the current capacity, the Text object's capacity is increased to match.
      Parameters:
      len - the number of bytes we need
      keepData - should the old data be kept