org.apache.lucene.codecs.uniformsplit

## 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 to `UniformSplitTerms.intersect(CompiledAutomaton, BytesRef)`, intersecting the terms with an automaton.

### Nested Class Summary

Nested Classes
`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
`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 to `runAutomatonForState(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`

### Fields inherited from class org.apache.lucene.index.TermsEnum

`EMPTY`

### Constructor Summary

Constructors
Constructor and Description
`IntersectBlockReader(CompiledAutomaton compiled, BytesRef startTerm, DictionaryBrowserSupplier dictionaryBrowserSupplier, IndexInput blockInput, PostingsReaderBase postingsReader, FieldMetadata fieldMetadata, BlockDecoder blockDecoder)`

### Method Summary

All Methods Instance Methods Concrete Methods
`protected boolean` `isBeyondCommonPrefix(BytesRef bytesRef)` Determines if the provided `BytesRef` is beyond the automaton common prefix.
`BytesRef` `next()`
`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)`
`boolean` `seekExact(BytesRef text)`
`void` `seekExact(BytesRef term, TermState state)` Positions this `BlockReader` without re-seeking the term dictionary.
`void` `seekExact(long ord)` Not supported.

### 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 org.apache.lucene.index.TermsEnum

`postings`

### 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 to `runAutomatonForState(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 IOException

Throws:
  `IOException`

### Method Detail

#### next

    public BytesRef next()
                  throws IOException

Specified by:
  `next` in interface `BytesRefIterator`
Overrides:
  `next` in class `BlockReader`
Throws:
  `IOException`

#### nextBlockMatchingPrefix

    protected boolean nextBlockMatchingPrefix()
                                       throws 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:
  `IOException`

#### nextTermInBlockMatching

    protected BytesRef nextTermInBlockMatching()
                                        throws IOException

Find the next block line that matches, or null when at end of block.

Throws:
  `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. Sets `numBytesAccepted` 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 provided `BytesRef` is beyond the automaton common prefix. This method must be called after a call to `runAutomatonForState(byte[], int, int, int)` because it uses `numBytesAccepted` value.

#### seekExact

    public boolean seekExact(BytesRef text)

Overrides:
  `seekExact` in class `BlockReader`

#### seekExact

    public void seekExact(long ord)

Description copied from class: `BlockReader`
Not supported.

Overrides:
  `seekExact` in class `BlockReader`

#### seekCeil

    public TermsEnum.SeekStatus seekCeil(BytesRef text)

Overrides:
  `seekCeil` in class `BlockReader`

#### seekExact

    public void seekExact(BytesRef term,
                          TermState state)

Description copied from class: `BlockReader`
Positions this `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 `BlockReader.next()` is called. Calling `BlockReader.postings(org.apache.lucene.index.PostingsEnum, int)` after this method does require the block to be read.

Overrides:
  `seekExact` in class `BlockReader`