Class BlockIterator

java.lang.Object
org.iq80.leveldb.table.BlockIterator
All Implemented Interfaces:
com.google.common.collect.PeekingIterator<Map.Entry<Slice,Slice>>, Iterator<Map.Entry<Slice,Slice>>, SeekingIterator<Slice,Slice>

public class BlockIterator extends Object implements SeekingIterator<Slice,Slice>
  • Field Details

    • data

      private final SliceInput data
    • restartPositions

      private final Slice restartPositions
    • restartCount

      private final int restartCount
    • comparator

      private final Comparator<Slice> comparator
    • nextEntry

      private BlockEntry nextEntry
  • Constructor Details

  • Method Details

    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<Map.Entry<Slice,Slice>>
    • peek

      public BlockEntry peek()
      Specified by:
      peek in interface com.google.common.collect.PeekingIterator<Map.Entry<Slice,Slice>>
    • next

      public BlockEntry next()
      Specified by:
      next in interface Iterator<Map.Entry<Slice,Slice>>
      Specified by:
      next in interface com.google.common.collect.PeekingIterator<Map.Entry<Slice,Slice>>
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<Map.Entry<Slice,Slice>>
      Specified by:
      remove in interface com.google.common.collect.PeekingIterator<Map.Entry<Slice,Slice>>
    • seekToFirst

      public void seekToFirst()
      Repositions the iterator so the beginning of this block.
      Specified by:
      seekToFirst in interface SeekingIterator<Slice,Slice>
    • seek

      public void seek(Slice targetKey)
      Repositions the iterator so the key of the next BlockElement returned greater than or equal to the specified targetKey.
      Specified by:
      seek in interface SeekingIterator<Slice,Slice>
    • seekToRestartPosition

      private void seekToRestartPosition(int restartPosition)
      Seeks to and reads the entry at the specified restart position.

      After this method, nextEntry will contain the next entry to return, and the previousEntry will be null.

    • readEntry

      private static BlockEntry readEntry(SliceInput data, BlockEntry previousEntry)
      Reads the entry at the current data readIndex. After this method, data readIndex is positioned at the beginning of the next entry or at the end of data if there was not a next entry.
      Returns:
      true if an entry was read