You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "rmuir (via GitHub)" <gi...@apache.org> on 2023/02/10 13:57:42 UTC

[GitHub] [lucene] rmuir commented on a diff in pull request #12141: Avoid duplicate sorting in KeywordField#newSetQuery (alternative approach)

rmuir commented on code in PR #12141:
URL: https://github.com/apache/lucene/pull/12141#discussion_r1102797942


##########
lucene/core/src/java/org/apache/lucene/document/SortedSetDocValuesSetQuery.java:
##########
@@ -51,20 +54,23 @@ final class SortedSetDocValuesSetQuery extends Query implements Accountable {
   private final PrefixCodedTerms termData;
   private final int termDataHashCode; // cached hashcode of termData
 
-  SortedSetDocValuesSetQuery(String field, BytesRef terms[]) {
+  /**
+   * Creates a new {@link TermInSetQuery} from the given collection of terms. This is most efficient
+   * if it is a sorted set or any other collection which has a presorted and distinct spliterator.
+   */
+  SortedSetDocValuesSetQuery(String field, Collection<BytesRef> terms) {
+    this(field, terms.stream());
+  }
+
+  /** Creates a new {@link TermInSetQuery} from the given array of terms. */
+  SortedSetDocValuesSetQuery(String field, BytesRef... terms) {
+    this(field, Arrays.stream(terms));
+  }
+
+  private SortedSetDocValuesSetQuery(String field, Stream<BytesRef> stream) {

Review Comment:
   do we really need 3 ctors or could we just have a single package private ctor taking stream. The XXXField classes could just call .stream method? I just don't know if we need so much "sugar" for classes that are entirely package private.
   
   Unfortunately, the TermInSetQuery is a public class, so maybe there are different concerns there. 



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

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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