Interface ColumnReaderIndex
- All Known Implementing Classes:
ArrayReaderImpl.ElementReaderIndex
,DirectRowIndex
,HyperRowIndex
,IndirectRowIndex
,ReaderIndex
Further, when used with a logical join, the top-level iteration may be over an array, with an implicit join out to enclosing nesting levels.
Because of this, the same index interface must work at all nesting levels: at the top, and within arrays. This interface supports a usage model as follows:
ColumnReaderIndex index = ...
while (index.hasNext()) {
index.next();
int hyperIndex = index.hyperVectorIndex();
int vectorOffset = index.offset();
}
When convenient, the following abbreviated form is also supported:
ColumnReaderIndex index = ...
while (index.next()) {
int hyperIndex = index.hyperVectorIndex();
int vectorOffset = index.offset();
}
For a top-level index, the check of hasNext() and call to next() is done by the row set reader. For arrays, the call to hasNext() is done by the array reader. The call to next() is done by the scalar reader (for scalar arrays) or the array reader (for other arrays.)
The hyper-vector index has meaning only for top-level vectors,
and is ignored by nested vectors. (Nested vectors work by navigating
down from a top-level vector.) But, as noted above, any given
reader does not know if it is at the top or nested level, instead
it is the VectorAccessor
abstraction that works out the nesting levels.
-
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()
Vector offset to read.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.
-
Method Details
-
logicalIndex
int logicalIndex()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.- Returns:
- logical read index
-
hyperVectorIndex
int hyperVectorIndex()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.- Returns:
- batch index of the current row within the hyper-batch
-
offset
int offset()Vector offset to read. For top-level vectors, the offset may be through an indirection (SV2 or SV4). For arrays, the offset is the absolute position, with the vector of the current array element.- Returns:
- vector read index
-
next
boolean next()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.
- Returns:
- true if another value is available, false if EOF
-
hasNext
boolean hasNext()Reports if the index has another item.- Returns:
if more rows remain. That is, if a call to next()
would return true.
-
size
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.- Returns:
- element count at this index level
-