Class Decimal256Vector

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

public final class Decimal256Vector extends BaseFixedWidthVector implements ValueIterableVector<BigDecimal>
Decimal256Vector implements a fixed width vector (32 bytes) of decimal values which could be null. A validity buffer (bit vector) is maintained to track which elements in the vector are null.
  • Field Details

  • Constructor Details

    • Decimal256Vector

      public Decimal256Vector(String name, BufferAllocator allocator, int precision, int scale)
      Instantiate a Decimal256Vector. This doesn't allocate any memory for the data in vector.
      Parameters:
      name - name of the vector
      allocator - allocator for memory management.
    • Decimal256Vector

      public Decimal256Vector(String name, FieldType fieldType, BufferAllocator allocator)
      Instantiate a Decimal256Vector. 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.
    • Decimal256Vector

      public Decimal256Vector(Field field, BufferAllocator allocator)
      Instantiate a Decimal256Vector. 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 ArrowBuf get(int index) throws IllegalStateException
      Get the element at the given index from the vector.
      Parameters:
      index - position of element
      Returns:
      element at given index
      Throws:
      IllegalStateException
    • get

      public void get(int index, NullableDecimal256Holder 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
    • getObject

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

      public BigDecimal getObjectNotNull(int index)
      Same as getObject(int), but does not check for null.
      Parameters:
      index - position of element
      Returns:
      element at given index
    • getPrecision

      public int getPrecision()
      Return precision for the decimal value.
    • getScale

      public int getScale()
      Return scale for the decimal 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 decimal value.
    • setBigEndian

      public void setBigEndian(int index, byte[] value)
      Set the decimal element at given index to the provided array of bytes. Decimal256 is now implemented as Native Endian. This API allows the user to pass a decimal value in the form of byte array in BE byte order.

      Consumers of Arrow code can use this API instead of first swapping the source bytes (doing a write and read) and then finally writing to ArrowBuf of decimal vector.

      This method takes care of adding the necessary padding if the length of byte array is less than 32 (length of decimal type).

      Parameters:
      index - position of element
      value - array of bytes containing decimal in big endian byte order.
    • set

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

      public void setSafe(int index, long start, ArrowBuf buffer, int length)
      Sets the element at given index using the buffer whose size maybe <= 32 bytes.
      Parameters:
      index - index to write the decimal to
      start - start of value in the buffer
      buffer - contains the decimal in native endian bytes
      length - length of the value in the buffer
    • setBigEndianSafe

      public void setBigEndianSafe(int index, long start, ArrowBuf buffer, int length)
      Sets the element at given index using the buffer whose size maybe <= 32 bytes.
      Parameters:
      index - index to write the decimal to
      start - start of value in the buffer
      buffer - contains the decimal in big endian bytes
      length - length of the value in the buffer
    • set

      public void set(int index, BigDecimal value)
      Set the element at the given index to the given value.
      Parameters:
      index - position of element
      value - BigDecimal containing decimal value.
    • set

      public void set(int index, long value)
      Set the element at the given index to the given value.
      Parameters:
      index - position of element
      value - long value.
    • set

      public void set(int index, NullableDecimal256Holder holder) throws IllegalArgumentException
      Set the element at the given index to the value set in data holder. If the value in holder is not indicated as set, element in the at the given index will be null.
      Parameters:
      index - position of element
      holder - nullable data holder for value of element
      Throws:
      IllegalArgumentException
    • set

      public void set(int index, Decimal256Holder holder)
      Set the element at the given index to the value set in data holder.
      Parameters:
      index - position of element
      holder - data holder for value of element
    • 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 decimal value.
    • setBigEndianSafe

      public void setBigEndianSafe(int index, byte[] value)
      Same as setBigEndian(int, byte[]) except that it handles the case when index is greater than or equal to existing value capacity BaseFixedWidthVector.getValueCapacity().
    • setSafe

      public void setSafe(int index, long start, ArrowBuf buffer)
      Same as set(int, 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
      start - start index of data in the buffer
      buffer - ArrowBuf containing decimal value.
    • setSafe

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

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

      public void setSafe(int index, NullableDecimal256Holder holder) throws IllegalArgumentException
      Same as set(int, NullableDecimalHolder) except that it handles the case when index is greater than or equal to existing value capacity BaseFixedWidthVector.getValueCapacity().
      Parameters:
      index - position of element
      holder - nullable data holder for value of element
      Throws:
      IllegalArgumentException
    • setSafe

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

      public void set(int index, int isSet, long start, ArrowBuf buffer)
      Store the given value at a particular position in the vector. isSet indicates whether the value is NULL or not.
      Parameters:
      index - position of the new value
      isSet - 0 for NULL value, 1 otherwise
      start - start position of the value in the buffer
      buffer - buffer containing the value to be stored in the vector
    • setSafe

      public void setSafe(int index, int isSet, long start, ArrowBuf buffer)
      Same as setSafe(int, int, int, ArrowBuf) except that it handles the case when the position of new value is beyond the current value capacity of the vector.
      Parameters:
      index - position of the new value
      isSet - 0 for NULL value, 1 otherwise
      start - start position of the value in the buffer
      buffer - buffer containing the value to be stored in the vector
    • 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