lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1696181 - in /lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene: bkdtree/TestBKDTree.java rangetree/TestRangeTree.java
Date Sun, 16 Aug 2015 23:15:23 GMT
Author: mikemccand
Date: Sun Aug 16 23:15:22 2015
New Revision: 1696181

URL: http://svn.apache.org/r1696181
Log:
LUCENE-6697: fix test bugs

Modified:
    lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/bkdtree/TestBKDTree.java
    lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/rangetree/TestRangeTree.java

Modified: lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/bkdtree/TestBKDTree.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/bkdtree/TestBKDTree.java?rev=1696181&r1=1696180&r2=1696181&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/bkdtree/TestBKDTree.java (original)
+++ lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/bkdtree/TestBKDTree.java Sun
Aug 16 23:15:22 2015
@@ -169,9 +169,7 @@ public class TestBKDTree extends LuceneT
     IndexWriterConfig iwc = newIndexWriterConfig();
     // We rely on docID order:
     iwc.setMergePolicy(newLogMergePolicy());
-    int maxPointsInLeaf = TestUtil.nextInt(random(), 16, 2048);
-    int maxPointsSortInHeap = TestUtil.nextInt(random(), maxPointsInLeaf, 1024*1024);
-    Codec codec = TestUtil.alwaysDocValuesFormat(new BKDTreeDocValuesFormat(maxPointsInLeaf,
maxPointsSortInHeap));
+    Codec codec = TestUtil.alwaysDocValuesFormat(getDocValuesFormat());
     iwc.setCodec(codec);
     RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc);
 
@@ -360,15 +358,13 @@ public class TestBKDTree extends LuceneT
   private static final double TOLERANCE = 1e-7;
 
   private static void verify(double[] lats, double[] lons) throws Exception {
-    int maxPointsInLeaf = TestUtil.nextInt(random(), 16, 2048);
-    int maxPointsSortInHeap = TestUtil.nextInt(random(), maxPointsInLeaf, 1024*1024);
     IndexWriterConfig iwc = newIndexWriterConfig();
     // Else we can get O(N^2) merging:
     int mbd = iwc.getMaxBufferedDocs();
     if (mbd != -1 && mbd < lats.length/100) {
       iwc.setMaxBufferedDocs(lats.length/100);
     }
-    final DocValuesFormat dvFormat = new BKDTreeDocValuesFormat(maxPointsInLeaf, maxPointsSortInHeap);
+    final DocValuesFormat dvFormat = getDocValuesFormat();
     Codec codec = new Lucene53Codec() {
         @Override
         public DocValuesFormat getDocValuesFormatForField(String field) {
@@ -616,7 +612,7 @@ public class TestBKDTree extends LuceneT
   public void testAccountableHasDelegate() throws Exception {
     Directory dir = newDirectory();
     IndexWriterConfig iwc = newIndexWriterConfig();
-    Codec codec = TestUtil.alwaysDocValuesFormat(new BKDTreeDocValuesFormat());
+    Codec codec = TestUtil.alwaysDocValuesFormat(getDocValuesFormat());
     iwc.setCodec(codec);
     RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc);
     Document doc = new Document();
@@ -632,4 +628,10 @@ public class TestBKDTree extends LuceneT
     assertTrue(Accountables.toString((Accountable) r.leaves().get(0).reader()).contains("delegate"));
     IOUtils.close(r, w, dir);
   }
+
+  private static DocValuesFormat getDocValuesFormat() {
+    int maxPointsInLeaf = TestUtil.nextInt(random(), 16, 2048);
+    int maxPointsSortInHeap = TestUtil.nextInt(random(), maxPointsInLeaf, 1024*1024);
+    return new BKDTreeDocValuesFormat(maxPointsInLeaf, maxPointsSortInHeap);
+  }
 }

Modified: lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/rangetree/TestRangeTree.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/rangetree/TestRangeTree.java?rev=1696181&r1=1696180&r2=1696181&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/rangetree/TestRangeTree.java
(original)
+++ lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/rangetree/TestRangeTree.java
Sun Aug 16 23:15:22 2015
@@ -123,9 +123,7 @@ public class TestRangeTree extends Lucen
 
     // We rely on docID order:
     iwc.setMergePolicy(newLogMergePolicy());
-    int maxPointsInLeaf = TestUtil.nextInt(random(), 16, 2048);
-    int maxPointsSortInHeap = TestUtil.nextInt(random(), maxPointsInLeaf, 1024*1024);
-    Codec codec = TestUtil.alwaysDocValuesFormat(new RangeTreeDocValuesFormat(maxPointsInLeaf,
maxPointsSortInHeap));
+    Codec codec = TestUtil.alwaysDocValuesFormat(getDocValuesFormat());
     iwc.setCodec(codec);
     RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc);
 
@@ -210,9 +208,7 @@ public class TestRangeTree extends Lucen
 
     // We rely on docID order:
     iwc.setMergePolicy(newLogMergePolicy());
-    int maxPointsInLeaf = TestUtil.nextInt(random(), 16, 2048);
-    int maxPointsSortInHeap = TestUtil.nextInt(random(), 1024, 1024*1024);
-    Codec codec = TestUtil.alwaysDocValuesFormat(new RangeTreeDocValuesFormat(maxPointsInLeaf,
maxPointsSortInHeap));
+    Codec codec = TestUtil.alwaysDocValuesFormat(getDocValuesFormat());
     iwc.setCodec(codec);
     RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc);
 
@@ -353,8 +349,6 @@ public class TestRangeTree extends Lucen
   }
 
   private static void verify(Bits missing, long[] values) throws Exception {
-    int maxPointsInLeaf = TestUtil.nextInt(random(), 16, 2048);
-    int maxPointsSortInHeap = TestUtil.nextInt(random(), maxPointsInLeaf, 1024*1024);
     IndexWriterConfig iwc = newIndexWriterConfig();
 
     // Else we can get O(N^2) merging:
@@ -362,7 +356,7 @@ public class TestRangeTree extends Lucen
     if (mbd != -1 && mbd < values.length/100) {
       iwc.setMaxBufferedDocs(values.length/100);
     }
-    final DocValuesFormat dvFormat = new RangeTreeDocValuesFormat(maxPointsInLeaf, maxPointsSortInHeap);
+    final DocValuesFormat dvFormat = getDocValuesFormat();
     Codec codec = new Lucene53Codec() {
         @Override
         public DocValuesFormat getDocValuesFormatForField(String field) {
@@ -768,4 +762,10 @@ public class TestRangeTree extends Lucen
     return v ^ 0x8000000000000000L;
   }
   */
+
+  private static DocValuesFormat getDocValuesFormat() {
+    int maxPointsInLeaf = TestUtil.nextInt(random(), 16, 2048);
+    int maxPointsSortInHeap = TestUtil.nextInt(random(), maxPointsInLeaf, 1024*1024);
+    return new RangeTreeDocValuesFormat(maxPointsInLeaf, maxPointsSortInHeap);
+  }
 }



Mime
View raw message