mirror of https://github.com/apache/lucene.git
LUCENE-2512: fix DeleteByPercentTask to work again post flex
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@957486 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a9947aeb8d
commit
f81a5d9bf6
|
@ -77,10 +77,15 @@ public class DeleteByPercentTask extends PerfTask {
|
|||
Bits delDocs = MultiFields.getDeletedDocs(r);
|
||||
int doc = 0;
|
||||
while (doc < maxDoc && numDeleted < numToDelete) {
|
||||
if (!delDocs.get(doc) && random.nextDouble() <= delRate) {
|
||||
if ((delDocs == null || !delDocs.get(doc)) && random.nextDouble() <= delRate) {
|
||||
r.deleteDocument(doc);
|
||||
numDeleted++;
|
||||
if (delDocs == null) {
|
||||
delDocs = MultiFields.getDeletedDocs(r);
|
||||
assert delDocs != null;
|
||||
}
|
||||
}
|
||||
doc++;
|
||||
}
|
||||
}
|
||||
System.out.println("--> processed (delete) " + numDeleted + " docs");
|
||||
|
|
|
@ -606,6 +606,40 @@ public class TestPerfTasksLogic extends BenchmarkTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void testDeleteByPercent() throws Exception {
|
||||
// 1. alg definition (required in every "logic" test)
|
||||
String algLines[] = {
|
||||
"# ----- properties ",
|
||||
"content.source=org.apache.lucene.benchmark.byTask.feeds.LineDocSource",
|
||||
"docs.file=" + getReuters20LinesFile(),
|
||||
"ram.flush.mb=-1",
|
||||
"max.buffered=2",
|
||||
"content.source.log.step=3",
|
||||
"doc.term.vector=false",
|
||||
"content.source.forever=false",
|
||||
"directory=RAMDirectory",
|
||||
"doc.stored=false",
|
||||
"doc.tokenized=false",
|
||||
"debug.level=1",
|
||||
"# ----- alg ",
|
||||
"CreateIndex",
|
||||
"{ \"AddDocs\" AddDoc > : * ",
|
||||
"CloseIndex()",
|
||||
"OpenReader(false)",
|
||||
"DeleteByPercent(20)",
|
||||
"CloseReader"
|
||||
};
|
||||
|
||||
// 2. execute the algorithm (required in every "logic" test)
|
||||
Benchmark benchmark = execBenchmark(algLines);
|
||||
|
||||
// 3. test number of docs in the index
|
||||
IndexReader ir = IndexReader.open(benchmark.getRunData().getDirectory(), true);
|
||||
int ndocsExpected = 16; // first 20 reuters docs, minus 20%
|
||||
assertEquals("wrong number of docs in the index!", ndocsExpected, ir.numDocs());
|
||||
ir.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that we can set merge scheduler".
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue