Github user mikemccand commented on a diff in the pull request:
https://github.com/apache/lucene-solr/pull/526#discussion_r241372182
--- Diff:
lucene/core/src/java/org/apache/lucene/index/FrozenBufferedUpdates.java ---
@@ -821,4 +759,93 @@ public String toString() {
boolean any() {
return deleteTerms.size() > 0 || deleteQueries.length > 0 ||
fieldUpdatesCount > 0 ;
}
+
+ /**
+ * This class helps iterating a term dictionary and consuming all the
docs for each terms.
+ * It accepts a field, value tuple and returns a {@link
DocIdSetIterator} if the field has an entry
+ * for the given value. It has an optimized way of iterating the term
dictionary if the terms are
+ * passed in sorted order and makes sure terms and postings are reused
as much as possible.
+ */
+ static final class TermDocsIterator {
+ private final TermsProvider provider;
+ private String field;
+ private TermsEnum termsEnum;
+ private PostingsEnum postingsEnum;
+ private final boolean sortedTerms;
+ private BytesRef readerTerm;
+
+ @FunctionalInterface
+ interface TermsProvider {
+ Terms terms(String field) throws IOException;
+ }
+
+ TermDocsIterator(Fields fields, boolean sortedTerms) {
+ this(fields::terms, sortedTerms);
+ }
+
+ TermDocsIterator(LeafReader reader, boolean sortedTerms) {
+ this(reader::terms, sortedTerms);
+ }
+
+ private TermDocsIterator(TermsProvider provider, boolean sortedTerms) {
+ this.sortedTerms = sortedTerms;
+ this.provider = provider;
+ }
+
+ private void nextField(String field) throws IOException {
--- End diff --
Maybe simply name `setField` or `changeField`? `nextField` made me think
it was somehow following along in sorted field order or something.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]