Package org.apache.druid.segment
Interface RowIterator
-
- All Superinterfaces:
AutoCloseable
,Closeable
,TimeAndDimsIterator
- All Known Subinterfaces:
TransformableRowIterator
- All Known Implementing Classes:
ForwardingRowIterator
public interface RowIterator extends TimeAndDimsIterator
Extension ofTimeAndDimsIterator
, specialized forRowPointer
instead ofTimeAndDimsPointer
. Also, RowIterator encapsulates tracking of data point changes betweenTimeAndDimsIterator.moveToNext()
calls viamark()
andhasTimeAndDimsChangedSinceMark()
methods. This functionality is used inRowCombiningTimeAndDimsIterator
, and also internally inMergingRowIterator
to reduce the number of comparisons that this class makes. This functionality is added directly toRowIterator
interface rather than left to be implemented externally to this interface, because it's inefficient to do the latter with "generic" RowIterator, because ofTimeAndDimsPointer
allocation-free design, that reuses objects. On the other hand, some implementations of RowIterator allow to optimizemark()
andhasTimeAndDimsChangedSinceMark()
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description RowPointer
getPointer()
Returns a pointer to the current row.boolean
hasTimeAndDimsChangedSinceMark()
Compares the "memoized" data point from the lastmark()
call with the data point, to whichgetPointer()
currently points.void
mark()
"Memoizes" the data point, to whichgetPointer()
currently points.-
Methods inherited from interface org.apache.druid.segment.TimeAndDimsIterator
close, moveToNext
-
-
-
-
Method Detail
-
mark
void mark()
"Memoizes" the data point, to whichgetPointer()
currently points. If the last call toTimeAndDimsIterator.moveToNext()
returnedfalse
, the behaviour of this method is undefined, e. g. it may throw a runtime exception.
-
hasTimeAndDimsChangedSinceMark
boolean hasTimeAndDimsChangedSinceMark()
Compares the "memoized" data point from the lastmark()
call with the data point, to whichgetPointer()
currently points. Comparison is made in terms ofTimeAndDimsPointer.compareTo(org.apache.druid.segment.TimeAndDimsPointer)
contract. Ifmark()
has never been called, or the last call toTimeAndDimsIterator.moveToNext()
returnedfalse
, the behaviour of this method is undefined: it may arbitrarily return true, or false, or throw a runtime exception.
-
getPointer
RowPointer getPointer()
Returns a pointer to the current row. This method may return the same (in terms of referencial identity), as well as different object on any calls, but the row itself, to which the returned object points, changes after eachTimeAndDimsIterator.moveToNext()
call that returns {@link true}. This method must not be called before ever calling toTimeAndDimsIterator.moveToNext()
. If the very first call toTimeAndDimsIterator.moveToNext()
returnedfalse
, the behaviour of this method is undefined (it may return a "wrong" pointer, null, throw an exception, etc.). IfTimeAndDimsIterator.moveToNext()
returnedtrue
one or more times, and then eventually returnedfalse
, callinggetPointer()
after that should return a pointer pointing to the last valid row, as ifgetPointer()
was called before the last (unsuccessful) call toTimeAndDimsIterator.moveToNext()
. In other words, unsuccessfulTimeAndDimsIterator.moveToNext()
call doesn't "corrupt" the pointer. This property is used inTimeAndDimsIterator.moveToNext()
.- Specified by:
getPointer
in interfaceTimeAndDimsIterator
-
-