Package io.deephaven.engine.rowset
Interface RowSequence.Iterator
- All Superinterfaces:
AutoCloseable
,SafeCloseable
- Enclosing interface:
- RowSequence
Iterator for consuming an
RowSequence
by ordered subsets.-
Method Summary
Modifier and TypeMethodDescriptionboolean
advance
(long nextKey) Advance this iterator's position tonextKey
, or to the first present row key greater thannextKey
ifnextKey
is not found.default long
advanceAndGetPositionDistance
(long nextKey) Advance this iterator's position as inadvance(long)
, returning the number of row keys thus consumed.default void
close()
Free any resources associated with this iterator.getNextRowSequenceThrough
(long maxKeyInclusive) Get aRowSequence
from the row key at the position of this iterator up to the maximum row key (inclusive).getNextRowSequenceWithLength
(long numberOfKeys) Get aRowSequence
from the row key at the position of this iterator up to the desired number of row keys.long
Taking the difference between values returned by this method at different positions in the iterator gives you the cardinality of the set of row keys between them, exclusive.boolean
hasMore()
Poll whether there are more row keys available from thisRowSequence.Iterator
.long
Peek at the next row key that would be returned bygetNextRowSequenceThrough(long)
orgetNextRowSequenceWithLength(long)
.
-
Method Details
-
hasMore
boolean hasMore()Poll whether there are more row keys available from thisRowSequence.Iterator
.- Returns:
- True if there are more row keys available, else false
-
peekNextKey
long peekNextKey()Peek at the next row key that would be returned bygetNextRowSequenceThrough(long)
orgetNextRowSequenceWithLength(long)
. Does not advance the position.- Returns:
- The next row key that would be returned, or
RowSequence.NULL_ROW_KEY
if this iterator is exhausted
-
getNextRowSequenceThrough
Get aRowSequence
from the row key at the position of this iterator up to the maximum row key (inclusive). Advances the position of this iterator by the size of the result. If the maximum row key provided is smaller than the next row key (as would be returned bypeekNextKey()
), the empty RowSequence is returned. The returned RowSequence object is only borrowed by the caller from theRowSequence.Iterator
, who owns it. It is guaranteed to be valid and not change only until a later call to anothergetNext*
method. As the returned reference is owned by theRowSequence.Iterator
, the caller should not callclose()
on it.- Parameters:
maxKeyInclusive
- The maximum row key to include.- Returns:
- An
RowSequence
from the row key at the initial position up to the maximum row key (inclusive).
-
getNextRowSequenceWithLength
Get aRowSequence
from the row key at the position of this iterator up to the desired number of row keys. Advances the position of this iterator by the size of the result. The returned RowSequence object is only borrowed by the caller from theRowSequence.Iterator
, who owns it. It is guaranteed to be valid and not change only until the next call to anothergetNext*
method. As the returned reference is owned by theRowSequence.Iterator
, the caller should not callclose()
on it.- Parameters:
numberOfKeys
- The desired number of row keys- Returns:
- An
RowSequence
from the row key at the initial position up to the desired number of row keys
-
advance
boolean advance(long nextKey) Advance this iterator's position to
nextKey
, or to the first present row key greater thannextKey
ifnextKey
is not found. IfnextKey
is less than or equal to the row key at this iterator's current position, this method is a no-op.Subsequent calls to
peekNextKey()
,getNextRowSequenceThrough(long)
, orgetNextRowSequenceWithLength(long)
will begin with the row key advanced to.- Parameters:
nextKey
- The row key to advance to- Returns:
- true If there are any row keys remaining to be iterated after the advance, false if this
RowSequence.Iterator
is exhausted
-
advanceAndGetPositionDistance
default long advanceAndGetPositionDistance(long nextKey) Advance this iterator's position as inadvance(long)
, returning the number of row keys thus consumed.- Parameters:
nextKey
- The row key to advance to- Returns:
- The number of row keys consumed from the iterator
-
close
default void close()Free any resources associated with this iterator.
Callers of
RowSequence.getRowSequenceIterator()
are responsible for ensuring thatclose()
is called when they are done with resultingRowSequence.Iterator
.Using any
RowSequence.Iterator
methods afterclose()
is an error and may produce exceptions or undefined results.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceSafeCloseable
-
getRelativePosition
long getRelativePosition()Taking the difference between values returned by this method at different positions in the iterator gives you the cardinality of the set of row keys between them, exclusive. Note a single value itself is not meaningful; like measuring elapsed time, it only makes sense to take the difference from absolute points.- Returns:
- A relative position offset from some arbitrary initial point in the underlying row sequence.
-