public class BlockReader
extends BaseTermsEnum
Reads fully the block in blockReadBuffer. Then scans the block
terms in memory. The details region is lazily decoded with termStatesReadBuffer
which shares the same byte array with blockReadBuffer.
See BlockWriter and BlockLine for the block format.
| Modifier and Type | Field and Description |
|---|---|
protected BlockDecoder |
blockDecoder |
protected int |
blockFirstLineStart
Offset of the start of the first line of the current block (just after the header), relative to the block start.
|
protected BlockHeader |
blockHeader
Current block header.
|
protected IndexInput |
blockInput
IndexInput on the block file. |
protected BlockLine |
blockLine
Current block line.
|
protected BlockLine.Serializer |
blockLineReader |
protected ByteArrayDataInput |
blockReadBuffer
In-memory read buffer for the current block.
|
protected long |
blockStartFP
Current block start file pointer, absolute in the
block file. |
protected IndexDictionary.Browser |
dictionaryBrowser
Holds the
IndexDictionary.Browser once loaded. |
protected java.util.function.Supplier<IndexDictionary.Browser> |
dictionaryBrowserSupplier
IndexDictionary.Browser supplier for lazy loading. |
protected FieldMetadata |
fieldMetadata |
protected BytesRefBuilder |
forcedTerm
Set when
seekExact(BytesRef, TermState) is called. |
protected int |
lineIndexInBlock
Current line index in the block.
|
protected PostingsReaderBase |
postingsReader |
protected BytesRef |
scratchBlockBytes |
protected BlockTermState |
scratchTermState |
protected BlockTermState |
termState
Current block line details.
|
protected boolean |
termStateForced
Whether the current
TermState has been forced with a call to
seekExact(BytesRef, TermState). |
protected DeltaBaseTermStateSerializer |
termStateSerializer |
protected ByteArrayDataInput |
termStatesReadBuffer
In-memory read buffer for the details region of the current block.
|
| Modifier | Constructor and Description |
|---|---|
protected |
BlockReader(java.util.function.Supplier<IndexDictionary.Browser> dictionaryBrowserSupplier,
IndexInput blockInput,
PostingsReaderBase postingsReader,
FieldMetadata fieldMetadata,
BlockDecoder blockDecoder) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
clearTermState()
Called by the primary
TermsEnum methods to clear the previous TermState. |
protected int |
compareToMiddleAndJump(BytesRef searchedTerm)
Compares the searched term to the middle term of the block.
|
protected BytesRef |
decodeBlockBytesIfNeeded(int numBlockBytes) |
int |
docFreq() |
protected IndexDictionary.Browser |
getOrCreateDictionaryBrowser() |
ImpactsEnum |
impacts(int flags) |
protected void |
initializeBlockReadLazily() |
protected void |
initializeHeader(BytesRef searchedTerm,
long targetBlockStartFP)
Reads and sets
blockHeader. |
protected boolean |
isBeyondLastTerm(BytesRef searchedTerm,
long blockStartFP)
Indicates whether the searched term is beyond the last term of the field.
|
protected boolean |
isCurrentTerm(BytesRef searchedTerm) |
BytesRef |
next() |
protected BytesRef |
nextTerm()
Moves to the next term line and reads it, it may be in the next block.
|
long |
ord() |
PostingsEnum |
postings(PostingsEnum reuse,
int flags) |
long |
ramBytesUsed() |
protected BlockHeader |
readHeader()
Reads the block header.
|
protected BlockLine |
readLineInBlock()
Reads the current block line.
|
protected BlockTermState |
readTermState()
Reads the
BlockTermState on the current line. |
protected BlockTermState |
readTermStateIfNotRead()
Reads the
BlockTermState if it is not already set. |
SeekStatus |
seekCeil(BytesRef searchedTerm) |
boolean |
seekExact(BytesRef searchedTerm) |
void |
seekExact(BytesRef term,
TermState state)
Positions this
BlockReader without re-seeking the term dictionary. |
protected SeekStatus |
seekInBlock(BytesRef searchedTerm)
Seeks to the provided term in this block.
|
protected SeekStatus |
seekInBlock(BytesRef searchedTerm,
long blockStartFP)
Seeks to the provided term in the block starting at the provided file pointer.
|
BytesRef |
term() |
TermState |
termState() |
long |
totalTermFreq() |
protected IndexInput blockInput
IndexInput on the block file.protected final PostingsReaderBase postingsReader
protected final FieldMetadata fieldMetadata
protected final BlockDecoder blockDecoder
protected BlockLine.Serializer blockLineReader
protected ByteArrayDataInput blockReadBuffer
protected ByteArrayDataInput termStatesReadBuffer
blockReadBuffer, with a
different position.protected DeltaBaseTermStateSerializer termStateSerializer
protected final java.util.function.Supplier<IndexDictionary.Browser> dictionaryBrowserSupplier
IndexDictionary.Browser supplier for lazy loading.protected IndexDictionary.Browser dictionaryBrowser
IndexDictionary.Browser once loaded.protected long blockStartFP
block file.protected BlockHeader blockHeader
protected BlockLine blockLine
protected BlockTermState termState
protected int blockFirstLineStart
protected int lineIndexInBlock
protected boolean termStateForced
TermState has been forced with a call to
seekExact(BytesRef, TermState).forcedTermprotected BytesRefBuilder forcedTerm
seekExact(BytesRef, TermState) is called.
This optimizes the use-case when the caller calls first seekExact(BytesRef, TermState)
and then postings(PostingsEnum, int). In this case we don't access
the terms block file (we don't seek) but directly the postings file because
we already have the TermState with the file pointers to the postings
file.
protected BytesRef scratchBlockBytes
protected final BlockTermState scratchTermState
protected BlockReader(java.util.function.Supplier<IndexDictionary.Browser> dictionaryBrowserSupplier, IndexInput blockInput, PostingsReaderBase postingsReader, FieldMetadata fieldMetadata, BlockDecoder blockDecoder) throws java.io.IOException
dictionaryBrowserSupplier - to load the IndexDictionary.Browser
lazily in seekCeil(BytesRef).blockDecoder - Optional block decoder, may be null if none.
It can be used for decompression or decryption.java.io.IOExceptionpublic SeekStatus seekCeil(BytesRef searchedTerm)
throws java.io.IOException
java.io.IOExceptionpublic boolean seekExact(BytesRef searchedTerm)
throws java.io.IOException
java.io.IOExceptionprotected boolean isCurrentTerm(BytesRef searchedTerm)
protected boolean isBeyondLastTerm(BytesRef searchedTerm,
long blockStartFP)
blockStartFP - The current block start file pointer.protected SeekStatus seekInBlock(BytesRef searchedTerm,
long blockStartFP)
throws java.io.IOException
java.io.IOExceptionprotected SeekStatus seekInBlock(BytesRef searchedTerm)
throws java.io.IOException
Does not exceed this block; org.apache.lucene.index.TermsEnum.SeekStatus#END
is returned if it follows the block.
Compares the line terms with the searchedTerm, taking
advantage of the incremental encoding properties.
Scans linearly the terms. Updates the current block line with the current term.
java.io.IOExceptionprotected int compareToMiddleAndJump(BytesRef searchedTerm)
throws java.io.IOException
java.io.IOExceptionprotected BlockLine readLineInBlock() throws java.io.IOException
blockLine and increments lineIndexInBlock.BlockLine; or null if there no more line in the block.java.io.IOExceptionpublic void seekExact(BytesRef term,
TermState state)
BlockReader without re-seeking the term dictionary.
The block containing the term is not read by this method. It will be read
lazily only if needed, for example if next() is called.
Calling postings(PostingsEnum, int) after this method does require the block to be read.
public BytesRef next()
throws java.io.IOException
java.io.IOExceptionprotected BytesRef nextTerm()
throws java.io.IOException
readTermStateIfNotRead().java.io.IOExceptionprotected void initializeHeader(BytesRef searchedTerm,
long targetBlockStartFP)
throws java.io.IOException
blockHeader. Sets null if there is no block for the field anymore.searchedTerm - The searched term; or null if none.targetBlockStartFP - The file pointer of the block to read.java.io.IOExceptionprotected void initializeBlockReadLazily()
protected BlockHeader readHeader() throws java.io.IOException
blockHeader.java.io.IOExceptionprotected BytesRef decodeBlockBytesIfNeeded(int numBlockBytes)
throws java.io.IOException
java.io.IOExceptionprotected BlockTermState readTermStateIfNotRead()
throws java.io.IOException
BlockTermState if it is not already set.
Sets termState.java.io.IOExceptionprotected BlockTermState readTermState()
throws java.io.IOException
BlockTermState on the current line.
Sets termState.
Overriding method may return null if there is no BlockTermState
(in this case the extending class must support a null termState).
BlockTermState; or null if none.java.io.IOExceptionpublic BytesRef term()
public long ord()
public int docFreq()
throws java.io.IOException
java.io.IOExceptionpublic long totalTermFreq()
throws java.io.IOException
java.io.IOExceptionpublic TermState termState()
throws java.io.IOException
java.io.IOExceptionpublic PostingsEnum postings(PostingsEnum reuse,
int flags)
throws java.io.IOException
java.io.IOExceptionpublic ImpactsEnum impacts(int flags)
throws java.io.IOException
java.io.IOExceptionpublic long ramBytesUsed()
protected IndexDictionary.Browser getOrCreateDictionaryBrowser()
protected void clearTermState()
TermsEnum methods to clear the previous TermState.Data In Motion GmbH all rights reserved