Class SimpleListShim

java.lang.Object
org.apache.drill.exec.vector.accessor.writer.SimpleListShim
All Implemented Interfaces:
UnionShim, WriterEvents, WriterPosition

public class SimpleListShim extends Object implements UnionShim
Shim for a list that holds a single type, but may eventually become a list of variants. (A list that is declared to hold a single type is implemented using the ListWriterImpl class that directly holds that single type.) This shim is needed when we want to present a uniform variant interface for a list that holds zero one (this case) or many types.
  • Constructor Details

    • SimpleListShim

      public SimpleListShim()
    • SimpleListShim

      public SimpleListShim(AbstractObjectWriter writer)
  • Method Details

    • bindWriter

      public void bindWriter(UnionWriterImpl writer)
      Specified by:
      bindWriter in interface UnionShim
    • bindIndex

      public void bindIndex(ColumnWriterIndex index)
      Description copied from interface: WriterEvents
      Bind the writer to a writer index.
      Specified by:
      bindIndex in interface WriterEvents
      Parameters:
      index - the writer index (top level or nested for arrays)
    • bindListener

      public void bindListener(WriterEvents.ColumnWriterListener listener)
      Description copied from interface: WriterEvents
      Bind a listener to the underlying vector writer. This listener reports on vector events (overflow, growth), and so is called only when the writer is backed by a vector. The listener is ignored (and never called) for dummy (non-projected) columns. If the column is compound (such as for a nullable or repeated column, or for a map), then the writer is bound to the individual components.
      Specified by:
      bindListener in interface WriterEvents
      Parameters:
      listener - the vector event listener to bind
    • hasType

      public boolean hasType(TypeProtos.MinorType type)
      Specified by:
      hasType in interface UnionShim
    • setType

      public void setType(TypeProtos.MinorType type)
      Specified by:
      setType in interface UnionShim
    • member

      public ObjectWriter member(TypeProtos.MinorType type)
      Description copied from interface: UnionShim
      Return an existing writer for the given type, or create a new one if needed.
      Specified by:
      member in interface UnionShim
      Parameters:
      type - desired variant type
      Returns:
      a writer for that type
    • memberWriter

      public AbstractObjectWriter memberWriter()
    • addMember

      public AbstractObjectWriter addMember(ColumnMetadata colSchema)
      Specified by:
      addMember in interface UnionShim
    • addMember

      public AbstractObjectWriter addMember(TypeProtos.MinorType type)
      Specified by:
      addMember in interface UnionShim
    • addMember

      public void addMember(AbstractObjectWriter colWriter)
      Specified by:
      addMember in interface UnionShim
    • setNull

      public void setNull()
      Specified by:
      setNull in interface UnionShim
    • startWrite

      public void startWrite()
      Description copied from interface: WriterEvents
      Start a write (batch) operation. Performs any vector initialization required at the start of a batch (especially for offset vectors.)
      Specified by:
      startWrite in interface WriterEvents
    • startRow

      public void startRow()
      Description copied from interface: WriterEvents
      Start a new row. To be called only when a row is not active. To restart a row, call WriterEvents.restartRow() instead.
      Specified by:
      startRow in interface WriterEvents
    • endArrayValue

      public void endArrayValue()
      Description copied from interface: WriterEvents
      End a value. Similar to WriterEvents.saveRow(), but the save of a value is conditional on saving the row. This version is primarily of use in tuples nested inside arrays: it saves each tuple within the array, advancing to a new position in the array. The update of the array's offset vector based on the cumulative value saves is done when saving the row.
      Specified by:
      endArrayValue in interface WriterEvents
    • restartRow

      public void restartRow()
      Description copied from interface: WriterEvents
      During a writer to a row, rewind the the current index position to restart the row. Done when abandoning the current row, such as when filtering out a row at read time.
      Specified by:
      restartRow in interface WriterEvents
    • saveRow

      public void saveRow()
      Description copied from interface: WriterEvents
      Saves a row. Commits offset vector locations and advances each to the next position. Can be called only when a row is active.
      Specified by:
      saveRow in interface WriterEvents
    • endWrite

      public void endWrite()
      Description copied from interface: WriterEvents
      End a batch: finalize any vector values.
      Specified by:
      endWrite in interface WriterEvents
    • preRollover

      public void preRollover()
      Description copied from interface: WriterEvents
      The vectors backing this vector are about to roll over. Finish the current batch up to, but not including, the current row.
      Specified by:
      preRollover in interface WriterEvents
    • postRollover

      public void postRollover()
      Description copied from interface: WriterEvents
      The vectors backing this writer rolled over. This means that data for the current row has been rolled over into a new vector. Offsets and indexes should be shifted based on the understanding that data for the current row now resides at the start of a new vector instead of its previous location elsewhere in an old vector.
      Specified by:
      postRollover in interface WriterEvents
    • lastWriteIndex

      public int lastWriteIndex()
      Description copied from interface: WriterPosition
      Return the last write position in the vector. This may be the same as the writer index position (if the vector was written at that point), or an earlier point. In either case, this value points to the last valid value in the vector.
      Specified by:
      lastWriteIndex in interface UnionShim
      Specified by:
      lastWriteIndex in interface WriterPosition
      Returns:
      index of the last valid value in the vector
    • rowStartIndex

      public int rowStartIndex()
      Description copied from interface: WriterPosition
      Position within the vector of the first value for the current row. Note that this is always the first value for the row, even for a writer deeply nested within a hierarchy of arrays. (The first position for the current array is not exposed in this API.)
      Specified by:
      rowStartIndex in interface UnionShim
      Specified by:
      rowStartIndex in interface WriterPosition
      Returns:
      the vector offset of the first value for the current row
    • writeIndex

      public int writeIndex()
      Description copied from interface: WriterPosition
      Current write index for the writer. This is the global array location for arrays, same as the row index for top-level columns.
      Specified by:
      writeIndex in interface WriterPosition
      Returns:
      current write index
    • dump

      public void dump(HierarchicalFormatter format)
      Specified by:
      dump in interface WriterEvents
    • isProjected

      public boolean isProjected()
      Specified by:
      isProjected in interface UnionShim