Class BunchedMapMultiIterator<K,V,T>

java.lang.Object
com.apple.foundationdb.map.BunchedMapMultiIterator<K,V,T>
Type Parameters:
K - type of keys in the maps
V - type of values in the maps
T - type of tags associated with each subspace
All Implemented Interfaces:
AsyncIterator<BunchedMapScanEntry<K,V,T>>, AsyncPeekIterator<BunchedMapScanEntry<K,V,T>>, Iterator<BunchedMapScanEntry<K,V,T>>

@API(EXPERIMENTAL) public class BunchedMapMultiIterator<K,V,T> extends Object implements AsyncPeekIterator<BunchedMapScanEntry<K,V,T>>
An iterator that will return BunchedMapScanEntry objects while scanning over multiple BunchedMaps. This is the iterator returned by scanMulti(). This iterator will use the provided SubspaceSplitter to associate each key that it reads with an underlying subspace. It will return keys in either ascending order or descending order based on whether it is a "reverse" iterator (i.e., descending) or not. However, it will sort keys first by subspace (using the unsigned byte order of the underlying prefixes) and then by key, so use cases that need all keys in a strict order will have to re-sort the items after they have all been returned by the iterator.
  • 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 BunchedMapScanEntry<K,V,T> 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 BunchedMapScanEntry<K,V,T> 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.scanMulti(). 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 any of the maps being scanned.
      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 subspace according to the byte prefixes of each one followed by key order within a subspace. Reverse order is thus equivalent to descending order.
      Returns:
      whether this iterator returns values in reverse order
    • getLimit

      public int getLimit()
      Returns the maximum number of entries that this iterator will return. It will return ReadTransaction.ROW_LIMIT_UNLIMITED if this iterator has no limit.
      Returns:
      the limit of this iterator
    • cancel

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