romseygeek commented on a change in pull request #1467:
URL: https://github.com/apache/lucene-solr/pull/1467#discussion_r418480197



##########
File path: lucene/core/src/java/org/apache/lucene/search/FuzzyTermsEnum.java
##########
@@ -88,43 +89,44 @@
    * @throws IOException if there is a low-level IO error
    */
   public FuzzyTermsEnum(Terms terms, Term term, int maxEdits, int 
prefixLength, boolean transpositions) throws IOException {
-    this(terms, term, stringToUTF32(term.text()), maxEdits, prefixLength, 
transpositions);
-  }
-
-  private FuzzyTermsEnum(Terms terms, Term term, int[] codePoints, int 
maxEdits, int prefixLength, boolean transpositions) throws IOException {
-    this(terms, new AttributeSource(), term, codePoints.length, maxEdits,
-        buildAutomata(term.text(), codePoints, prefixLength, transpositions, 
maxEdits));
+    this(terms, new AttributeSource(), term, () -> new 
FuzzyAutomatonBuilder(term.text(), maxEdits, prefixLength, transpositions));
   }
 
   /**
    * Constructor for enumeration of all terms from specified 
<code>reader</code> which share a prefix of
    * length <code>prefixLength</code> with <code>term</code> and which have at 
most {@code maxEdits} edits.
    * <p>
-   * After calling the constructor the enumeration is already pointing to the 
first 
-   * valid term if such a term exists. 
-   * 
+   * After calling the constructor the enumeration is already pointing to the 
first
+   * valid term if such a term exists.
+   *
    * @param terms Delivers terms.
-   * @param atts {@link AttributeSource} created by the rewrite method of 
{@link MultiTermQuery}
-   *              that contains information about competitive boosts during 
rewrite
+   * @param atts An AttributeSource used to share automata between segments
    * @param term Pattern term.
    * @param maxEdits Maximum edit distance.
-   * @param automata An array of levenshtein automata to match against terms,
-   *                 see {@link #buildAutomata(String, int[], int, boolean, 
int)}
+   * @param prefixLength the length of the required common prefix
+   * @param transpositions whether transpositions should count as a single edit
    * @throws IOException if there is a low-level IO error
    */
-  public FuzzyTermsEnum(Terms terms, AttributeSource atts, Term term, int 
termLength,
-      final int maxEdits, CompiledAutomaton[] automata) throws IOException {
+  FuzzyTermsEnum(Terms terms, AttributeSource atts, Term term, int maxEdits, 
int prefixLength, boolean transpositions) throws IOException {
+    this(terms, atts, term, () -> new FuzzyAutomatonBuilder(term.text(), 
maxEdits, prefixLength, transpositions));
+  }
+
+  private FuzzyTermsEnum(Terms terms, AttributeSource atts, Term term, 
Supplier<FuzzyAutomatonBuilder> automatonBuilder) throws IOException {
 
-    this.maxEdits = maxEdits;
     this.terms = terms;
-    this.term = term;
     this.atts = atts;
-    this.termLength = termLength;
+    this.term = term;
 
     this.maxBoostAtt = 
atts.addAttribute(MaxNonCompetitiveBoostAttribute.class);
     this.boostAtt = atts.addAttribute(BoostAttribute.class);
 
-    this.automata = automata;
+    atts.addAttributeImpl(new AutomatonAttributeImpl());

Review comment:
       I don't think we can use an AttributeFactory here because the attribute 
source has already been created.  This seems to work fine though - @thetaphi 
can probably tell me if I've done something wrong?




----------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to