public class BlockReader extends BaseTermsEnum implements Accountable
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.
TermsEnum.SeekStatus| 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 BlockHeader.Serializer |
blockHeaderReader |
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 IndexDictionary.BrowserSupplier |
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 BlockLine |
scratchBlockLine |
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.
|
NULL_ACCOUNTABLE| Modifier | Constructor and Description |
|---|---|
protected |
BlockReader(IndexDictionary.BrowserSupplier dictionaryBrowserSupplier,
IndexInput blockInput,
PostingsReaderBase postingsReader,
FieldMetadata fieldMetadata,
BlockDecoder blockDecoder) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
clearTermState()
|
protected int |
compareToMiddleAndJump(BytesRef searchedTerm)
Compares the searched term to the middle term of the block.
|
protected BlockHeader.Serializer |
createBlockHeaderSerializer() |
protected BlockLine.Serializer |
createBlockLineSerializer() |
protected DeltaBaseTermStateSerializer |
createDeltaBaseTermStateSerializer() |
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) |
protected CorruptIndexException |
newCorruptIndexException(String msg,
Long fp) |
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. |
TermsEnum.SeekStatus |
seekCeil(BytesRef searchedTerm) |
boolean |
seekExact(BytesRef searchedTerm) |
void |
seekExact(BytesRef term,
TermState state)
Positions this
BlockReader without re-seeking the term dictionary. |
void |
seekExact(long ord)
Not supported.
|
protected TermsEnum.SeekStatus |
seekInBlock(BytesRef searchedTerm)
Seeks to the provided term in this block.
|
protected TermsEnum.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() |
attributesclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetChildResourcesprotected IndexInput blockInput
IndexInput on the block file.protected final PostingsReaderBase postingsReader
protected final FieldMetadata fieldMetadata
protected final BlockDecoder blockDecoder
protected BlockHeader.Serializer blockHeaderReader
protected BlockLine.Serializer blockLineReader
protected ByteArrayDataInput blockReadBuffer
protected ByteArrayDataInput termStatesReadBuffer
blockReadBuffer, with a
different position.protected DeltaBaseTermStateSerializer termStateSerializer
protected final IndexDictionary.BrowserSupplier 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 BlockLine scratchBlockLine
protected BlockReader(IndexDictionary.BrowserSupplier dictionaryBrowserSupplier, IndexInput blockInput, PostingsReaderBase postingsReader, FieldMetadata fieldMetadata, BlockDecoder blockDecoder) throws 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.IOExceptionpublic TermsEnum.SeekStatus seekCeil(BytesRef searchedTerm) throws IOException
seekCeil in class TermsEnumIOExceptionpublic boolean seekExact(BytesRef searchedTerm) throws IOException
seekExact in class BaseTermsEnumIOExceptionprotected boolean isCurrentTerm(BytesRef searchedTerm)
protected boolean isBeyondLastTerm(BytesRef searchedTerm, long blockStartFP)
blockStartFP - The current block start file pointer.protected TermsEnum.SeekStatus seekInBlock(BytesRef searchedTerm, long blockStartFP) throws IOException
IOExceptionprotected TermsEnum.SeekStatus seekInBlock(BytesRef searchedTerm) throws IOException
Does not exceed this block; 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.
IOExceptionprotected int compareToMiddleAndJump(BytesRef searchedTerm) throws IOException
IOExceptionprotected BlockLine readLineInBlock() throws IOException
blockLine and increments lineIndexInBlock.BlockLine; or null if there no more line in the block.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(org.apache.lucene.index.PostingsEnum, int) after this method does require the block to be read.
seekExact in class BaseTermsEnumpublic BytesRef next() throws IOException
next in interface BytesRefIteratorIOExceptionprotected BytesRef nextTerm() throws IOException
readTermStateIfNotRead().IOExceptionprotected void initializeHeader(BytesRef searchedTerm, long targetBlockStartFP) throws 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.IOExceptionprotected void initializeBlockReadLazily()
throws IOException
IOExceptionprotected BlockHeader.Serializer createBlockHeaderSerializer()
protected BlockLine.Serializer createBlockLineSerializer()
protected DeltaBaseTermStateSerializer createDeltaBaseTermStateSerializer()
protected BlockHeader readHeader() throws IOException
blockHeader.IOExceptionprotected BytesRef decodeBlockBytesIfNeeded(int numBlockBytes) throws IOException
IOExceptionprotected BlockTermState readTermStateIfNotRead() throws IOException
BlockTermState if it is not already set.
Sets termState.IOExceptionprotected BlockTermState readTermState() throws 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.IOExceptionpublic int docFreq()
throws IOException
docFreq in class TermsEnumIOExceptionpublic long totalTermFreq()
throws IOException
totalTermFreq in class TermsEnumIOExceptionpublic TermState termState() throws IOException
termState in class BaseTermsEnumIOExceptionpublic PostingsEnum postings(PostingsEnum reuse, int flags) throws IOException
postings in class TermsEnumIOExceptionpublic ImpactsEnum impacts(int flags) throws IOException
impacts in class TermsEnumIOExceptionpublic long ramBytesUsed()
ramBytesUsed in interface Accountableprotected IndexDictionary.Browser getOrCreateDictionaryBrowser() throws IOException
IOExceptionprotected void clearTermState()
protected CorruptIndexException newCorruptIndexException(String msg, Long fp)
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.