Class ArrayReaderImpl.ElementReaderIndex
java.lang.Object
org.apache.drill.exec.vector.accessor.reader.ArrayReaderImpl.ElementReaderIndex
- All Implemented Interfaces:
ColumnReaderIndex
- Enclosing class:
ArrayReaderImpl
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
FieldsModifier and TypeFieldDescriptionprotected final ColumnReaderIndexprotected intprotected intprotected int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanhasNext()Reports if the index has another item.intWhen used with a hyper-vector (SV4) based batch, returns the index of the current batch within the hyper-batch.intOrdinal index within the batch or array.booleannext()Advances the index to the next position.intoffset()Given a 0-based index relative to the current array, return an absolute offset vector location for the array value.voidreset(int startOffset, int length) Reposition this array index for a new array given the array start offset and length.voidrewind()voidset(int index) Set the current iterator location to the given index offset.intsize()Return the number of items that this index indexes: top-level record count for the root index; total element count for nested arrays.
-
Field Details
-
base
-
startOffset
protected int startOffset -
length
protected int length -
position
protected int position
-
-
Constructor Details
-
ElementReaderIndex
-
-
Method Details
-
hyperVectorIndex
public int hyperVectorIndex()Description copied from interface:ColumnReaderIndexWhen 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:
hyperVectorIndexin interfaceColumnReaderIndex- 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 vectorlength- number of offset vector locations associated with this array
-
rewind
public void rewind() -
size
public int size()Description copied from interface:ColumnReaderIndexReturn the number of items that this index indexes: top-level record count for the root index; total element count for nested arrays.- Specified by:
sizein interfaceColumnReaderIndex- 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:
offsetin interfaceColumnReaderIndex- Returns:
- absolute offset vector location for the array value
-
next
public boolean next()Description copied from interface:ColumnReaderIndexAdvances the index to the next position. Used:- At the top level for normal readers or invalid input: '<'liAt a nested level for implicit join readers, and
- An each array level to iterate over arrays.
- Specified by:
nextin interfaceColumnReaderIndex- Returns:
- true if another value is available, false if EOF
-
hasNext
public boolean hasNext()Description copied from interface:ColumnReaderIndexReports if the index has another item.- Specified by:
hasNextin interfaceColumnReaderIndex- 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:ColumnReaderIndexOrdinal 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:
logicalIndexin interfaceColumnReaderIndex- Returns:
- logical read index
-