mirror of https://github.com/apache/lucene.git
LUCENE-5649: tests should sometimes disable bulk merges for segments
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1592752 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
07d9fd7bd3
commit
15f1d9416a
|
@ -64,7 +64,7 @@ public class MockRandomMergePolicy extends MergePolicy {
|
||||||
// TODO: sometimes make more than 1 merge?
|
// TODO: sometimes make more than 1 merge?
|
||||||
mergeSpec = new MergeSpecification();
|
mergeSpec = new MergeSpecification();
|
||||||
final int segsToMerge = TestUtil.nextInt(random, 1, numSegments);
|
final int segsToMerge = TestUtil.nextInt(random, 1, numSegments);
|
||||||
mergeSpec.add(new OneMerge(segments.subList(0, segsToMerge)));
|
mergeSpec.add(new MockRandomOneMerge(segments.subList(0, segsToMerge),random.nextLong()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return mergeSpec;
|
return mergeSpec;
|
||||||
|
@ -93,7 +93,7 @@ public class MockRandomMergePolicy extends MergePolicy {
|
||||||
while(upto < eligibleSegments.size()) {
|
while(upto < eligibleSegments.size()) {
|
||||||
int max = Math.min(10, eligibleSegments.size()-upto);
|
int max = Math.min(10, eligibleSegments.size()-upto);
|
||||||
int inc = max <= 2 ? max : TestUtil.nextInt(random, 2, max);
|
int inc = max <= 2 ? max : TestUtil.nextInt(random, 2, max);
|
||||||
mergeSpec.add(new OneMerge(eligibleSegments.subList(upto, upto+inc)));
|
mergeSpec.add(new MockRandomOneMerge(eligibleSegments.subList(upto, upto+inc), random.nextLong()));
|
||||||
upto += inc;
|
upto += inc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,4 +122,28 @@ public class MockRandomMergePolicy extends MergePolicy {
|
||||||
// 80% of the time we create CFS:
|
// 80% of the time we create CFS:
|
||||||
return random.nextInt(5) != 1;
|
return random.nextInt(5) != 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class MockRandomOneMerge extends OneMerge {
|
||||||
|
final Random r;
|
||||||
|
ArrayList<AtomicReader> readers;
|
||||||
|
|
||||||
|
MockRandomOneMerge(List<SegmentCommitInfo> segments, long seed) {
|
||||||
|
super(segments);
|
||||||
|
r = new Random(seed);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AtomicReader> getMergeReaders() throws IOException {
|
||||||
|
if (readers == null) {
|
||||||
|
readers = new ArrayList<AtomicReader>(super.getMergeReaders());
|
||||||
|
for (int i = 0; i < readers.size(); i++) {
|
||||||
|
// wrap it (e.g. prevent bulk merge etc)
|
||||||
|
if (r.nextInt(4) == 0) {
|
||||||
|
readers.set(i, new FilterAtomicReader(readers.get(i)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return readers;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue