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
Modifier and TypeFieldDescriptionprotected final ColumnReaderIndex
protected int
protected int
protected int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
hasNext()
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
next()
Advances the index to the next position.int
offset()
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
rewind()
void
set
(int index) Set the current iterator location to the given index offset.int
size()
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: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 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: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 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:
offset
in interfaceColumnReaderIndex
- 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 interfaceColumnReaderIndex
- 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 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: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 interfaceColumnReaderIndex
- Returns:
- logical read index
-