Package org.apache.lucene.codecs
Class MultiLevelSkipListReader
- java.lang.Object
-
- org.apache.lucene.codecs.MultiLevelSkipListReader
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
- Direct Known Subclasses:
Lucene50SkipReader,Lucene84SkipReader,Lucene90SkipReader,SimpleTextSkipReader
public abstract class MultiLevelSkipListReader extends java.lang.Object implements java.io.CloseableThis abstract class reads skip lists with multiple levels.See
MultiLevelSkipListWriterfor 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.
-
-
Field Summary
Fields Modifier and Type Field Description private long[]childPointerChild pointer of current skip entry per level.private intdocCountprivate longlastChildPointerchildPointer of last read skip entry with docId <= target.private intlastDocDoc id of last read skip entry with docId <= target.protected intmaxNumberOfSkipLevelsthe maximum number of skip levels possible for this indexprotected intnumberOfSkipLevelsnumber of levels in this skip listprivate int[]numSkippedNumber of docs skipped per level.protected int[]skipDocDoc id of current skip entry per level.private int[]skipIntervalskipInterval of each level.private intskipMultiplierprivate long[]skipPointerThe start pointer of each skip level.private IndexInput[]skipStreamskipStream for each level.
-
Constructor Summary
Constructors Modifier Constructor Description protectedMultiLevelSkipListReader(IndexInput skipStream, int maxSkipLevels, int skipInterval)Creates aMultiLevelSkipListReader, whereskipIntervalandskipMultiplierare the same.protectedMultiLevelSkipListReader(IndexInput skipStream, int maxSkipLevels, int skipInterval, int skipMultiplier)Creates aMultiLevelSkipListReader.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()intgetDoc()Returns the id of the doc to which the last call ofskipTo(int)has skipped.voidinit(long skipPointer, int df)Initializes the reader, for reuse on a new term.private booleanloadNextSkip(int level)private voidloadSkipLevels()Loads the skip levelsprotected longreadChildPointer(IndexInput skipStream)read the child pointer written viaMultiLevelSkipListWriter.writeChildPointer(long, DataOutput).protected longreadLevelLength(IndexInput skipStream)read the length of the current level written viaMultiLevelSkipListWriter.writeLevelLength(long, IndexOutput).protected abstract intreadSkipData(int level, IndexInput skipStream)Subclasses must implement the actual skip data encoding in this method.protected voidseekChild(int level)Seeks the skip entry on the given levelprotected voidsetLastSkipData(int level)Copies the values of the last read skip entry on this levelintskipTo(int target)Skips entries to the first beyond the current whose document number is greater than or equal to target.
-
-
-
Field Detail
-
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
-
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.
-
skipMultiplier
private final int skipMultiplier
-
-
Constructor Detail
-
MultiLevelSkipListReader
protected MultiLevelSkipListReader(IndexInput skipStream, int maxSkipLevels, int skipInterval, int skipMultiplier)
Creates aMultiLevelSkipListReader.
-
MultiLevelSkipListReader
protected MultiLevelSkipListReader(IndexInput skipStream, int maxSkipLevels, int skipInterval)
Creates aMultiLevelSkipListReader, whereskipIntervalandskipMultiplierare the same.
-
-
Method Detail
-
getDoc
public int getDoc()
Returns the id of the doc to which the last call ofskipTo(int)has skipped.
-
skipTo
public int skipTo(int target) throws java.io.IOExceptionSkips entries to the first beyond the current whose document number is greater than or equal to target. Returns the current doc count.- Throws:
java.io.IOException
-
loadNextSkip
private boolean loadNextSkip(int level) throws java.io.IOException- Throws:
java.io.IOException
-
seekChild
protected void seekChild(int level) throws java.io.IOExceptionSeeks the skip entry on the given level- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
init
public void init(long skipPointer, int df) throws java.io.IOExceptionInitializes the reader, for reuse on a new term.- Throws:
java.io.IOException
-
loadSkipLevels
private void loadSkipLevels() throws java.io.IOExceptionLoads the skip levels- Throws:
java.io.IOException
-
readSkipData
protected abstract int readSkipData(int level, IndexInput skipStream) throws java.io.IOExceptionSubclasses must implement the actual skip data encoding in this method.- Parameters:
level- the level skip data shall be read fromskipStream- the skip stream to read from- Throws:
java.io.IOException
-
readLevelLength
protected long readLevelLength(IndexInput skipStream) throws java.io.IOException
read the length of the current level written viaMultiLevelSkipListWriter.writeLevelLength(long, IndexOutput).- Parameters:
skipStream- the IndexInput the length shall be read from- Returns:
- level length
- Throws:
java.io.IOException
-
readChildPointer
protected long readChildPointer(IndexInput skipStream) throws java.io.IOException
read the child pointer written viaMultiLevelSkipListWriter.writeChildPointer(long, DataOutput).- Parameters:
skipStream- the IndexInput the child pointer shall be read from- Returns:
- child pointer
- Throws:
java.io.IOException
-
setLastSkipData
protected void setLastSkipData(int level)
Copies the values of the last read skip entry on this level
-
-