LUCENE-5668: fix ob1 in TieredMergePolicy

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1594059 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2014-05-12 19:16:56 +00:00
parent cf4eb04a21
commit fb23f007aa
2 changed files with 29 additions and 0 deletions

View File

@ -186,6 +186,8 @@ Bug fixes
* LUCENE-5660: AnalyzingSuggester.build will now throw IllegalArgumentException if
you give it a longer suggestion than it can handle (Robert Muir, Mike McCandless)
* LUCENE-5668: Fix off-by-one in TieredMergePolicy (Mike McCandless)
Test Framework
* LUCENE-5622: Fail tests if they print over the given limit of bytes to

View File

@ -211,4 +211,31 @@ public class TestTieredMergePolicy extends BaseMergePolicyTestCase {
// TODO: Add more checks for other non-double setters!
}
// LUCENE-5668
public void testUnbalancedMergeSelection() throws Exception {
Directory dir = newDirectory();
IndexWriterConfig iwc = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
TieredMergePolicy tmp = (TieredMergePolicy) iwc.getMergePolicy();
tmp.setFloorSegmentMB(0.00001);
iwc.setMergeScheduler(new SerialMergeScheduler());
iwc.setMaxBufferedDocs(100);
iwc.setRAMBufferSizeMB(-1);
IndexWriter w = new IndexWriter(dir, iwc);
for(int i=0;i<100000;i++) {
Document doc = new Document();
doc.add(newTextField("id", random().nextLong() + "" + random().nextLong(), Field.Store.YES));
w.addDocument(doc);
}
IndexReader r = DirectoryReader.open(w, true);
// Make sure TMP always merged equal-number-of-docs segments:
for(AtomicReaderContext ctx : r.leaves()) {
int numDocs = ctx.reader().numDocs();
assertTrue("got numDocs=" + numDocs, numDocs == 100 || numDocs == 1000 || numDocs == 10000);
}
r.close();
w.close();
dir.close();
}
}