Class RowSetUtils.CombinedRangeIterator
- All Implemented Interfaces:
RowSet.RangeIterator
,SafeCloseable
,AutoCloseable
- Enclosing class:
- RowSetUtils
-
Nested Class Summary
-
Field Summary
Fields inherited from interface io.deephaven.engine.rowset.RowSet.RangeIterator
empty
-
Constructor Summary
ConstructorDescriptionProvide the means to iterate over the combined ranges of two provided iterators. -
Method Summary
Modifier and TypeMethodDescriptionboolean
advance
(long notUsed) Advance the current iterator position untilcurrentRangeStart()
andcurrentRangeEnd()
are both greater than or equal tov
.void
close()
long
long
boolean
hasNext()
long
next()
void
postpone
(long notUsed) Given an iterator state with a current range of [start, end], and a value v such that start <= v <= end, postpone(v) makes the iterator current range [v, end].
-
Constructor Details
-
CombinedRangeIterator
Provide the means to iterate over the combined ranges of two provided iterators. The resulting ranges in this object are tagged with first, second, or both, to indicate if the current range was from the first iterator, second iterator, or both respectively.- Parameters:
it1
- First iteratorit2
- Second iterator
-
-
Method Details
-
hasNext
public boolean hasNext()- Specified by:
hasNext
in interfaceRowSet.RangeIterator
-
next
public long next()- Specified by:
next
in interfaceRowSet.RangeIterator
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceRowSet.RangeIterator
- Specified by:
close
in interfaceSafeCloseable
-
currentRangeStart
public long currentRangeStart()- Specified by:
currentRangeStart
in interfaceRowSet.RangeIterator
-
currentRangeEnd
public long currentRangeEnd()- Specified by:
currentRangeEnd
in interfaceRowSet.RangeIterator
-
currentRangeMembership
-
advance
public boolean advance(long notUsed) Description copied from interface:RowSet.RangeIterator
Advance the current iterator position until
currentRangeStart()
andcurrentRangeEnd()
are both greater than or equal tov
. This may or may not move the iterator to the next range: ifv
is inside the current range (but to the right ofcurrentRangeStart()
, this will simply advancecurrentRangeStart()
. Returns true if the operation was successful. Otherwise, returns false. In this case the iteration is over and the iterator is exhausted (calls tohasNext()
will return false, any other operation is undefined).Although calls to
advance()
may be interleaved with calls tohasNext()
/next()
if necessary, this is not the common case, as they are separate protocols having little to do with each other. In particular, when iterating withadvance()
, you do not use next() to bring the next range into view, even at the start of the iteration. Many common usages only involve calls to advance().Example:
{ @code RangeIterator it = rowSet.getRangeIterator(); if (!it.advance(100)) { return; // iteration done... no ranges at 100 or greater } assert (it.currentRangeStart() >= 100 && it.currentRangeEnd() >= 100); // do something with range if (!it.advance(500)) { return; // iteration done... no ranges at 500 or greater } assert (it.currentRangeStart() >= 500 && it.currentRangeEnd() >= 500); // do something with range }
- Specified by:
advance
in interfaceRowSet.RangeIterator
- Parameters:
notUsed
- a value to search forward from the current iterator position- Returns:
- false if iteration is exhausted, otherwise true.
-
postpone
public void postpone(long notUsed) Description copied from interface:RowSet.RangeIterator
Given an iterator state with a current range of [start, end], and a value v such that start <= v <= end, postpone(v) makes the iterator current range [v, end]. This call is useful to code that may need to process parts of ranges from different call sites from the site iterator. The results of this call are undefined if the value provided is not contained in the current range.- Specified by:
postpone
in interfaceRowSet.RangeIterator
- Parameters:
notUsed
- A value contained in the current iterator range
-