Package com.apple.foundationdb.map
Class BunchedMapIterator<K,V>
java.lang.Object
com.apple.foundationdb.map.BunchedMapIterator<K,V>
- Type Parameters:
K
- type of keys in the mapV
- type of values in the map
- All Implemented Interfaces:
AsyncIterator<Map.Entry<K,
,V>> AsyncPeekIterator<Map.Entry<K,
,V>> Iterator<Map.Entry<K,
V>>
@API(EXPERIMENTAL)
public class BunchedMapIterator<K,V>
extends Object
implements AsyncPeekIterator<Map.Entry<K,V>>
An iterator implementation that will iterate over the keys of a
BunchedMap
.
This handles "unbunching" the keys in the database so that the user can ignore
the underlying complexities of the on-disk format. The iterator may return keys
in either ascending or descending order depending on whether it is initialized to
be a reverse or non-reverse scan. This class is not thread safe.-
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
byte[]
Returns a continuation that can be passed to future calls ofBunchedMap.scan()
.int
getLimit()
Get the limit from the iterator.boolean
hasNext()
boolean
Returns whether this iterator returns keys in reverse order.next()
peek()
Get the next item of the scan without advancing it.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Method Details
-
onHasNext
- Specified by:
onHasNext
in interfaceAsyncIterator<K>
-
hasNext
public boolean hasNext() -
peek
Description copied from interface:AsyncPeekIterator
Get the next item of the scan without advancing it. This item can be called multiple times, and it should return the same value each time as long as there are no intervening calls tonext()
.- Specified by:
peek
in interfaceAsyncPeekIterator<K>
- Returns:
- the next item that will be returned by
next()
-
next
-
getContinuation
@Nullable public byte[] getContinuation()Returns a continuation that can be passed to future calls ofBunchedMap.scan()
. If the iterator has not yet returned anything or if the iterator is exhausted, then this will returnnull
. An iterator will be marked as exhausted only if there are no more elements in the map.- Returns:
- a continuation that can be used to resume iteration later
-
isReverse
public boolean isReverse()Returns whether this iterator returns keys in reverse order. Forward order is defined to be ascending order (by the key according to the key comparator used in the correspondingBunchedMap
that generated this iterator). Reverse order is thus equivalent to descending order.- Returns:
- whether this iterator returns values in reverse order
-
getLimit
public int getLimit()Get the limit from the iterator. This is the maximum number of entries that the iterator should return. If this iterator has no limit, it will returnReadTransaction.ROW_LIMIT_UNLIMITED
.- Returns:
- the limit of this iterator
-
cancel
public void cancel()- Specified by:
cancel
in interfaceAsyncIterator<K>
-