Package org.apache.lucene.util.automaton
Class CompiledAutomaton
- java.lang.Object
-
- org.apache.lucene.util.automaton.CompiledAutomaton
-
- All Implemented Interfaces:
Accountable
public class CompiledAutomaton extends java.lang.Object implements Accountable
Immutable class holding compiled details for a given Automaton. The Automaton is deterministic, must not have dead states but is not necessarily minimal.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CompiledAutomaton.AUTOMATON_TYPE
Automata are compiled into different internal forms for the most efficient execution depending upon the language they accept.
-
Field Summary
Fields Modifier and Type Field Description Automaton
automaton
Two dimensional array of transitions, indexed by state number for traversal.private static long
BASE_RAM_BYTES
BytesRef
commonSuffixRef
Shared common suffix accepted by the automaton.java.lang.Boolean
finite
Indicates if the automaton accepts a finite set of strings.ByteRunAutomaton
runAutomaton
Matcher for quickly determining if a byte[] is accepted.int
sinkState
Which state, if any, accepts all suffixes, else -1.BytesRef
term
ForCompiledAutomaton.AUTOMATON_TYPE.SINGLE
this is the singleton term.private Transition
transition
CompiledAutomaton.AUTOMATON_TYPE
type
If simplify is true this will be the "simplified" type; else, this is NORMAL-
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE
-
-
Constructor Summary
Constructors Constructor Description CompiledAutomaton(Automaton automaton)
Create this, passing simplify=true and finite=null, so that we try to simplify the automaton and determine if it is finite.CompiledAutomaton(Automaton automaton, java.lang.Boolean finite, boolean simplify)
Create this.CompiledAutomaton(Automaton automaton, java.lang.Boolean finite, boolean simplify, int determinizeWorkLimit, boolean isBinary)
Create this.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private BytesRef
addTail(int state, BytesRefBuilder term, int idx, int leadLabel)
boolean
equals(java.lang.Object obj)
private static int
findSinkState(Automaton automaton)
Returns sink state, if present, else -1.BytesRef
floor(BytesRef input, BytesRefBuilder output)
Finds largest term accepted by this Automaton, that's <= the provided input term.TermsEnum
getTermsEnum(Terms terms)
int
hashCode()
long
ramBytesUsed()
Return the memory usage of this object in bytes.void
visit(QueryVisitor visitor, Query parent, java.lang.String field)
Report back to a QueryVisitor how this automaton matches terms-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.lucene.util.Accountable
getChildResources
-
-
-
-
Field Detail
-
BASE_RAM_BYTES
private static final long BASE_RAM_BYTES
-
type
public final CompiledAutomaton.AUTOMATON_TYPE type
If simplify is true this will be the "simplified" type; else, this is NORMAL
-
term
public final BytesRef term
ForCompiledAutomaton.AUTOMATON_TYPE.SINGLE
this is the singleton term.
-
runAutomaton
public final ByteRunAutomaton runAutomaton
Matcher for quickly determining if a byte[] is accepted. only valid forCompiledAutomaton.AUTOMATON_TYPE.NORMAL
.
-
automaton
public final Automaton automaton
Two dimensional array of transitions, indexed by state number for traversal. The state numbering is consistent withrunAutomaton
. Only valid forCompiledAutomaton.AUTOMATON_TYPE.NORMAL
.
-
commonSuffixRef
public final BytesRef commonSuffixRef
Shared common suffix accepted by the automaton. Only valid forCompiledAutomaton.AUTOMATON_TYPE.NORMAL
, and only when the automaton accepts an infinite language. This will be null if the common prefix is length 0.
-
finite
public final java.lang.Boolean finite
Indicates if the automaton accepts a finite set of strings. Null if this was not computed. Only valid forCompiledAutomaton.AUTOMATON_TYPE.NORMAL
.
-
sinkState
public final int sinkState
Which state, if any, accepts all suffixes, else -1.
-
transition
private Transition transition
-
-
Constructor Detail
-
CompiledAutomaton
public CompiledAutomaton(Automaton automaton)
Create this, passing simplify=true and finite=null, so that we try to simplify the automaton and determine if it is finite.
-
CompiledAutomaton
public CompiledAutomaton(Automaton automaton, java.lang.Boolean finite, boolean simplify)
Create this. If finite is null, we useOperations.isFinite(org.apache.lucene.util.automaton.Automaton)
to determine whether it is finite. If simplify is true, we run possibly expensive operations to determine if the automaton is one the cases inCompiledAutomaton.AUTOMATON_TYPE
.
-
CompiledAutomaton
public CompiledAutomaton(Automaton automaton, java.lang.Boolean finite, boolean simplify, int determinizeWorkLimit, boolean isBinary)
Create this. If finite is null, we useOperations.isFinite(org.apache.lucene.util.automaton.Automaton)
to determine whether it is finite. If simplify is true, we run possibly expensive operations to determine if the automaton is one the cases inCompiledAutomaton.AUTOMATON_TYPE
. If simplify requires determinizing the automaton then at most determinizeWorkLimit effort will be spent. Any more than that will cause a TooComplexToDeterminizeException.
-
-
Method Detail
-
findSinkState
private static int findSinkState(Automaton automaton)
Returns sink state, if present, else -1.
-
addTail
private BytesRef addTail(int state, BytesRefBuilder term, int idx, int leadLabel)
-
getTermsEnum
public TermsEnum getTermsEnum(Terms terms) throws java.io.IOException
- Throws:
java.io.IOException
-
visit
public void visit(QueryVisitor visitor, Query parent, java.lang.String field)
Report back to a QueryVisitor how this automaton matches terms
-
floor
public BytesRef floor(BytesRef input, BytesRefBuilder output)
Finds largest term accepted by this Automaton, that's <= the provided input term. The result is placed in output; it's fine for output and input to point to the same bytes. The returned result is either the provided output, or null if there is no floor term (ie, the provided input term is before the first term accepted by this Automaton).
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
ramBytesUsed
public long ramBytesUsed()
Description copied from interface:Accountable
Return the memory usage of this object in bytes. Negative values are illegal.- Specified by:
ramBytesUsed
in interfaceAccountable
-
-