Class BunchedMapIterator<K,V>

java.lang.Object
com.apple.foundationdb.map.BunchedMapIterator<K,V>
Type Parameters:
K - type of keys in the map
V - 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 Details

    • onHasNext

      public CompletableFuture<Boolean> onHasNext()
      Specified by:
      onHasNext in interface AsyncIterator<K>
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface AsyncIterator<K>
      Specified by:
      hasNext in interface Iterator<K>
    • peek

      @Nonnull public Map.Entry<K,V> 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 to next().
      Specified by:
      peek in interface AsyncPeekIterator<K>
      Returns:
      the next item that will be returned by next()
    • next

      @Nonnull public Map.Entry<K,V> next()
      Specified by:
      next in interface AsyncIterator<K>
      Specified by:
      next in interface Iterator<K>
    • getContinuation

      @Nullable public byte[] getContinuation()
      Returns a continuation that can be passed to future calls of BunchedMap.scan(). If the iterator has not yet returned anything or if the iterator is exhausted, then this will return null. 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 corresponding BunchedMap 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 return ReadTransaction.ROW_LIMIT_UNLIMITED.
      Returns:
      the limit of this iterator
    • cancel

      public void cancel()
      Specified by:
      cancel in interface AsyncIterator<K>