You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/08/17 01:16:07 UTC

svn commit: r1696182 - in /lucene/dev/branches/branch_5x: ./ lucene/ lucene/sandbox/ lucene/sandbox/src/test/org/apache/lucene/bkdtree/TestBKDTree.java lucene/sandbox/src/test/org/apache/lucene/rangetree/TestRangeTree.java

Author: mikemccand
Date: Sun Aug 16 23:16:07 2015
New Revision: 1696182

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

Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/lucene/   (props changed)
    lucene/dev/branches/branch_5x/lucene/sandbox/   (props changed)
    lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/bkdtree/TestBKDTree.java
    lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/rangetree/TestRangeTree.java

Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/bkdtree/TestBKDTree.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/bkdtree/TestBKDTree.java?rev=1696182&r1=1696181&r2=1696182&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/bkdtree/TestBKDTree.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/bkdtree/TestBKDTree.java Sun Aug 16 23:16:07 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);
 
@@ -361,15 +359,13 @@ public class TestBKDTree extends LuceneT
 
   private static void verify(final double[] lats, final 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) {
@@ -617,7 +613,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();
@@ -633,4 +629,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/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/rangetree/TestRangeTree.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/rangetree/TestRangeTree.java?rev=1696182&r1=1696181&r2=1696182&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/rangetree/TestRangeTree.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/rangetree/TestRangeTree.java Sun Aug 16 23:16:07 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(final Bits missing, final 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);
+  }
 }