Package org.apache.lucene.codecs
Class MultiLevelSkipListReader
java.lang.Object
org.apache.lucene.codecs.MultiLevelSkipListReader
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
Lucene50SkipReader,Lucene84SkipReader
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 ClassesModifier and TypeClassDescriptionprivate static final classused to buffer the top skip levels -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate long[]Child pointer of current skip entry per level.private intprivate booleanprivate longchildPointer of last read skip entry with docId <= target.private intDoc id of last read skip entry with docId <= target.protected intthe maximum number of skip levels possible for this indexprivate intprotected intnumber of levels in this skip listprivate 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 intprivate long[]The start pointer of each skip level.private IndexInput[]skipStream for each level. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMultiLevelSkipListReader(IndexInput skipStream, int maxSkipLevels, int skipInterval) Creates aMultiLevelSkipListReader, whereskipIntervalandskipMultiplierare the same.protectedMultiLevelSkipListReader(IndexInput skipStream, int maxSkipLevels, int skipInterval, int skipMultiplier) Creates aMultiLevelSkipListReader. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()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 voidLoads the skip levelsprotected 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 Details
-
maxNumberOfSkipLevels
protected int maxNumberOfSkipLevelsthe maximum number of skip levels possible for this index -
numberOfSkipLevels
protected int numberOfSkipLevelsnumber of levels in this skip list -
numberOfLevelsToBuffer
private int numberOfLevelsToBuffer -
docCount
private int docCount -
skipStream
skipStream for each level. -
skipPointer
private long[] skipPointerThe start pointer of each skip level. -
skipInterval
private int[] skipIntervalskipInterval of each level. -
numSkipped
private int[] numSkippedNumber 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[] skipDocDoc id of current skip entry per level. -
lastDoc
private int lastDocDoc id of last read skip entry with docId <= target. -
childPointer
private long[] childPointerChild pointer of current skip entry per level. -
lastChildPointer
private long lastChildPointerchildPointer 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 aMultiLevelSkipListReader. -
MultiLevelSkipListReader
Creates aMultiLevelSkipListReader, whereskipIntervalandskipMultiplierare the same.
-
-
Method Details
-
getDoc
public int getDoc()Returns the id of the doc to which the last call ofskipTo(int)has skipped. -
skipTo
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
- Throws:
IOException
-
seekChild
Seeks the skip entry on the given level- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
init
Initializes the reader, for reuse on a new term.- Throws:
IOException
-
loadSkipLevels
Loads the skip levels- Throws:
IOException
-
readSkipData
Subclasses 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:
IOException
-
setLastSkipData
protected void setLastSkipData(int level) Copies the values of the last read skip entry on this level
-