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

[GitHub] [lucene] gsmiller commented on a diff in pull request #12158: Clone the BytesRef[] values in KeywordField#newSetQuery

gsmiller commented on code in PR #12158:
URL: https://github.com/apache/lucene/pull/12158#discussion_r1114516161


##########
lucene/core/src/java/org/apache/lucene/document/KeywordField.java:
##########
@@ -169,7 +169,7 @@ public static Query newSetQuery(String field, BytesRef... values) {
     Objects.requireNonNull(field, "field must not be null");
     Objects.requireNonNull(values, "values must not be null");
     return new IndexOrDocValuesQuery(
-        new TermInSetQuery(field, values), new SortedSetDocValuesSetQuery(field, values));
+        new TermInSetQuery(field, values), new SortedSetDocValuesSetQuery(field, values.clone()));

Review Comment:
   If the class was public, I would agree. Not cloning in the ctor though leaves open the option of sharing a pre-sorted array across different query implementations. Like what’s being explored in #12141. So I think I favor this approach still, even though it is a bit trappy. At a minimum though, let me at least add some javadoc to the ctor warning of this. 



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