Class 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 Detail

      • 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()
      • 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