romseygeek commented on a change in pull request #1467:
URL: https://github.com/apache/lucene-solr/pull/1467#discussion_r417400710
##########
File path: lucene/core/src/java/org/apache/lucene/search/FuzzyTermsEnum.java
##########
@@ -364,4 +325,60 @@ public BytesRef term() throws IOException {
}
}
+ /**
+ * Used for sharing automata between segments
+ *
+ * Levenshtein automata are large and expensive to build; we don't want to
build
+ * them directly on the query because this can blow up caches that use
queries
+ * as keys; we also don't want to rebuild them for every segment. This
attribute
+ * allows the FuzzyTermsEnum to build the automata once for its first segment
+ * and then share them for subsequent segment calls.
+ */
+ private interface AutomatonAttribute extends Attribute {
+ CompiledAutomaton[] getAutomata();
+ int getTermLength();
+ void init(Supplier<FuzzyAutomatonBuilder> builder);
+ }
+
+ private static class AutomatonAttributeImpl extends AttributeImpl implements
AutomatonAttribute {
+
+ private CompiledAutomaton[] automata;
+ private int termLength;
+
+ @Override
+ public CompiledAutomaton[] getAutomata() {
+ return automata;
+ }
+
+ @Override
+ public int getTermLength() {
+ return termLength;
+ }
+
+ @Override
+ public void init(Supplier<FuzzyAutomatonBuilder> supplier) {
+ if (automata != null) {
+ return;
+ }
+ FuzzyAutomatonBuilder builder = supplier.get();
+ this.termLength = builder.getTermLength();
+ this.automata = builder.buildAutomatonSet();
+ }
+
+ @Override
+ public void clear() {
+ this.automata = null;
+ }
+
+ @Override
+ public void reflectWith(AttributeReflector reflector) {
Review comment:
It's a private implementation and only gets used internally to
FuzzyTermsEnum, so I don't see how the analysis page or luke would get
presented with one of these?
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]