romseygeek commented on a change in pull request #1042: LUCENE-9068: Build FuzzyQuery automata up-front URL: https://github.com/apache/lucene-solr/pull/1042#discussion_r362775224
########## File path: lucene/core/src/java/org/apache/lucene/search/FuzzyTermsEnum.java ########## @@ -91,58 +105,49 @@ * * @param terms Delivers terms. * @param atts {@link AttributeSource} created by the rewrite method of {@link MultiTermQuery} - * thats contains information about competitive boosts during rewrite. It is also used - * to cache DFAs between segment transitions. + * that contains information about competitive boosts during rewrite * @param term Pattern term. * @param maxEdits Maximum edit distance. - * @param prefixLength Length of required common prefix. Default value is 0. + * @param automata An array of levenshtein automata to match against terms, + * see {@link #buildAutomata(String, int, boolean, int)} * @throws IOException if there is a low-level IO error */ public FuzzyTermsEnum(Terms terms, AttributeSource atts, Term term, - final int maxEdits, final int prefixLength, boolean transpositions) throws IOException { - if (maxEdits < 0 || maxEdits > LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE) { - throw new IllegalArgumentException("max edits must be 0.." + LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE + ", inclusive; got: " + maxEdits); - } - if (prefixLength < 0) { - throw new IllegalArgumentException("prefixLength cannot be less than 0"); - } + final int maxEdits, CompiledAutomaton[] automata) throws IOException { + this.maxEdits = maxEdits; this.terms = terms; this.term = term; + this.atts = atts; // convert the string into a utf32 int[] representation for fast comparisons - this.termText = stringToUTF32(term.text()); + int[] termText = stringToUTF32(term.text()); Review comment: I've rearranged things a bit now so that we don't call this twice ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org