Package org.apache.druid.segment
Interface RowIterator
- All Superinterfaces:
AutoCloseable,Closeable,TimeAndDimsIterator
- All Known Subinterfaces:
TransformableRowIterator
- All Known Implementing Classes:
ForwardingRowIterator
Extension of
TimeAndDimsIterator, specialized for RowPointer instead of TimeAndDimsPointer.
Also, RowIterator encapsulates tracking of data point changes between TimeAndDimsIterator.moveToNext() calls via mark()
and hasTimeAndDimsChangedSinceMark() methods. This functionality is used in RowCombiningTimeAndDimsIterator, and also internally in MergingRowIterator to reduce the number of
comparisons that this class makes. This functionality is added directly to RowIterator interface rather than
left to be implemented externally to this interface, because it's inefficient to do the latter with "generic"
RowIterator, because of TimeAndDimsPointer allocation-free design, that reuses objects. On the other hand,
some implementations of RowIterator allow to optimize mark() and hasTimeAndDimsChangedSinceMark().-
Method Summary
Modifier and TypeMethodDescriptionReturns a pointer to the current row.booleanCompares the "memoized" data point from the lastmark()call with the data point, to whichgetPointer()currently points.voidmark()"Memoizes" the data point, to whichgetPointer()currently points.Methods inherited from interface org.apache.druid.segment.TimeAndDimsIterator
close, moveToNext
-
Method Details
-
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()returnedtrueone 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:
getPointerin interfaceTimeAndDimsIterator
-