LUCENE-6697: fix test bugs

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1696181 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2015-08-16 23:15:22 +00:00
parent dc2f2295e0
commit 4f543493a4
2 changed files with 18 additions and 16 deletions

View File

@ -169,9 +169,7 @@ public class TestBKDTree extends LuceneTestCase {
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 LuceneTestCase {
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 LuceneTestCase {
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 LuceneTestCase {
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);
}
}

View File

@ -123,9 +123,7 @@ public class TestRangeTree extends LuceneTestCase {
// 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 LuceneTestCase {
// 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 LuceneTestCase {
}
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 LuceneTestCase {
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 LuceneTestCase {
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);
}
}