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 2021/03/30 16:02:57 UTC

[GitHub] [lucene] jtibshirani commented on a change in pull request #52: LUCENE-9705: Create Lucene90PointsFormat

jtibshirani commented on a change in pull request #52:
URL: https://github.com/apache/lucene/pull/52#discussion_r604216342



##########
File path: lucene/core/src/test/org/apache/lucene/codecs/lucene90/TestLucene90PointsFormat.java
##########
@@ -0,0 +1,425 @@
+/*
+ * 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.codecs.lucene90;
+
+import java.io.IOException;
+import java.util.Arrays;
+import org.apache.lucene.codecs.Codec;
+import org.apache.lucene.codecs.FilterCodec;
+import org.apache.lucene.codecs.PointsFormat;
+import org.apache.lucene.codecs.PointsReader;
+import org.apache.lucene.codecs.PointsWriter;
+import org.apache.lucene.document.BinaryPoint;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.index.BasePointsFormatTestCase;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.LeafReader;
+import org.apache.lucene.index.MockRandomMergePolicy;
+import org.apache.lucene.index.PointValues;
+import org.apache.lucene.index.PointValues.IntersectVisitor;
+import org.apache.lucene.index.PointValues.Relation;
+import org.apache.lucene.index.SegmentReadState;
+import org.apache.lucene.index.SegmentWriteState;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.TestUtil;
+import org.apache.lucene.util.bkd.BKDConfig;
+
+public class TestLucene90PointsFormat extends BasePointsFormatTestCase {
+
+  private final Codec codec;
+  private final int maxPointsInLeafNode;
+
+  public TestLucene90PointsFormat() {
+    // standard issue
+    Codec defaultCodec = TestUtil.getDefaultCodec();
+    if (random().nextBoolean()) {
+      // randomize parameters
+      maxPointsInLeafNode = TestUtil.nextInt(random(), 50, 500);
+      double maxMBSortInHeap = 3.0 + (3 * random().nextDouble());
+      if (VERBOSE) {
+        System.out.println(
+            "TEST: using Lucene60PointsFormat with maxPointsInLeafNode="
+                + maxPointsInLeafNode
+                + " and maxMBSortInHeap="
+                + maxMBSortInHeap);
+      }
+
+      // sneaky impersonation!
+      codec =
+          new FilterCodec(defaultCodec.getName(), defaultCodec) {
+            @Override
+            public PointsFormat pointsFormat() {
+              return new PointsFormat() {
+                @Override
+                public PointsWriter fieldsWriter(SegmentWriteState writeState) throws IOException {
+                  return new Lucene90PointsWriter(writeState, maxPointsInLeafNode, maxMBSortInHeap);
+                }
+
+                @Override
+                public PointsReader fieldsReader(SegmentReadState readState) throws IOException {
+                  return new Lucene90PointsReader(readState);
+                }
+              };
+            }
+          };
+    } else {
+      // standard issue
+      codec = defaultCodec;
+      maxPointsInLeafNode = BKDConfig.DEFAULT_MAX_POINTS_IN_LEAF_NODE;
+    }
+  }
+
+  @Override
+  protected Codec getCodec() {
+    return codec;
+  }
+
+  @Override
+  public void testMergeStability() throws Exception {
+    assumeFalse(
+        "TODO: mess with the parameters and test gets angry!", codec instanceof FilterCodec);
+    super.testMergeStability();
+  }
+
+  public void testEstimatePointCount() throws IOException {

Review comment:
       Is it possible to move these methods to `BasePointsFormatTestCase`? It'd be nice to cut down on duplicated test cases.

##########
File path: lucene/backward-codecs/src/test/org/apache/lucene/backward_codecs/lucene86/Lucene86PointsWriter.java
##########
@@ -60,40 +60,40 @@ public Lucene86PointsWriter(
         IndexFileNames.segmentFileName(
             writeState.segmentInfo.name,
             writeState.segmentSuffix,
-            Lucene86PointsFormat.DATA_EXTENSION);
+            Lucene86RWPointsFormat.DATA_EXTENSION);

Review comment:
       Small comment, seems clearer to reference `Lucene86PointsFormat` here.




-- 
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:
users@infra.apache.org



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