mirror of https://github.com/apache/lucene.git
LUCENE-2377: Enable the use of NoMergePolicy and NoMergeScheduler by Benchmark
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@931502 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ec8bcf48d1
commit
a37ac8ba7d
|
@ -2,6 +2,10 @@ Lucene Benchmark Contrib Change Log
|
|||
|
||||
The Benchmark contrib package contains code for benchmarking Lucene in a variety of ways.
|
||||
|
||||
4/07/2010
|
||||
LUCENE-2377: Enable the use of NoMergePolicy and NoMergeScheduler by
|
||||
CreateIndexTask. (Shai Erera)
|
||||
|
||||
3/28/2010
|
||||
LUCENE-2353: Fixed bug in Config where Windows absolute path property values
|
||||
were incorrectly handled (Shai Erera)
|
||||
|
|
|
@ -25,6 +25,8 @@ import org.apache.lucene.index.IndexWriterConfig;
|
|||
import org.apache.lucene.index.MergeScheduler;
|
||||
import org.apache.lucene.index.ConcurrentMergeScheduler;
|
||||
import org.apache.lucene.index.MergePolicy;
|
||||
import org.apache.lucene.index.NoMergePolicy;
|
||||
import org.apache.lucene.index.NoMergeScheduler;
|
||||
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
|
||||
import org.apache.lucene.util.Version;
|
||||
|
||||
|
@ -70,6 +72,9 @@ public class CreateIndexTask extends PerfTask {
|
|||
|
||||
final String mergeScheduler = config.get("merge.scheduler",
|
||||
"org.apache.lucene.index.ConcurrentMergeScheduler");
|
||||
if (mergeScheduler.equals(NoMergeScheduler.class.getName())) {
|
||||
writer.setMergeScheduler(NoMergeScheduler.INSTANCE);
|
||||
} else {
|
||||
try {
|
||||
writer.setMergeScheduler(Class.forName(mergeScheduler).asSubclass(MergeScheduler.class).newInstance());
|
||||
} catch (Exception e) {
|
||||
|
@ -87,17 +92,22 @@ public class CreateIndexTask extends PerfTask {
|
|||
cms.setMaxMergeCount(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final String mergePolicy = config.get("merge.policy",
|
||||
"org.apache.lucene.index.LogByteSizeMergePolicy");
|
||||
boolean isCompound = config.get("compound", true);
|
||||
if (mergePolicy.equals(NoMergePolicy.class.getName())) {
|
||||
writer.setMergePolicy(isCompound ? NoMergePolicy.COMPOUND_FILES : NoMergePolicy.NO_COMPOUND_FILES);
|
||||
} else {
|
||||
try {
|
||||
writer.setMergePolicy(Class.forName(mergePolicy).asSubclass(MergePolicy.class).newInstance());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("unable to instantiate class '" + mergePolicy + "' as merge policy", e);
|
||||
}
|
||||
|
||||
writer.setUseCompoundFile(config.get("compound",true));
|
||||
writer.setUseCompoundFile(isCompound);
|
||||
writer.setMergeFactor(config.get("merge.factor",OpenIndexTask.DEFAULT_MERGE_PFACTOR));
|
||||
}
|
||||
writer.setMaxFieldLength(config.get("max.field.length",OpenIndexTask.DEFAULT_MAX_FIELD_LENGTH));
|
||||
|
||||
final double ramBuffer = config.get("ram.flush.mb",OpenIndexTask.DEFAULT_RAM_FLUSH_MB);
|
||||
|
|
|
@ -25,6 +25,8 @@ import java.util.Properties;
|
|||
import org.apache.lucene.benchmark.BenchmarkTestCase;
|
||||
import org.apache.lucene.benchmark.byTask.PerfRunData;
|
||||
import org.apache.lucene.benchmark.byTask.utils.Config;
|
||||
import org.apache.lucene.index.NoMergePolicy;
|
||||
import org.apache.lucene.index.NoMergeScheduler;
|
||||
|
||||
/** Tests the functionality of {@link CreateIndexTask}. */
|
||||
public class CreateIndexTaskTest extends BenchmarkTestCase {
|
||||
|
@ -33,7 +35,9 @@ public class CreateIndexTaskTest extends BenchmarkTestCase {
|
|||
Properties props = new Properties();
|
||||
props.setProperty("print.props", "false"); // don't print anything
|
||||
props.setProperty("directory", "RAMDirectory");
|
||||
if (infoStreamValue != null) {
|
||||
props.setProperty("writer.info.stream", infoStreamValue);
|
||||
}
|
||||
Config config = new Config(props);
|
||||
return new PerfRunData(config);
|
||||
}
|
||||
|
@ -77,4 +81,18 @@ public class CreateIndexTaskTest extends BenchmarkTestCase {
|
|||
assertTrue(outFile.length() > 0);
|
||||
}
|
||||
|
||||
public void testNoMergePolicy() throws Exception {
|
||||
PerfRunData runData = createPerfRunData(null);
|
||||
runData.getConfig().set("merge.policy", NoMergePolicy.class.getName());
|
||||
new CreateIndexTask(runData).doLogic();
|
||||
new CloseIndexTask(runData).doLogic();
|
||||
}
|
||||
|
||||
public void testNoMergeScheduler() throws Exception {
|
||||
PerfRunData runData = createPerfRunData(null);
|
||||
runData.getConfig().set("merge.scheduler", NoMergeScheduler.class.getName());
|
||||
new CreateIndexTask(runData).doLogic();
|
||||
new CloseIndexTask(runData).doLogic();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue