Lucene99SkipReader (Lucene 10.5.0 backward-codecs API)
Description: declaration: package: org.apache.lucene.backward_codecs.lucene99, class: Lucene99SkipReader

Package org.apache.lucene.backward_codecs.lucene99

# Class Lucene99SkipReader

java.lang.Object
org.apache.lucene.codecs.MultiLevelSkipListReader
org.apache.lucene.backward_codecs.lucene99.Lucene99SkipReader

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

public class Lucene99SkipReader extends MultiLevelSkipListReader
Implements the skip list reader for block postings format that stores positions and payloads.

Although this skipper uses MultiLevelSkipListReader as an interface, its definition of skip position will be a little different.

For example, when skipInterval = blockSize = 3, df = 2*skipInterval = 6,

     0 1 2 3 4 5
     d d d d d d    (posting list)
         ^     ^    (skip point in MultiLeveSkipWriter)
           ^        (skip point in Lucene99SkipWriter)

In this case, MultiLevelSkipListReader will use the last document as a skip point, while Lucene99SkipReader should assume no skip point will comes.

If we use the interface directly in Lucene99SkipReader, it may silly try to read another skip data after the only skip point is loaded.

To illustrate this, we can call skipTo(d[5]), since skip point d[3] has smaller docId, and numSkipped+blockSize== df, the MultiLevelSkipListReader will assume the skip list isn't exhausted yet, and try to load a non-existed skip point

Therefore, we'll trim df before passing it to the interface. see trim(int)

- ## Field Summary

  ### Fields inherited from class org.apache.lucene.codecs.MultiLevelSkipListReader

  `maxNumberOfSkipLevels, numberOfSkipLevels, skipDoc`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Lucene99SkipReader(IndexInput skipStream, int maxSkipLevels, boolean hasPos, boolean hasOffsets, boolean hasPayloads)`
  Sole constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `long`
  `getDocPointer()`
  Returns the doc pointer of the doc to which the last call of `MultiLevelSkipListReader.skipTo(int)` has skipped.
  `int`
  `getNextSkipDoc()`
  Return the next skip doc, no skipping can be performed until this doc.
  `int`
  `getPayloadByteUpto()`
  Return the number of bytes in the pay block that belongs to docs from the previous block.
  `long`
  `getPayPointer()`
  Returns the pointer in the pay file.
  `int`
  `getPosBufferUpto()`
  Return the start offset in the position block.
  `long`
  `getPosPointer()`
  Returns the pointer in the pos file.
  `void`
  `init(long skipPointer, long docBasePointer, long posBasePointer, long payBasePointer, int df)`
  Initialize state.
  `protected void`
  `readImpacts(int level, IndexInput skipStream)`
  Read impacts.
  `protected int`
  `readSkipData(int level, IndexInput skipStream)`
  `protected void`
  `seekChild(int level)`
  `protected void`
  `setLastSkipData(int level)`
  `protected int`
  `trim(int df)`
  Trim original docFreq to tell skipReader read proper number of skip points.

  ### Methods inherited from class org.apache.lucene.codecs.MultiLevelSkipListReader

  `close, getDoc, init, readChildPointer, readLevelLength, skipTo`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Lucene99SkipReader

    public Lucene99SkipReader(IndexInput skipStream, int maxSkipLevels, boolean hasPos, boolean hasOffsets, boolean hasPayloads)
    Sole constructor.

- ## Method Details

  - ### trim

    protected int trim(int df)
    Trim original docFreq to tell skipReader read proper number of skip points.

    Since our definition in Lucene99Skip* is a little different from MultiLevelSkip* This trimmed docFreq will prevent skipReader from: 1. silly reading a non-existed skip point after the last block boundary 2. moving into the vInt block

  - ### init

    public void init(long skipPointer, long docBasePointer, long posBasePointer, long payBasePointer, int df) throws IOException
    Initialize state.
    Throws:
      `IOException`

  - ### getDocPointer

    public long getDocPointer()
    Returns the doc pointer of the doc to which the last call of `MultiLevelSkipListReader.skipTo(int)` has skipped.

  - ### getPosPointer

    public long getPosPointer()
    Returns the pointer in the pos file.

  - ### getPosBufferUpto

    public int getPosBufferUpto()
    Return the start offset in the position block.

  - ### getPayPointer

    public long getPayPointer()
    Returns the pointer in the pay file.

  - ### getPayloadByteUpto

    public int getPayloadByteUpto()
    Return the number of bytes in the pay block that belongs to docs from the previous block.

  - ### getNextSkipDoc

    public int getNextSkipDoc()
    Return the next skip doc, no skipping can be performed until this doc.

  - ### seekChild

    protected void seekChild(int level) throws IOException
    Overrides:
      `seekChild` in class `MultiLevelSkipListReader`
    Throws:
      `IOException`

  - ### setLastSkipData

    protected void setLastSkipData(int level)
    Overrides:
      `setLastSkipData` in class `MultiLevelSkipListReader`

  - ### readSkipData

    protected int readSkipData(int level, IndexInput skipStream) throws IOException
    Specified by:
      `readSkipData` in class `MultiLevelSkipListReader`
    Throws:
      `IOException`

  - ### readImpacts

    protected void readImpacts(int level, IndexInput skipStream) throws IOException
    Read impacts. The default implementation skips them.
    Throws:
      `IOException`