You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2022/03/21 16:44:35 UTC

[GitHub] [lucene] nknize commented on a change in pull request #749: LUCENE-10466: IndexSortSortedNumericDocValuesRangeQuery unconditionally assumes the usage of the LONG-encoded SortField

nknize commented on a change in pull request #749:
URL: https://github.com/apache/lucene/pull/749#discussion_r831316035



##########
File path: lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestIndexSortSortedNumericDocValuesRangeQueryByType.java
##########
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.sandbox.search;
+
+import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
+import java.util.Arrays;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.SortedNumericDocValuesField;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.SortField;
+import org.apache.lucene.search.SortedNumericSortField;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.tests.analysis.MockAnalyzer;
+import org.apache.lucene.tests.index.RandomIndexWriter;
+import org.apache.lucene.tests.util.LuceneTestCase;
+
+public class TestIndexSortSortedNumericDocValuesRangeQueryByType extends LuceneTestCase {
+  private final SortField.Type type;
+
+  public TestIndexSortSortedNumericDocValuesRangeQueryByType(SortField.Type type) {
+    this.type = type;
+  }
+
+  @ParametersFactory(argumentFormatting = "type=%s")
+  public static Iterable<Object[]> parametersWithCustomName() {
+    return Arrays.asList(
+        new Object[][] {
+          {SortField.Type.INT},
+          {SortField.Type.FLOAT},
+          {SortField.Type.LONG},
+          {SortField.Type.DOUBLE}
+        });
+  }
+
+  public void testIndexSortDocValues() throws Exception {
+    testIndexSortDocValuesWithEvenLength(true);
+    testIndexSortDocValuesWithEvenLength(false);
+  }
+
+  private void testIndexSortDocValuesWithEvenLength(boolean reverse) throws Exception {
+    Directory dir = newDirectory();
+
+    IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
+    Sort indexSort = new Sort(new SortedNumericSortField("field", type, reverse));

Review comment:
       ```suggestion
       Sort indexSort = new Sort(new SortedNumericSortField("field", RandomPicks.randomFrom(new SortField.Type[] {SortField.Type.INT, SortField.Type.FLOAT, SortField.Type.LONG, SortField.Type.DOUBLE}), reverse));
   ```

##########
File path: lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestIndexSortSortedNumericDocValuesRangeQueryByType.java
##########
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.sandbox.search;
+
+import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
+import java.util.Arrays;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.SortedNumericDocValuesField;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.SortField;
+import org.apache.lucene.search.SortedNumericSortField;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.tests.analysis.MockAnalyzer;
+import org.apache.lucene.tests.index.RandomIndexWriter;
+import org.apache.lucene.tests.util.LuceneTestCase;
+
+public class TestIndexSortSortedNumericDocValuesRangeQueryByType extends LuceneTestCase {
+  private final SortField.Type type;
+
+  public TestIndexSortSortedNumericDocValuesRangeQueryByType(SortField.Type type) {
+    this.type = type;
+  }
+
+  @ParametersFactory(argumentFormatting = "type=%s")

Review comment:
       I think this is overkill.. maybe just use `RandomPicks.randomFrom(..)`?
   Suggestion below.




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