Class AbstractMapVector

java.lang.Object
org.apache.drill.exec.vector.complex.AbstractContainerVector
org.apache.drill.exec.vector.complex.AbstractMapVector
All Implemented Interfaces:
Closeable, AutoCloseable, Iterable<ValueVector>, ValueVector
Direct Known Subclasses:
AbstractRepeatedMapVector, MapVector

public abstract class AbstractMapVector extends AbstractContainerVector
Base class for MapVectors. Currently used by AbstractRepeatedMapVector and MapVector
  • Constructor Details

  • Method Details

    • 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
    • allocateNewSafe

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

      public <T extends ValueVector> T addOrGet(String name, TypeProtos.MajorType type, Class<T> clazz)
      Adds a new field with the given parameters or replaces the existing one and consequently returns the resultant ValueVector. Execution takes place in the following order:
      • if field is new, create and insert a new vector of desired type.
      • if field exists and existing vector is of desired vector type, return the vector.
      • if field exists and null filled, clear the existing vector; create and insert a new vector of desired type.
      • otherwise, throw an IllegalStateException
      Specified by:
      addOrGet in class AbstractContainerVector
      Type Parameters:
      T - class type of expected vector type
      Parameters:
      name - name of the field
      type - type of the field
      clazz - class of expected vector type
      Returns:
      resultant ValueVector
      Throws:
      IllegalStateException - raised if there is a hard schema change
    • getChildByOrdinal

      public ValueVector getChildByOrdinal(int id)
      Returns a ValueVector corresponding to the given ordinal identifier.
    • getChild

      public <T extends ValueVector> T getChild(String name, Class<T> clazz)
      Returns a ValueVector instance of subtype of corresponding to the given field name if exists or null.
      Specified by:
      getChild in class AbstractContainerVector
    • putChild

      public void putChild(String name, ValueVector vector)
      Inserts the vector with the given name if it does not exist else replaces it with the new value. Note that this method does not enforce any vector type check nor throws a schema change exception.
    • putVector

      protected void putVector(String name, ValueVector vector)
      Inserts the input vector into the map if it does not exist, replaces if it exists already
      Parameters:
      name - field name
      vector - vector to be inserted
    • getChildren

      protected Collection<ValueVector> getChildren()
      Returns a sequence of underlying child vectors.
    • size

      public int size()
      Returns the number of underlying child vectors.
      Specified by:
      size in class AbstractContainerVector
    • iterator

      public Iterator<ValueVector> iterator()
    • getPrimitiveVectors

      public List<ValueVector> getPrimitiveVectors()
      Returns a list of scalar child vectors recursing the entire vector hierarchy.
    • getChildVectorWithOrdinal

      public VectorWithOrdinal getChildVectorWithOrdinal(String name)
      Returns a vector with its corresponding ordinal mapping if field exists or null.
      Specified by:
      getChildVectorWithOrdinal in class AbstractContainerVector
    • 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).
      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.
    • 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.
    • 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.
      Returns:
      allocated buffer size, in bytes
    • 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.
      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.
    • 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.