Class MultiLevelSkipListReader

java.lang.Object
org.apache.lucene.codecs.MultiLevelSkipListReader
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
Lucene50SkipReader, Lucene84SkipReader

public abstract class MultiLevelSkipListReader extends Object implements Closeable
This abstract class reads skip lists with multiple levels. See MultiLevelSkipListWriter for the information about the encoding of the multi level skip lists. Subclasses must implement the abstract method readSkipData(int, IndexInput) which defines the actual format of the skip data.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static final class 
    used to buffer the top skip levels
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private long[]
    Child pointer of current skip entry per level.
    private int
     
    private boolean
     
    private long
    childPointer of last read skip entry with docId <= target.
    private int
    Doc id of last read skip entry with docId <= target.
    protected int
    the maximum number of skip levels possible for this index
    private int
     
    protected int
    number of levels in this skip list
    private int[]
    Number of docs skipped per level.
    protected int[]
    Doc id of current skip entry per level.
    private int[]
    skipInterval of each level.
    private final int
     
    private long[]
    The start pointer of each skip level.
    private IndexInput[]
    skipStream for each level.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    MultiLevelSkipListReader(IndexInput skipStream, int maxSkipLevels, int skipInterval)
    Creates a MultiLevelSkipListReader, where skipInterval and skipMultiplier are the same.
    protected
    MultiLevelSkipListReader(IndexInput skipStream, int maxSkipLevels, int skipInterval, int skipMultiplier)
    Creates a MultiLevelSkipListReader.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    int
    Returns the id of the doc to which the last call of skipTo(int) has skipped.
    void
    init(long skipPointer, int df)
    Initializes the reader, for reuse on a new term.
    private boolean
    loadNextSkip(int level)
     
    private void
    Loads the skip levels
    protected abstract int
    readSkipData(int level, IndexInput skipStream)
    Subclasses must implement the actual skip data encoding in this method.
    protected void
    seekChild(int level)
    Seeks the skip entry on the given level
    protected void
    setLastSkipData(int level)
    Copies the values of the last read skip entry on this level
    int
    skipTo(int target)
    Skips entries to the first beyond the current whose document number is greater than or equal to target.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • maxNumberOfSkipLevels

      protected int maxNumberOfSkipLevels
      the maximum number of skip levels possible for this index
    • numberOfSkipLevels

      protected int numberOfSkipLevels
      number of levels in this skip list
    • numberOfLevelsToBuffer

      private int numberOfLevelsToBuffer
    • docCount

      private int docCount
    • skipStream

      private IndexInput[] skipStream
      skipStream for each level.
    • skipPointer

      private long[] skipPointer
      The start pointer of each skip level.
    • skipInterval

      private int[] skipInterval
      skipInterval of each level.
    • numSkipped

      private int[] numSkipped
      Number of docs skipped per level. It's possible for some values to overflow a signed int, but this has been accounted for.
    • skipDoc

      protected int[] skipDoc
      Doc id of current skip entry per level.
    • lastDoc

      private int lastDoc
      Doc id of last read skip entry with docId <= target.
    • childPointer

      private long[] childPointer
      Child pointer of current skip entry per level.
    • lastChildPointer

      private long lastChildPointer
      childPointer of last read skip entry with docId <= target.
    • inputIsBuffered

      private boolean inputIsBuffered
    • skipMultiplier

      private final int skipMultiplier
  • Constructor Details

    • MultiLevelSkipListReader

      protected MultiLevelSkipListReader(IndexInput skipStream, int maxSkipLevels, int skipInterval, int skipMultiplier)
      Creates a MultiLevelSkipListReader.
    • MultiLevelSkipListReader

      protected MultiLevelSkipListReader(IndexInput skipStream, int maxSkipLevels, int skipInterval)
      Creates a MultiLevelSkipListReader, where skipInterval and skipMultiplier are the same.
  • Method Details

    • getDoc

      public int getDoc()
      Returns the id of the doc to which the last call of skipTo(int) has skipped.
    • skipTo

      public int skipTo(int target) throws IOException
      Skips entries to the first beyond the current whose document number is greater than or equal to target. Returns the current doc count.
      Throws:
      IOException
    • loadNextSkip

      private boolean loadNextSkip(int level) throws IOException
      Throws:
      IOException
    • seekChild

      protected void seekChild(int level) throws IOException
      Seeks the skip entry on the given level
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • init

      public void init(long skipPointer, int df) throws IOException
      Initializes the reader, for reuse on a new term.
      Throws:
      IOException
    • loadSkipLevels

      private void loadSkipLevels() throws IOException
      Loads the skip levels
      Throws:
      IOException
    • readSkipData

      protected abstract int readSkipData(int level, IndexInput skipStream) throws IOException
      Subclasses must implement the actual skip data encoding in this method.
      Parameters:
      level - the level skip data shall be read from
      skipStream - the skip stream to read from
      Throws:
      IOException
    • setLastSkipData

      protected void setLastSkipData(int level)
      Copies the values of the last read skip entry on this level