Class FixedSizeBinaryVector

All Implemented Interfaces:
Closeable, AutoCloseable, Iterable<ValueVector>, ElementAddressableVector, FieldVector, FixedWidthVector, ValueIterableVector<byte[]>, ValueVector, VectorDefinitionSetter

public class FixedSizeBinaryVector extends BaseFixedWidthVector implements ValueIterableVector<byte[]>
FixedSizeBinaryVector implements a fixed width vector of binary values which could be null. A validity buffer (bit vector) is maintained to track which elements in the vector are null.
  • Constructor Details

    • FixedSizeBinaryVector

      public FixedSizeBinaryVector(String name, BufferAllocator allocator, int byteWidth)
      Instantiate a FixedSizeBinaryVector. This doesn't allocate any memory for the data in vector.
      Parameters:
      name - name of the vector
      allocator - allocator for memory management.
      byteWidth - byte width of the binary values
    • FixedSizeBinaryVector

      public FixedSizeBinaryVector(String name, FieldType fieldType, BufferAllocator allocator)
      Instantiate a FixedSizeBinaryVector. This doesn't allocate any memory for the data in vector.
      Parameters:
      name - name of the vector
      fieldType - type of Field materialized by this vector
      allocator - allocator for memory management.
    • FixedSizeBinaryVector

      public FixedSizeBinaryVector(Field field, BufferAllocator allocator)
      Instantiate a FixedSizeBinaryVector. This doesn't allocate any memory for the data in vector.
      Parameters:
      field - field materialized by this vector
      allocator - allocator for memory management.
  • Method Details

    • getReaderImpl

      protected FieldReader getReaderImpl()
      Description copied from class: BaseValueVector
      Each vector has a different reader that implements the FieldReader interface. Overridden methods must make sure to return the correct concrete reader implementation.
      Specified by:
      getReaderImpl in class BaseValueVector
      Returns:
      Returns a lambda that initializes a reader when called.
    • getMinorType

      public Types.MinorType getMinorType()
      Get minor type for this vector. The vector holds values belonging to a particular type.
      Specified by:
      getMinorType in interface ValueVector
      Returns:
      Types.MinorType
    • get

      public byte[] get(int index)
      Get the element at the given index from the vector.
      Parameters:
      index - position of element
      Returns:
      element at given index
    • read

      public void read(int index, ReusableBuffer<?> buffer)
      Read the value at the given position to the given output buffer. The caller is responsible for checking for nullity first.
      Parameters:
      index - position of element.
      buffer - the buffer to write into.
    • get

      public void get(int index, NullableFixedSizeBinaryHolder holder)
      Get the element at the given index from the vector and sets the state in holder. If element at given index is null, holder.isSet will be zero.
      Parameters:
      index - position of element
      holder - nullable holder to carry the buffer
    • getObject

      public byte[] getObject(int index)
      Same as get(int).
      Specified by:
      getObject in interface ValueVector
      Parameters:
      index - position of element
      Returns:
      element at given index
    • getByteWidth

      public int getByteWidth()
    • set

      public void set(int index, byte[] value)
      Sets the value at index to the provided one.
    • setSafe

      public void setSafe(int index, byte[] value)
      Same as set(int, byte[]) but reallocates if index is larger than capacity.
    • set

      public void set(int index, int isSet, byte[] value)
      Sets the value if isSet is positive, otherwise sets the index to null/invalid.
    • setSafe

      public void setSafe(int index, int isSet, byte[] value)
    • set

      public void set(int index, ArrowBuf buffer)
      Set the element at the given index to the given value.
      Parameters:
      index - position of element
      buffer - ArrowBuf containing binary value.
    • setSafe

      public void setSafe(int index, ArrowBuf buffer)
      Same as set(int, ArrowBuf) except that it handles the case when index is greater than or equal to existing value capacity BaseFixedWidthVector.getValueCapacity().
      Parameters:
      index - position of element
      buffer - ArrowBuf containing binary value.
    • set

      public void set(int index, int isSet, ArrowBuf buffer)
      Set the element at the given index to the given value.
      Parameters:
      index - position of element
      buffer - ArrowBuf containing binary value.
    • setSafe

      public void setSafe(int index, int isSet, ArrowBuf buffer)
      Same as set(int, ArrowBuf) except that it handles the case when index is greater than or equal to existing value capacity BaseFixedWidthVector.getValueCapacity().
      Parameters:
      index - position of element
      buffer - ArrowBuf containing binary value.
    • set

      public void set(int index, FixedSizeBinaryHolder holder)
      Set the variable length element at the specified index to the data buffer supplied in the holder.
      Parameters:
      index - position of the element to set
      holder - holder that carries data buffer.
    • setSafe

      public void setSafe(int index, FixedSizeBinaryHolder holder)
      Same as set(int, FixedSizeBinaryHolder) except that it handles the case where index and length of new element are beyond the existing capacity of the vector.
      Parameters:
      index - position of the element to set
      holder - holder that carries data buffer.
    • set

      public void set(int index, NullableFixedSizeBinaryHolder holder)
      Set the variable length element at the specified index to the data buffer supplied in the holder.
      Parameters:
      index - position of the element to set
      holder - holder that carries data buffer.
    • setSafe

      public void setSafe(int index, NullableFixedSizeBinaryHolder holder)
      Same as set(int, NullableFixedSizeBinaryHolder) except that it handles the case where index and length of new element are beyond the existing capacity of the vector.
      Parameters:
      index - position of the element to set
      holder - holder that carries data buffer.
    • get

      public static byte[] get(ArrowBuf buffer, int index, int byteWidth)
      Given a data buffer, get the value stored at a particular position in the vector.

      This method should not be used externally.

      Parameters:
      buffer - data buffer
      index - position of the element.
      Returns:
      value stored at the index.
    • validateScalars

      public void validateScalars()
      Description copied from class: BaseFixedWidthVector
      Validate the scalar values held by this vector.
      Overrides:
      validateScalars in class BaseFixedWidthVector
    • getTransferPair

      public TransferPair getTransferPair(String ref, BufferAllocator allocator)
      Construct a TransferPair comprising this and a target vector of the same type.
      Specified by:
      getTransferPair in interface ValueVector
      Specified by:
      getTransferPair in class BaseFixedWidthVector
      Parameters:
      ref - name of the target vector
      allocator - allocator for the target vector
      Returns:
      TransferPair
    • getTransferPair

      public TransferPair getTransferPair(Field field, BufferAllocator allocator)
      Construct a TransferPair comprising this and a target vector of the same type.
      Specified by:
      getTransferPair in interface ValueVector
      Specified by:
      getTransferPair in class BaseFixedWidthVector
      Parameters:
      field - Field object used by the target vector
      allocator - allocator for the target vector
      Returns:
      TransferPair
    • makeTransferPair

      public TransferPair makeTransferPair(ValueVector to)
      Construct a TransferPair with a desired target vector of the same type.
      Specified by:
      makeTransferPair in interface ValueVector
      Parameters:
      to - target vector
      Returns:
      TransferPair