Class AbstractStructVector

java.lang.Object
org.apache.arrow.vector.complex.AbstractContainerVector
org.apache.arrow.vector.complex.AbstractStructVector
All Implemented Interfaces:
Closeable, AutoCloseable, Iterable<ValueVector>, DensityAwareVector, ValueVector
Direct Known Subclasses:
NonNullableStructVector

public abstract class AbstractStructVector extends AbstractContainerVector
Base class for StructVectors. Currently used by NonNullableStructVector
  • Field Details

    • allowConflictPolicyChanges

      protected final boolean allowConflictPolicyChanges
  • Constructor Details

  • Method Details

    • setConflictPolicy

      Set conflict policy and return last conflict policy state.
    • getConflictPolicy

      public AbstractStructVector.ConflictPolicy getConflictPolicy()
    • 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.
    • 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
    • addOrGet

      public <T extends FieldVector> T addOrGet(String childName, FieldType fieldType, 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:
      childName - the name of the field
      fieldType - the type for the vector
      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.
      Parameters:
      id - the ordinal of the child to return
      Returns:
      the corresponding child
    • getChild

      public <T extends FieldVector> T getChild(String name, Class<T> clazz)
      Returns a ValueVector instance of subtype of T corresponding to the given field name if exists or null.

      If there is more than one element for name this will return the first inserted.

      Specified by:
      getChild in class AbstractContainerVector
      Parameters:
      name - the name of the child to return
      clazz - the expected type of the child
      Returns:
      the child corresponding to this name
    • add

      protected ValueVector add(String childName, FieldType fieldType)
    • putChild

      protected void putChild(String name, FieldVector 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.

      Parameters:
      name - the name of the child to add
      vector - the vector to add as a child
    • putVector

      protected void putVector(String name, FieldVector vector)
      Inserts the input vector into the map if it does not exist.

      If the field name already exists the conflict is handled according to the currently set ConflictPolicy

      Parameters:
      name - field name
      vector - vector to be inserted
    • getChildren

      protected List<FieldVector> getChildren()
      Get child vectors.
      Returns:
      a sequence of underlying child vectors.
    • getChildFieldNames

      public List<String> getChildFieldNames()
      Get child field names.
    • size

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

      public Iterator<ValueVector> iterator()
    • getPrimitiveVectors

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

      public VectorWithOrdinal getChildVectorWithOrdinal(String name)
      Get a child vector by name. If duplicate names this returns the first inserted.
      Specified by:
      getChildVectorWithOrdinal in class AbstractContainerVector
      Parameters:
      name - the name of the child to return
      Returns:
      a vector with its corresponding ordinal mapping if field exists or null.
    • 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).
      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
      Get the number of bytes used by this vector.
      Returns:
      the number of bytes that is used by this vector instance.
    • toString

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