public class AutomatonTermsEnum extends FilteredTermsEnum
The algorithm is such:
The algorithm does not attempt to actually skip to the next string that is completely accepted. This is not possible when the language accepted by the FSM is not finite (i.e. * operator).
FilteredTermsEnum.AcceptStatus
TermsEnum.SeekStatus
Modifier and Type | Field and Description |
---|---|
private Automaton |
automaton |
private BytesRef |
commonSuffixRef |
private long |
curGen |
private boolean |
finite |
private boolean |
linear |
private BytesRef |
linearUpperBound |
private ByteRunAutomaton |
runAutomaton |
private IntsRefBuilder |
savedStates |
private BytesRefBuilder |
seekBytesRef |
private Transition |
transition |
private long[] |
visited |
actualTerm, tenum
Constructor and Description |
---|
AutomatonTermsEnum(TermsEnum tenum,
CompiledAutomaton compiled)
Construct an enumerator based upon an automaton, enumerating the specified
field, working on a supplied TermsEnum
|
Modifier and Type | Method and Description |
---|---|
protected FilteredTermsEnum.AcceptStatus |
accept(BytesRef term)
Returns true if the term matches the automaton.
|
private int |
backtrack(int position)
Attempts to backtrack thru the string after encountering a dead end
at some given position.
|
protected BytesRef |
nextSeekTerm(BytesRef term)
On the first call to
FilteredTermsEnum.next() or if FilteredTermsEnum.accept(org.apache.lucene.util.BytesRef) returns
FilteredTermsEnum.AcceptStatus.YES_AND_SEEK or FilteredTermsEnum.AcceptStatus.NO_AND_SEEK ,
this method will be called to eventually seek the underlying TermsEnum
to a new position. |
private boolean |
nextString()
Increments the byte buffer to the next String in binary order after s that will not put
the machine into a reject state.
|
private boolean |
nextString(int state,
int position)
Returns the next String in lexicographic order that will not put
the machine into a reject state.
|
private void |
setLinear(int position)
Sets the enum to operate in linear fashion, as we have found
a looping transition at position: we set an upper bound and
act like a TermRangeQuery for this portion of the term space.
|
attributes, docFreq, impacts, next, ord, postings, seekCeil, seekExact, seekExact, seekExact, setInitialSeekTerm, term, termState, totalTermFreq
private final ByteRunAutomaton runAutomaton
private final BytesRef commonSuffixRef
private final boolean finite
private final Automaton automaton
private final long[] visited
private long curGen
private final BytesRefBuilder seekBytesRef
private boolean linear
private final BytesRef linearUpperBound
private Transition transition
private final IntsRefBuilder savedStates
public AutomatonTermsEnum(TermsEnum tenum, CompiledAutomaton compiled)
compiled
- CompiledAutomatonprotected FilteredTermsEnum.AcceptStatus accept(BytesRef term)
accept
in class FilteredTermsEnum
protected BytesRef nextSeekTerm(BytesRef term) throws java.io.IOException
FilteredTermsEnum
FilteredTermsEnum.next()
or if FilteredTermsEnum.accept(org.apache.lucene.util.BytesRef)
returns
FilteredTermsEnum.AcceptStatus.YES_AND_SEEK
or FilteredTermsEnum.AcceptStatus.NO_AND_SEEK
,
this method will be called to eventually seek the underlying TermsEnum
to a new position.
On the first call, currentTerm
will be null
, later
calls will provide the term the underlying enum is positioned at.
This method returns per default only one time the initial seek term
and then null
, so no repositioning is ever done.
Override this method, if you want a more sophisticated TermsEnum,
that repositions the iterator during enumeration.
If this method always returns null
the enum is empty.
Please note: This method should always provide a greater term than the last enumerated term, else the behaviour of this enum violates the contract for TermsEnums.
nextSeekTerm
in class FilteredTermsEnum
java.io.IOException
private void setLinear(int position)
private boolean nextString()
private boolean nextString(int state, int position)
state
- current non-reject stateposition
- useful portion of the stringprivate int backtrack(int position)
position
- current position in the input Stringposition >= 0
if more possible solutions exist for the DFA