Class UnionVector

java.lang.Object
org.apache.drill.exec.vector.complex.UnionVector
All Implemented Interfaces:
Closeable, AutoCloseable, Iterable<ValueVector>, ValueVector

public class UnionVector extends Object implements ValueVector
  • Field Details

  • Constructor Details

  • Method Details

    • getAllocator

      public BufferAllocator getAllocator()
      Specified by:
      getAllocator in interface ValueVector
    • getSubTypes

      public List<TypeProtos.MinorType> getSubTypes()
    • subtype

      public <T extends ValueVector> T subtype(TypeProtos.MinorType type)
    • addType

      public void addType(ValueVector vector)
      Add an externally-created subtype vector. The vector must represent a type that does not yet exist in the union, and must be of OPTIONAL mode. Does not call the callback since the client (presumably) knows that it is adding the type. The caller must also allocate the buffer for the vector.
      Parameters:
      vector - subtype vector to add
    • addSubType

      public void addSubType(TypeProtos.MinorType type)
    • getMap

      public MapVector getMap()
    • getDict

      public DictVector getDict()
    • getList

      public ListVector getList()
    • getTinyIntVector

      public NullableTinyIntVector getTinyIntVector()
    • getUInt1Vector

      public NullableUInt1Vector getUInt1Vector()
    • getUInt2Vector

      public NullableUInt2Vector getUInt2Vector()
    • getSmallIntVector

      public NullableSmallIntVector getSmallIntVector()
    • getIntVector

      public NullableIntVector getIntVector()
    • getUInt4Vector

      public NullableUInt4Vector getUInt4Vector()
    • getFloat4Vector

      public NullableFloat4Vector getFloat4Vector()
    • getTimeVector

      public NullableTimeVector getTimeVector()
    • getIntervalYearVector

      public NullableIntervalYearVector getIntervalYearVector()
    • getBigIntVector

      public NullableBigIntVector getBigIntVector()
    • getUInt8Vector

      public NullableUInt8Vector getUInt8Vector()
    • getFloat8Vector

      public NullableFloat8Vector getFloat8Vector()
    • getDateVector

      public NullableDateVector getDateVector()
    • getTimeStampVector

      public NullableTimeStampVector getTimeStampVector()
    • getIntervalDayVector

      public NullableIntervalDayVector getIntervalDayVector()
    • getIntervalVector

      public NullableIntervalVector getIntervalVector()
    • getVarBinaryVector

      public NullableVarBinaryVector getVarBinaryVector()
    • getVarCharVector

      public NullableVarCharVector getVarCharVector()
    • getVar16CharVector

      public NullableVar16CharVector getVar16CharVector()
    • getVarDecimalVector

      public NullableVarDecimalVector getVarDecimalVector()
    • getBitVector

      public NullableBitVector getBitVector()
    • getMember

      public ValueVector getMember(TypeProtos.MinorType type)
      Add or get a type member given the type.
      Parameters:
      type - the type of the vector to retrieve
      Returns:
      the (potentially newly created) vector that backs the given type
    • member

      public <T extends ValueVector> T member(TypeProtos.MinorType type)
    • getTypeValue

      public int getTypeValue(int index)
    • getTypeVector

      public UInt1Vector getTypeVector()
    • getTypeMap

      public MapVector getTypeMap()
    • 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
      Throws:
      OutOfMemoryException - Thrown if no memory can be allocated.
    • allocateNew

      public void allocateNew(int rowCount) throws OutOfMemoryException
      Throws:
      OutOfMemoryException
    • 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.
    • setInitialCapacity

      public void setInitialCapacity(int numRecords)
      Description copied from interface: ValueVector
      Set the initial record capacity
      Specified by:
      setInitialCapacity in interface ValueVector
    • 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
    • close

      public void close()
      Description copied from interface: ValueVector
      Alternative to clear(). Allows use as an AutoCloseable in try-with-resources.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface ValueVector
    • clear

      public void clear()
      Description copied from interface: ValueVector
      Release the underlying DrillBuf and reset the ValueVector to empty.
      Specified by:
      clear in interface ValueVector
    • getField

      public MaterializedField getField()
      Description copied from interface: ValueVector
      Get information about how this field is materialized.
      Specified by:
      getField in interface ValueVector
    • collectLedgers

      public void collectLedgers(Set<AllocationManager.BufferLedger> ledgers)
      Description copied from interface: ValueVector
      Add the ledgers underlying the buffers underlying the components of the vector to the set provided. Used to determine actual memory allocation.
      Specified by:
      collectLedgers in interface ValueVector
      Parameters:
      ledgers - set of ledgers to which to add ledgers for this vector
    • getPayloadByteCount

      public int getPayloadByteCount(int valueCount)
      Description copied from interface: ValueVector
      Return the number of value bytes consumed by actual data.
      Specified by:
      getPayloadByteCount in interface ValueVector
    • getTransferPair

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

      public TransferPair getTransferPair(String ref, BufferAllocator allocator)
      Specified by:
      getTransferPair in interface ValueVector
    • makeTransferPair

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

      public void transferTo(UnionVector target)
    • copyFrom

      public void copyFrom(int inIndex, int outIndex, UnionVector from)
    • copyFromSafe

      public void copyFromSafe(int inIndex, int outIndex, UnionVector from)
    • copyEntry

      public void copyEntry(int toIndex, ValueVector from, int fromIndex)
      Specified by:
      copyEntry in interface ValueVector
    • addVector

      public ValueVector addVector(ValueVector v)
      Add a vector that matches the argument. Transfer the buffer from the argument to the new vector.
      Parameters:
      v - the vector to clone and add
      Returns:
      the cloned vector that now holds the data from the argument
    • setFirstType

      public ValueVector setFirstType(ValueVector v, int newValueCount)
    • toNullable

      public void toNullable(ValueVector nullableVector)
      Description copied from interface: ValueVector
      Convert a non-nullable vector to nullable by shuffling the data from one to the other. Avoids the need to generate copy code just to change mode. If this vector is non-nullable, accepts a nullable dual (same minor type, different mode.) If the vector is non-nullable, or non-scalar, then throws an exception.
      Specified by:
      toNullable in interface ValueVector
      Parameters:
      nullableVector - nullable vector of the same minor type as this vector
    • getAccessor

      public UnionVector.Accessor getAccessor()
      Description copied from interface: ValueVector
      Returns an accessor that is used to read from this vector instance.
      Specified by:
      getAccessor in interface ValueVector
    • getMutator

      public UnionVector.Mutator getMutator()
      Description copied from interface: ValueVector
      Returns an mutator that is used to write to this vector instance.
      Specified by:
      getMutator in interface ValueVector
    • getReader

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

      public FieldWriter getWriter()
    • getMetadata

      public UserBitShared.SerializedField getMetadata()
      Description copied from interface: ValueVector
      Get the metadata for this field. Used in serialization
      Specified by:
      getMetadata in interface ValueVector
      Returns:
      FieldMetadata for this field.
    • getBufferSize

      public int getBufferSize()
      Description copied from interface: ValueVector
      Returns the number of bytes that is used by this vector instance. This is a bit of a misnomer. Returns the number of bytes used by data in this instance.
      Specified by:
      getBufferSize in interface ValueVector
    • getAllocatedSize

      public int getAllocatedSize()
      Description copied from interface: ValueVector
      Returns the total size of buffers allocated by this vector. Has meaning only when vectors are directly allocated and each vector has its own buffer. Does not have meaning for vectors deserialized from the network or disk in which multiple vectors share the same vector.
      Specified by:
      getAllocatedSize in interface ValueVector
      Returns:
      allocated buffer size, in bytes
    • getBufferSizeFor

      public int getBufferSizeFor(int valueCount)
      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 Mutator.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:
      valueCount - the number of values to assume this vector contains
      Returns:
      the buffer size if this vector is holding valueCount values
    • getBuffers

      public DrillBuf[] 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.
    • load

      public void load(UserBitShared.SerializedField metadata, DrillBuf buffer)
      Description copied from interface: ValueVector
      Load the data provided in the buffer. Typically used when deserializing from the wire.
      Specified by:
      load in interface ValueVector
      Parameters:
      metadata - Metadata used to decode the incoming buffer.
      buffer - The buffer that contains the ValueVector.
    • iterator

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

      public void exchange(ValueVector other)
      Description copied from interface: ValueVector
      Exchange state with another value vector of the same type. Used to implement look-ahead writers.
      Specified by:
      exchange in interface ValueVector