Class IntersectBlockReader
- java.lang.Object
-
- org.apache.lucene.index.TermsEnum
-
- org.apache.lucene.index.BaseTermsEnum
-
- org.apache.lucene.codecs.uniformsplit.BlockReader
-
- org.apache.lucene.codecs.uniformsplit.IntersectBlockReader
-
- All Implemented Interfaces:
Accountable
,BytesRefIterator
- Direct Known Subclasses:
STIntersectBlockReader
public class IntersectBlockReader extends BlockReader
The "intersect"TermsEnum
response toUniformSplitTerms.intersect(CompiledAutomaton, BytesRef)
, intersecting the terms with an automaton.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
IntersectBlockReader.AutomatonNextTermCalculator
This is a copy of AutomatonTermsEnum.-
Nested classes/interfaces inherited from class org.apache.lucene.index.TermsEnum
TermsEnum.SeekStatus
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
beyondCommonPrefix
Whether the current term is beyond the automaton common prefix.protected int
blockPrefixLen
protected int
blockPrefixRunAutomatonState
protected BytesRef
commonPrefixRef
protected BytesRef
commonSuffixRef
protected IntersectBlockReader.AutomatonNextTermCalculator
nextStringCalculator
protected int
numBytesAccepted
Number of bytes accepted by the last call torunAutomatonForState(byte[], int, int, int)
.protected ByteRunAutomaton
runAutomaton
protected BytesRef
seekTerm
Set this when our current mode is seeking to this term.protected BytesRef
startTerm
-
Fields inherited from class org.apache.lucene.codecs.uniformsplit.BlockReader
blockDecoder, blockFirstLineStart, blockHeader, blockInput, blockLine, blockLineReader, blockReadBuffer, blockStartFP, dictionaryBrowser, dictionaryBrowserSupplier, fieldMetadata, forcedTerm, lineIndexInBlock, postingsReader, scratchBlockBytes, scratchTermState, termState, termStateForced, termStateSerializer, termStatesReadBuffer
-
-
Constructor Summary
Constructors Constructor Description IntersectBlockReader(CompiledAutomaton compiled, BytesRef startTerm, DictionaryBrowserSupplier dictionaryBrowserSupplier, IndexInput blockInput, PostingsReaderBase postingsReader, FieldMetadata fieldMetadata, BlockDecoder blockDecoder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
isBeyondCommonPrefix(BytesRef bytesRef)
Determines if the providedBytesRef
is beyond the automaton common prefix.BytesRef
next()
Increments the iteration to the nextBytesRef
in the iterator.protected boolean
nextBlockMatchingPrefix()
Find the next block that appears to contain terms that could match the automata.protected BytesRef
nextTermInBlockMatching()
Find the next block line that matches, or null when at end of block.protected int
runAutomatonForState(byte[] s, int offset, int length, int initialState)
Run the automaton and return the final state (not necessary accepted).protected boolean
runAutomatonFromPrefix(BytesRef term)
TermsEnum.SeekStatus
seekCeil(BytesRef text)
Seeks to the specified term, if it exists, or to the next (ceiling) term.void
seekExact(long ord)
Not supported.boolean
seekExact(BytesRef text)
Attempts to seek to the exact term, returning true if the term is found.void
seekExact(BytesRef term, TermState state)
Positions thisBlockReader
without re-seeking the term dictionary.-
Methods inherited from class org.apache.lucene.codecs.uniformsplit.BlockReader
clearTermState, compareToMiddleAndJump, decodeBlockBytesIfNeeded, docFreq, getOrCreateDictionaryBrowser, impacts, initializeBlockReadLazily, initializeHeader, isBeyondLastTerm, isCurrentTerm, nextTerm, ord, postings, ramBytesUsed, readHeader, readLineInBlock, readTermState, readTermStateIfNotRead, seekInBlock, seekInBlock, term, termState, totalTermFreq
-
Methods inherited from class org.apache.lucene.index.BaseTermsEnum
attributes
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.lucene.util.Accountable
getChildResources
-
-
-
-
Field Detail
-
nextStringCalculator
protected final IntersectBlockReader.AutomatonNextTermCalculator nextStringCalculator
-
runAutomaton
protected final ByteRunAutomaton runAutomaton
-
commonSuffixRef
protected final BytesRef commonSuffixRef
-
commonPrefixRef
protected final BytesRef commonPrefixRef
-
startTerm
protected final BytesRef startTerm
-
seekTerm
protected BytesRef seekTerm
Set this when our current mode is seeking to this term. Set to null after.
-
blockPrefixRunAutomatonState
protected int blockPrefixRunAutomatonState
-
blockPrefixLen
protected int blockPrefixLen
-
numBytesAccepted
protected int numBytesAccepted
Number of bytes accepted by the last call torunAutomatonForState(byte[], int, int, int)
.
-
beyondCommonPrefix
protected boolean beyondCommonPrefix
Whether the current term is beyond the automaton common prefix. If true this means the enumeration should stop immediately.
-
-
Constructor Detail
-
IntersectBlockReader
public IntersectBlockReader(CompiledAutomaton compiled, BytesRef startTerm, DictionaryBrowserSupplier dictionaryBrowserSupplier, IndexInput blockInput, PostingsReaderBase postingsReader, FieldMetadata fieldMetadata, BlockDecoder blockDecoder) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
next
public BytesRef next() throws java.io.IOException
Description copied from interface:BytesRefIterator
Increments the iteration to the nextBytesRef
in the iterator. Returns the resultingBytesRef
ornull
if the end of the iterator is reached. The returned BytesRef may be re-used across calls to next. After this method returns null, do not call it again: the results are undefined.- Specified by:
next
in interfaceBytesRefIterator
- Overrides:
next
in classBlockReader
- Returns:
- the next
BytesRef
in the iterator ornull
if the end of the iterator is reached. - Throws:
java.io.IOException
- If there is a low-level I/O error.
-
nextBlockMatchingPrefix
protected boolean nextBlockMatchingPrefix() throws java.io.IOException
Find the next block that appears to contain terms that could match the automata. The prefix is the primary clue. Returns true if at one, or false for no more (EOF).- Throws:
java.io.IOException
-
nextTermInBlockMatching
protected BytesRef nextTermInBlockMatching() throws java.io.IOException
Find the next block line that matches, or null when at end of block.- Throws:
java.io.IOException
-
runAutomatonFromPrefix
protected boolean runAutomatonFromPrefix(BytesRef term)
-
runAutomatonForState
protected int runAutomatonForState(byte[] s, int offset, int length, int initialState)
Run the automaton and return the final state (not necessary accepted). -1 signifies no state / no match. SetsnumBytesAccepted
with the offset of the first byte rejected by the automaton; or (offset + length) if no byte is rejected.
-
isBeyondCommonPrefix
protected boolean isBeyondCommonPrefix(BytesRef bytesRef)
Determines if the providedBytesRef
is beyond the automaton common prefix. This method must be called after a call torunAutomatonForState(byte[], int, int, int)
because it usesnumBytesAccepted
value.
-
seekExact
public boolean seekExact(BytesRef text)
Description copied from class:TermsEnum
Attempts to seek to the exact term, returning true if the term is found. If this returns false, the enum is unpositioned. For some codecs, seekExact may be substantially faster thanTermsEnum.seekCeil(org.apache.lucene.util.BytesRef)
.- Overrides:
seekExact
in classBlockReader
- Returns:
- true if the term is found; return false if the enum is unpositioned.
-
seekExact
public void seekExact(long ord)
Description copied from class:BlockReader
Not supported.- Overrides:
seekExact
in classBlockReader
-
seekCeil
public TermsEnum.SeekStatus seekCeil(BytesRef text)
Description copied from class:TermsEnum
Seeks to the specified term, if it exists, or to the next (ceiling) term. Returns SeekStatus to indicate whether exact term was found, a different term was found, or EOF was hit. The target term may be before or after the current term. If this returns SeekStatus.END, the enum is unpositioned.- Overrides:
seekCeil
in classBlockReader
-
seekExact
public void seekExact(BytesRef term, TermState state)
Description copied from class:BlockReader
Positions thisBlockReader
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
BlockReader.next()
is called. CallingBlockReader.postings(org.apache.lucene.index.PostingsEnum, int)
after this method does require the block to be read.- Overrides:
seekExact
in classBlockReader
- Parameters:
term
- the term the TermState corresponds tostate
- theTermState
-
-