Class ArrayReaderImpl.ElementReaderIndex

java.lang.Object
org.apache.drill.exec.vector.accessor.reader.ArrayReaderImpl.ElementReaderIndex
All Implemented Interfaces:
ColumnReaderIndex
Enclosing class:
ArrayReaderImpl

public static class ArrayReaderImpl.ElementReaderIndex extends Object implements ColumnReaderIndex
Index into the vector of elements for a repeated vector. Indexes elements relative to the array. That is, if an array has five elements, the index here tracks elements 0..4. The actual vector index is given as the start offset plus the offset into the array.

Indexes allow random or sequential access. Random access is more typical for scalar arrays, while sequential access can be more convenient for tuple arrays.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final ColumnReaderIndex
     
    protected int
     
    protected int
     
    protected int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Reports if the index has another item.
    int
    When used with a hyper-vector (SV4) based batch, returns the index of the current batch within the hyper-batch.
    int
    Ordinal index within the batch or array.
    boolean
    Advances the index to the next position.
    int
    Given a 0-based index relative to the current array, return an absolute offset vector location for the array value.
    void
    reset(int startOffset, int length)
    Reposition this array index for a new array given the array start offset and length.
    void
     
    void
    set(int index)
    Set the current iterator location to the given index offset.
    int
    Return the number of items that this index indexes: top-level record count for the root index; total element count for nested arrays.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • base

      protected final ColumnReaderIndex base
    • startOffset

      protected int startOffset
    • length

      protected int length
    • position

      protected int position
  • Constructor Details

  • Method Details

    • hyperVectorIndex

      public int hyperVectorIndex()
      Description copied from interface: ColumnReaderIndex
      When used with a hyper-vector (SV4) based batch, returns the index of the current batch within the hyper-batch. If this is a single batch, or a nested index, then always returns 0.
      Specified by:
      hyperVectorIndex in interface ColumnReaderIndex
      Returns:
      batch index of the current row within the hyper-batch
    • reset

      public void reset(int startOffset, int length)
      Reposition this array index for a new array given the array start offset and length.
      Parameters:
      startOffset - first location within the array's offset vector
      length - number of offset vector locations associated with this array
    • rewind

      public void rewind()
    • size

      public int size()
      Description copied from interface: ColumnReaderIndex
      Return the number of items that this index indexes: top-level record count for the root index; total element count for nested arrays.
      Specified by:
      size in interface ColumnReaderIndex
      Returns:
      element count at this index level
    • offset

      public int offset()
      Given a 0-based index relative to the current array, return an absolute offset vector location for the array value.
      Specified by:
      offset in interface ColumnReaderIndex
      Returns:
      absolute offset vector location for the array value
    • next

      public boolean next()
      Description copied from interface: ColumnReaderIndex
      Advances the index to the next position. Used:
      • At the top level for normal readers or
      • <liAt a nested level for implicit join readers, and
      • An each array level to iterate over arrays.
      Specified by:
      next in interface ColumnReaderIndex
      Returns:
      true if another value is available, false if EOF
    • hasNext

      public boolean hasNext()
      Description copied from interface: ColumnReaderIndex
      Reports if the index has another item.
      Specified by:
      hasNext in interface ColumnReaderIndex
      Returns:
      if more rows remain. That is, if a call to ColumnReaderIndex.next() would return true.
    • set

      public void set(int index)
      Set the current iterator location to the given index offset.
      Parameters:
      index - 0-based index into the current array
    • logicalIndex

      public int logicalIndex()
      Description copied from interface: ColumnReaderIndex
      Ordinal index within the batch or array. Increments from -1. (The position before the first item.) Identifies the logical row number of top-level records, or the array element for arrays. Actual physical index may be different if an indirection layer is in use.
      Specified by:
      logicalIndex in interface ColumnReaderIndex
      Returns:
      logical read index