Skip to content

Commit

Permalink
plub through isFinite and simplify arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmiller committed May 19, 2023
1 parent ca0e8a6 commit eb68482
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,41 @@ public AutomatonQuery(final Term term, Automaton automaton, boolean isBinary) {
*/
public AutomatonQuery(
final Term term, Automaton automaton, boolean isBinary, RewriteMethod rewriteMethod) {
this(term, automaton, false, true, isBinary, rewriteMethod);
}

/**
* Create a new AutomatonQuery from an {@link Automaton}.
*
* @param term Term containing field and possibly some pattern structure. The term text is
* ignored.
* @param automaton Automaton to run, terms that are accepted are considered a match.
* @param isFinite if true, this automaton is already finite
* @param isBinary if true, this automaton is already binary and will not go through the
* UTF32ToUTF8 conversion
*/
public AutomatonQuery(final Term term, Automaton automaton, boolean isFinite, boolean simplify, boolean isBinary) {
this(term, automaton, isFinite, simplify, isBinary, CONSTANT_SCORE_BLENDED_REWRITE);
}

/**
* Create a new AutomatonQuery from an {@link Automaton}.
*
* @param term Term containing field and possibly some pattern structure. The term text is
* ignored.
* @param automaton Automaton to run, terms that are accepted are considered a match.
* @param isFinite if true, this automaton is already finite
* @param isBinary if true, this automaton is already binary and will not go through the
* UTF32ToUTF8 conversion
* @param rewriteMethod the rewriteMethod to use to build the final query from the automaton
*/
public AutomatonQuery(
final Term term, Automaton automaton, boolean isFinite, boolean simplify, boolean isBinary, RewriteMethod rewriteMethod) {
super(term.field(), rewriteMethod);
this.term = term;
this.automaton = automaton;
this.automatonIsBinary = isBinary;
this.compiled = new CompiledAutomaton(automaton, false, true, isBinary);
this.compiled = new CompiledAutomaton(automaton, isFinite, simplify, isBinary);

this.ramBytesUsed =
BASE_RAM_BYTES + term.ramBytesUsed() + automaton.ramBytesUsed() + compiled.ramBytesUsed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class TermInSetQuery extends AutomatonQuery {
private final int termCount;

public TermInSetQuery(String field, Collection<BytesRef> terms) {
super(new Term(field), toAutomaton(terms), true);
super(new Term(field), toAutomaton(terms), true, false, true);
this.field = field;
this.termCount = terms.size();
}
Expand All @@ -80,7 +80,7 @@ public TermInSetQuery(String field, BytesRef... terms) {

/** Creates a new {@link TermInSetQuery} from the given collection of terms. */
public TermInSetQuery(RewriteMethod rewriteMethod, String field, Collection<BytesRef> terms) {
super(new Term(field), toAutomaton(terms), true, rewriteMethod);
super(new Term(field), toAutomaton(terms), true, false, true, rewriteMethod);
this.field = field;
this.termCount = terms.size();
}
Expand Down

0 comments on commit eb68482

Please sign in to comment.