Class UInt4Vector

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

public final class UInt4Vector extends BaseFixedWidthVector implements BaseIntVector, ValueIterableVector<Integer>
UInt4Vector implements a fixed width (4 bytes) vector of integer values which could be null. A validity buffer (bit vector) is maintained to track which elements in the vector are null.
  • Field Details

    • PROMOTION_MASK

      public static final long PROMOTION_MASK
      The mask to use when promoting the unsigned int value to a long int.
      See Also:
    • MAX_UINT4

      public static final int MAX_UINT4
      The maximum 32-bit unsigned integer.
      See Also:
    • TYPE_WIDTH

      public static final byte TYPE_WIDTH
      See Also:
  • Constructor Details

  • 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()
      Specified by:
      getMinorType in interface ValueVector
    • getNoOverflow

      public static long getNoOverflow(ArrowBuf buffer, int index)
      Given a data buffer, get the value stored at a particular position in the vector.

      To avoid overflow, the returned type is one step up from the signed type.

      This method is mainly meant for integration tests.

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

      public int 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, NullableUInt4Holder 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 Integer getObject(int index)
      Same as get(int).
      Specified by:
      getObject in interface ValueVector
      Parameters:
      index - position of element
      Returns:
      element at given index
    • getObjectNoOverflow

      public Long getObjectNoOverflow(int index)
      Same as get(int).
      Parameters:
      index - position of element
      Returns:
      element at given index
    • set

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

      public void set(int index, NullableUInt4Holder 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, UInt4Holder 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, int value)
      Same as set(int, int) 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 - value of element
    • setSafe

      public void setSafe(int index, NullableUInt4Holder holder) throws IllegalArgumentException
      Same as set(int, NullableUInt4Holder) 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, UInt4Holder holder)
      Same as set(int, UInt4Holder) 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, int value)
      Sets the value at index to value isSet > 0, otherwise sets the index position to invalid/null.
    • setSafe

      public void setSafe(int index, int isSet, int value)
      Same as set(int, int, int) but will reallocate if the buffer if index is larger than the current capacity.
    • getTransferPair

      public TransferPair getTransferPair(String ref, BufferAllocator allocator)
      Description copied from class: BaseFixedWidthVector
      Construct a transfer pair of this vector and another vector of 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)
      Description copied from interface: ValueVector
      Makes a new transfer pair used to transfer underlying buffers.
      Specified by:
      makeTransferPair in interface ValueVector
      Parameters:
      to - the target for the transfer
      Returns:
      a new transfer pair that is used to transfer underlying buffers into the target vector.
    • setWithPossibleTruncate

      public void setWithPossibleTruncate(int index, long value)
      Description copied from interface: BaseIntVector
      Sets the value at index, note this value may need to be truncated. Note this is safe version (i.e. call setSafe(int, ...) method in vector)
      Specified by:
      setWithPossibleTruncate in interface BaseIntVector
    • setUnsafeWithPossibleTruncate

      public void setUnsafeWithPossibleTruncate(int index, long value)
      Description copied from interface: BaseIntVector
      Sets the value at index, note this value may need to be truncated. Note this is unsafe version (i.e. call set(int, ...) method in vector)
      Specified by:
      setUnsafeWithPossibleTruncate in interface BaseIntVector
    • getValueAsLong

      public long getValueAsLong(int index)
      Description copied from interface: BaseIntVector
      Gets the value at index. This value may have been extended to long and will throw NullPointerException if the value is null. Note null check could be turned off via NullCheckingForGet.
      Specified by:
      getValueAsLong in interface BaseIntVector
    • toString

      public String toString()
      Description copied from class: BaseValueVector
      Representation of vector suitable for debugging.
      Overrides:
      toString in class BaseValueVector