Class DenseUnionVector

java.lang.Object
org.apache.arrow.vector.complex.AbstractContainerVector
org.apache.arrow.vector.complex.DenseUnionVector
All Implemented Interfaces:
Closeable, AutoCloseable, Iterable<ValueVector>, DensityAwareVector, FieldVector, ValueIterableVector<Object>, ValueVector

public class DenseUnionVector extends AbstractContainerVector implements FieldVector, ValueIterableVector<Object>
  • Field Details

  • Constructor Details

  • Method Details

    • empty

      public static DenseUnionVector empty(String name, BufferAllocator allocator)
    • getAllocator

      public BufferAllocator getAllocator()
      Specified by:
      getAllocator in interface ValueVector
      Overrides:
      getAllocator in class AbstractContainerVector
    • getMinorType

      public Types.MinorType getMinorType()
      Specified by:
      getMinorType in interface ValueVector
    • initializeChildrenFromFields

      public void initializeChildrenFromFields(List<Field> children)
      Description copied from interface: FieldVector
      Initializes the child vectors to be later loaded with loadBuffers.
      Specified by:
      initializeChildrenFromFields in interface FieldVector
      Parameters:
      children - the schema
    • getChildrenFromFields

      public List<FieldVector> getChildrenFromFields()
      Description copied from interface: FieldVector
      The returned list is the same size as the list passed to initializeChildrenFromFields.
      Specified by:
      getChildrenFromFields in interface FieldVector
      Returns:
      the children according to schema (empty for primitive types)
    • loadFieldBuffers

      public void loadFieldBuffers(ArrowFieldNode fieldNode, List<ArrowBuf> ownBuffers)
      Description copied from interface: FieldVector
      Loads data in the vectors. (ownBuffers must be the same size as getFieldVectors())
      Specified by:
      loadFieldBuffers in interface FieldVector
      Parameters:
      fieldNode - the fieldNode
      ownBuffers - the buffers for this Field (own buffers only, children not included)
    • getFieldBuffers

      public List<ArrowBuf> getFieldBuffers()
      Description copied from interface: FieldVector
      Get the buffers of the fields, (same size as getFieldVectors() since it is their content).
      Specified by:
      getFieldBuffers in interface FieldVector
      Returns:
      the buffers containing the data for this vector (ready for reading)
    • getFieldInnerVectors

      @Deprecated public List<BufferBacked> getFieldInnerVectors()
      Deprecated.
      This API will be removed as the current implementations no longer support inner vectors.
      Get the inner vectors.
      Specified by:
      getFieldInnerVectors in interface FieldVector
      Returns:
      the inner vectors for this field as defined by the TypeLayout
    • registerNewTypeId

      public byte registerNewTypeId(Field field)
    • getOffsetBufferAddress

      public long getOffsetBufferAddress()
      Description copied from interface: FieldVector
      Gets the starting address of the underlying buffer associated with offset vector.
      Specified by:
      getOffsetBufferAddress in interface FieldVector
      Returns:
      buffer address
    • getDataBufferAddress

      public long getDataBufferAddress()
      Description copied from interface: FieldVector
      Gets the starting address of the underlying buffer associated with data vector.
      Specified by:
      getDataBufferAddress in interface FieldVector
      Returns:
      buffer address
    • getValidityBufferAddress

      public long getValidityBufferAddress()
      Description copied from interface: FieldVector
      Gets the starting address of the underlying buffer associated with validity vector.
      Specified by:
      getValidityBufferAddress in interface FieldVector
      Returns:
      buffer address
    • getValidityBuffer

      public ArrowBuf getValidityBuffer()
      Description copied from interface: ValueVector
      Gets the underlying buffer associated with validity vector.
      Specified by:
      getValidityBuffer in interface ValueVector
      Returns:
      buffer
    • getOffsetBuffer

      public ArrowBuf getOffsetBuffer()
      Description copied from interface: ValueVector
      Gets the underlying buffer associated with offset vector.
      Specified by:
      getOffsetBuffer in interface ValueVector
      Returns:
      buffer
    • getTypeBuffer

      public ArrowBuf getTypeBuffer()
    • getDataBuffer

      public ArrowBuf getDataBuffer()
      Description copied from interface: ValueVector
      Gets the underlying buffer associated with data vector.
      Specified by:
      getDataBuffer in interface ValueVector
      Returns:
      buffer
    • getStruct

      public StructVector getStruct(byte typeId)
    • getTinyIntVector

      public TinyIntVector getTinyIntVector(byte typeId)
    • getUInt1Vector

      public UInt1Vector getUInt1Vector(byte typeId)
    • getUInt2Vector

      public UInt2Vector getUInt2Vector(byte typeId)
    • getSmallIntVector

      public SmallIntVector getSmallIntVector(byte typeId)
    • getFloat2Vector

      public Float2Vector getFloat2Vector(byte typeId)
    • getIntVector

      public IntVector getIntVector(byte typeId)
    • getUInt4Vector

      public UInt4Vector getUInt4Vector(byte typeId)
    • getFloat4Vector

      public Float4Vector getFloat4Vector(byte typeId)
    • getDateDayVector

      public DateDayVector getDateDayVector(byte typeId)
    • getIntervalYearVector

      public IntervalYearVector getIntervalYearVector(byte typeId)
    • getTimeSecVector

      public TimeSecVector getTimeSecVector(byte typeId)
    • getTimeMilliVector

      public TimeMilliVector getTimeMilliVector(byte typeId)
    • getBigIntVector

      public BigIntVector getBigIntVector(byte typeId)
    • getUInt8Vector

      public UInt8Vector getUInt8Vector(byte typeId)
    • getFloat8Vector

      public Float8Vector getFloat8Vector(byte typeId)
    • getDateMilliVector

      public DateMilliVector getDateMilliVector(byte typeId)
    • getTimeStampSecVector

      public TimeStampSecVector getTimeStampSecVector(byte typeId)
    • getTimeStampMilliVector

      public TimeStampMilliVector getTimeStampMilliVector(byte typeId)
    • getTimeStampMicroVector

      public TimeStampMicroVector getTimeStampMicroVector(byte typeId)
    • getTimeStampNanoVector

      public TimeStampNanoVector getTimeStampNanoVector(byte typeId)
    • getTimeMicroVector

      public TimeMicroVector getTimeMicroVector(byte typeId)
    • getTimeNanoVector

      public TimeNanoVector getTimeNanoVector(byte typeId)
    • getIntervalDayVector

      public IntervalDayVector getIntervalDayVector(byte typeId)
    • getIntervalMonthDayNanoVector

      public IntervalMonthDayNanoVector getIntervalMonthDayNanoVector(byte typeId)
    • getDecimal256Vector

      public Decimal256Vector getDecimal256Vector(byte typeId, ArrowType arrowType)
    • getDecimalVector

      public DecimalVector getDecimalVector(byte typeId, ArrowType arrowType)
    • getVarBinaryVector

      public VarBinaryVector getVarBinaryVector(byte typeId)
    • getVarCharVector

      public VarCharVector getVarCharVector(byte typeId)
    • getViewVarBinaryVector

      public ViewVarBinaryVector getViewVarBinaryVector(byte typeId)
    • getViewVarCharVector

      public ViewVarCharVector getViewVarCharVector(byte typeId)
    • getLargeVarCharVector

      public LargeVarCharVector getLargeVarCharVector(byte typeId)
    • getLargeVarBinaryVector

      public LargeVarBinaryVector getLargeVarBinaryVector(byte typeId)
    • getBitVector

      public BitVector getBitVector(byte typeId)
    • getList

      public ListVector getList(byte typeId)
    • getMap

      public MapVector getMap(byte typeId)
    • getTypeId

      public byte getTypeId(int index)
    • getVectorByType

      public ValueVector getVectorByType(byte typeId)
    • allocateNew

      public void allocateNew() throws OutOfMemoryException
      Description copied from interface: ValueVector
      Allocate new buffers. ValueVector implements logic to determine how much to allocate.
      Specified by:
      allocateNew in interface ValueVector
      Overrides:
      allocateNew in class AbstractContainerVector
      Throws:
      OutOfMemoryException - Thrown if no memory can be allocated.
    • allocateNewSafe

      public boolean allocateNewSafe()
      Description copied from interface: ValueVector
      Allocates new buffers. ValueVector implements logic to determine how much to allocate.
      Specified by:
      allocateNewSafe in interface ValueVector
      Returns:
      Returns true if allocation was successful.
    • reAlloc

      public void reAlloc()
      Description copied from interface: ValueVector
      Allocate new buffer with double capacity, and copy data into the new buffer. Replace vector's buffer with new buffer, and release old one
      Specified by:
      reAlloc in interface ValueVector
    • getOffset

      public int getOffset(int index)
    • setInitialCapacity

      public void setInitialCapacity(int numRecords)
      Description copied from interface: ValueVector
      Set the initial record capacity.
      Specified by:
      setInitialCapacity in interface ValueVector
      Parameters:
      numRecords - the initial record capacity.
    • getValueCapacity

      public int getValueCapacity()
      Description copied from interface: ValueVector
      Returns the maximum number of values that can be stored in this vector instance.
      Specified by:
      getValueCapacity in interface ValueVector
      Returns:
      the maximum number of values that can be stored in this vector instance.
    • close

      public void close()
      Description copied from class: AbstractContainerVector
      Clears out all underlying child vectors.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface ValueVector
      Overrides:
      close in class AbstractContainerVector
    • clear

      public void clear()
      Description copied from interface: ValueVector
      Release any owned ArrowBuf and reset the ValueVector to the initial state. If the vector has any child vectors, they will also be cleared.
      Specified by:
      clear in interface ValueVector
    • reset

      public void reset()
      Description copied from interface: ValueVector
      Reset the ValueVector to the initial state without releasing any owned ArrowBuf. Buffer capacities will remain unchanged and any previous data will be zeroed out. This includes buffers for data, validity, offset, etc. If the vector has any child vectors, they will also be reset.
      Specified by:
      reset in interface ValueVector
    • getField

      public Field getField()
      Description copied from interface: ValueVector
      Get information about how this field is materialized.
      Specified by:
      getField in interface ValueVector
      Returns:
      the field corresponding to this vector
    • getTransferPair

      public TransferPair getTransferPair(BufferAllocator allocator)
      Description copied from interface: ValueVector
      To transfer quota responsibility.
      Specified by:
      getTransferPair in interface ValueVector
      Parameters:
      allocator - the target allocator
      Returns:
      a transfer pair, creating a new target vector of the same type.
    • getTransferPair

      public TransferPair getTransferPair(String ref, BufferAllocator allocator)
      Description copied from interface: ValueVector
      To transfer quota responsibility.
      Specified by:
      getTransferPair in interface ValueVector
      Parameters:
      ref - the name of the vector
      allocator - the target allocator
      Returns:
      a transfer pair, creating a new target vector of the same type.
    • getTransferPair

      public TransferPair getTransferPair(String ref, BufferAllocator allocator, CallBack callBack)
      Description copied from interface: ValueVector
      To transfer quota responsibility.
      Specified by:
      getTransferPair in interface ValueVector
      Parameters:
      ref - the name of the vector
      allocator - the target allocator
      callBack - A schema change callback.
      Returns:
      a transfer pair, creating a new target vector of the same type.
    • getTransferPair

      public TransferPair getTransferPair(Field field, BufferAllocator allocator)
      Description copied from interface: ValueVector
      To transfer quota responsibility.
      Specified by:
      getTransferPair in interface ValueVector
      Parameters:
      field - the Field object used by the target vector
      allocator - the target allocator
      Returns:
      a transfer pair, creating a new target vector of the same type.
    • getTransferPair

      public TransferPair getTransferPair(Field field, BufferAllocator allocator, CallBack callBack)
      Description copied from interface: ValueVector
      To transfer quota responsibility.
      Specified by:
      getTransferPair in interface ValueVector
      Parameters:
      field - the Field object used by the target vector
      allocator - the target allocator
      callBack - A schema change callback.
      Returns:
      a transfer pair, creating a new target vector of the same type.
    • makeTransferPair

      public TransferPair makeTransferPair(ValueVector target)
      Description copied from interface: ValueVector
      Makes a new transfer pair used to transfer underlying buffers.
      Specified by:
      makeTransferPair in interface ValueVector
      Parameters:
      target - the target for the transfer
      Returns:
      a new transfer pair that is used to transfer underlying buffers into the target vector.
    • copyFrom

      public void copyFrom(int inIndex, int outIndex, ValueVector from)
      Description copied from interface: ValueVector
      Copy a cell value from a particular index in source vector to a particular position in this vector.
      Specified by:
      copyFrom in interface ValueVector
      Overrides:
      copyFrom in class AbstractContainerVector
      Parameters:
      inIndex - position to copy from in source vector
      outIndex - position to copy to in this vector
      from - source vector
    • copyFromSafe

      public void copyFromSafe(int inIndex, int outIndex, ValueVector from)
      Description copied from interface: ValueVector
      Same as ValueVector.copyFrom(int, int, ValueVector) except that it handles the case when the capacity of the vector needs to be expanded before copy.
      Specified by:
      copyFromSafe in interface ValueVector
      Overrides:
      copyFromSafe in class AbstractContainerVector
      Parameters:
      inIndex - position to copy from in source vector
      outIndex - position to copy to in this vector
      from - source vector
    • addVector

      public FieldVector addVector(byte typeId, FieldVector v)
    • getReader

      public FieldReader getReader()
      Description copied from interface: ValueVector
      Get a reader for this vector.
      Specified by:
      getReader in interface ValueVector
      Returns:
      a field reader that supports reading values from this vector.
    • getWriter

      public FieldWriter getWriter()
    • getBufferSize

      public int getBufferSize()
      Description copied from interface: ValueVector
      Get the number of bytes used by this vector.
      Specified by:
      getBufferSize in interface ValueVector
      Returns:
      the number of bytes that is used by this vector instance.
    • getBufferSizeFor

      public int getBufferSizeFor(int count)
      Description copied from interface: ValueVector
      Returns the number of bytes that is used by this vector if it holds the given number of values. The result will be the same as if setValueCount() were called, followed by calling getBufferSize(), but without any of the closing side-effects that setValueCount() implies wrt finishing off the population of a vector. Some operations might wish to use this to determine how much memory has been used by a vector so far, even though it is not finished being populated.
      Specified by:
      getBufferSizeFor in interface ValueVector
      Parameters:
      count - the number of values to assume this vector contains
      Returns:
      the buffer size if this vector is holding valueCount values
    • getBuffers

      public ArrowBuf[] getBuffers(boolean clear)
      Description copied from interface: ValueVector
      Return the underlying buffers associated with this vector. Note that this doesn't impact the reference counts for this buffer so it only should be used for in-context access. Also note that this buffer changes regularly thus external classes shouldn't hold a reference to it (unless they change it).
      Specified by:
      getBuffers in interface ValueVector
      Parameters:
      clear - Whether to clear vector before returning; the buffers will still be refcounted; but the returned array will be the only reference to them
      Returns:
      The underlying buffers that is used by this vector instance.
    • iterator

      public Iterator<ValueVector> iterator()
      Specified by:
      iterator in interface Iterable<ValueVector>
    • getObject

      public Object getObject(int index)
      Description copied from interface: ValueVector
      Get friendly type object from the vector.
      Specified by:
      getObject in interface ValueVector
      Parameters:
      index - index of object to get
      Returns:
      friendly type object
    • get

      public void get(int index, DenseUnionHolder holder)
    • getValueCount

      public int getValueCount()
      Description copied from interface: ValueVector
      Gets the number of values.
      Specified by:
      getValueCount in interface ValueVector
      Returns:
      number of values in the vector
    • isNull

      public boolean isNull(int index)
      IMPORTANT: Union types always return non null as there is no validity buffer. To check validity correctly you must check the underlying vector.
      Specified by:
      isNull in interface ValueVector
      Parameters:
      index - index to check for null
      Returns:
      true if element is null
    • getNullCount

      public int getNullCount()
      Description copied from interface: ValueVector
      Returns number of null elements in the vector.
      Specified by:
      getNullCount in interface ValueVector
      Returns:
      number of null elements
    • isSet

      public int isSet(int index)
    • setValueCount

      public void setValueCount(int valueCount)
      Description copied from interface: ValueVector
      Set number of values in the vector.
      Specified by:
      setValueCount in interface ValueVector
    • setSafe

      public void setSafe(int index, DenseUnionHolder holder)
    • setSafe

      public void setSafe(int index, NullableTinyIntHolder holder)
    • setSafe

      public void setSafe(int index, NullableUInt1Holder holder)
    • setSafe

      public void setSafe(int index, NullableUInt2Holder holder)
    • setSafe

      public void setSafe(int index, NullableSmallIntHolder holder)
    • setSafe

      public void setSafe(int index, NullableFloat2Holder holder)
    • setSafe

      public void setSafe(int index, NullableIntHolder holder)
    • setSafe

      public void setSafe(int index, NullableUInt4Holder holder)
    • setSafe

      public void setSafe(int index, NullableFloat4Holder holder)
    • setSafe

      public void setSafe(int index, NullableDateDayHolder holder)
    • setSafe

      public void setSafe(int index, NullableIntervalYearHolder holder)
    • setSafe

      public void setSafe(int index, NullableTimeSecHolder holder)
    • setSafe

      public void setSafe(int index, NullableTimeMilliHolder holder)
    • setSafe

      public void setSafe(int index, NullableBigIntHolder holder)
    • setSafe

      public void setSafe(int index, NullableUInt8Holder holder)
    • setSafe

      public void setSafe(int index, NullableFloat8Holder holder)
    • setSafe

      public void setSafe(int index, NullableDateMilliHolder holder)
    • setSafe

      public void setSafe(int index, NullableTimeStampSecHolder holder)
    • setSafe

      public void setSafe(int index, NullableTimeStampMilliHolder holder)
    • setSafe

      public void setSafe(int index, NullableTimeStampMicroHolder holder)
    • setSafe

      public void setSafe(int index, NullableTimeStampNanoHolder holder)
    • setSafe

      public void setSafe(int index, NullableTimeMicroHolder holder)
    • setSafe

      public void setSafe(int index, NullableTimeNanoHolder holder)
    • setSafe

      public void setSafe(int index, NullableIntervalDayHolder holder)
    • setSafe

      public void setSafe(int index, NullableIntervalMonthDayNanoHolder holder)
    • setSafe

      public void setSafe(int index, NullableDecimal256Holder holder)
    • setSafe

      public void setSafe(int index, NullableDecimalHolder holder)
    • setSafe

      public void setSafe(int index, NullableVarBinaryHolder holder)
    • setSafe

      public void setSafe(int index, NullableVarCharHolder holder)
    • setSafe

      public void setSafe(int index, NullableViewVarBinaryHolder holder)
    • setSafe

      public void setSafe(int index, NullableViewVarCharHolder holder)
    • setSafe

      public void setSafe(int index, NullableLargeVarCharHolder holder)
    • setSafe

      public void setSafe(int index, NullableLargeVarBinaryHolder holder)
    • setSafe

      public void setSafe(int index, NullableBitHolder holder)
    • setTypeId

      public void setTypeId(int index, byte typeId)
    • setOffset

      public void setOffset(int index, int offset)
    • hashCode

      public int hashCode(int index, ArrowBufHasher hasher)
      Description copied from interface: ValueVector
      Returns hashCode of element in index with the given hasher.
      Specified by:
      hashCode in interface ValueVector
    • hashCode

      public int hashCode(int index)
      Description copied from interface: ValueVector
      Returns hashCode of element in index with the default hasher.
      Specified by:
      hashCode in interface ValueVector
    • accept

      public <OUT, IN> OUT accept(VectorVisitor<OUT,IN> visitor, IN value)
      Description copied from interface: ValueVector
      Accept a generic VectorVisitor and return the result.
      Specified by:
      accept in interface ValueVector
      Type Parameters:
      OUT - the output result type.
      IN - the input data together with visitor.
    • getName

      public String getName()
      Description copied from interface: ValueVector
      Gets the name of the vector.
      Specified by:
      getName in interface ValueVector
      Overrides:
      getName in class AbstractContainerVector
      Returns:
      the name of the vector.
    • addOrGet

      public <T extends FieldVector> T addOrGet(String name, FieldType fieldType, Class<T> clazz)
      Specified by:
      addOrGet in class AbstractContainerVector
    • getChild

      public <T extends FieldVector> T getChild(String name, Class<T> clazz)
      Specified by:
      getChild in class AbstractContainerVector
    • getChildVectorWithOrdinal

      public VectorWithOrdinal getChildVectorWithOrdinal(String name)
      Specified by:
      getChildVectorWithOrdinal in class AbstractContainerVector
    • size

      public int size()
      Specified by:
      size in class AbstractContainerVector
    • setInitialCapacity

      public void setInitialCapacity(int valueCount, double density)
      Description copied from interface: DensityAwareVector
      Set value with density.
      Specified by:
      setInitialCapacity in interface DensityAwareVector
      Parameters:
      valueCount - the number of values in this vector
      density - the density of the vector
    • setNull

      public void setNull(int index)
      Set the element at the given index to null. For DenseUnionVector, it throws an UnsupportedOperationException as nulls are not supported at the top level and isNull() always returns false.
      Specified by:
      setNull in interface FieldVector
      Parameters:
      index - position of element
      Throws:
      UnsupportedOperationException - whenever invoked