mirror of https://github.com/apache/lucene.git
LUCENE-2385: Move NoDeletionPolicy from benchmark to core
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@932129 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0a5e6806f3
commit
5792f0d711
|
@ -343,6 +343,10 @@ New features
|
|||
and iterated as byte[] (wrapped in a BytesRef) by IndexReader for
|
||||
searching.
|
||||
|
||||
* LUCENE-2385: Moved NoDeletionPolicy from benchmark to core. NoDeletionPolicy
|
||||
can be used to prevent commits from ever getting deleted from the index.
|
||||
(Shai Erera)
|
||||
|
||||
Optimizations
|
||||
|
||||
* LUCENE-2075: Terms dict cache is now shared across threads instead
|
||||
|
|
|
@ -35,7 +35,7 @@ content.source=org.apache.lucene.benchmark.byTask.feeds.ReutersContentSource
|
|||
|
||||
#query.maker=org.apache.lucene.benchmark.byTask.feeds.SimpleQueryMaker
|
||||
query.maker=org.apache.lucene.benchmark.byTask.feeds.ReutersQueryMaker
|
||||
deletion.policy=org.apache.lucene.benchmark.utils.NoDeletionPolicy
|
||||
deletion.policy=org.apache.lucene.index.NoDeletionPolicy
|
||||
|
||||
# task at this depth or less would print when they start
|
||||
task.max.depth.log=2
|
||||
|
|
|
@ -83,7 +83,7 @@ BASE_INDEX_ALG = '''
|
|||
analyzer=org.apache.lucene.analysis.standard.StandardAnalyzer
|
||||
|
||||
$OTHER$
|
||||
deletion.policy = org.apache.lucene.benchmark.utils.NoDeletionPolicy
|
||||
deletion.policy = org.apache.lucene.index.NoDeletionPolicy
|
||||
doc.tokenized = false
|
||||
doc.body.tokenized = true
|
||||
doc.stored = true
|
||||
|
|
|
@ -25,6 +25,7 @@ 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.NoDeletionPolicy;
|
||||
import org.apache.lucene.index.NoMergePolicy;
|
||||
import org.apache.lucene.index.NoMergeScheduler;
|
||||
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
|
||||
|
@ -135,23 +136,15 @@ public class CreateIndexTask extends PerfTask {
|
|||
|
||||
public static IndexDeletionPolicy getIndexDeletionPolicy(Config config) {
|
||||
String deletionPolicyName = config.get("deletion.policy", "org.apache.lucene.index.KeepOnlyLastCommitDeletionPolicy");
|
||||
IndexDeletionPolicy indexDeletionPolicy = null;
|
||||
RuntimeException err = null;
|
||||
try {
|
||||
indexDeletionPolicy = Class.forName(deletionPolicyName).asSubclass(IndexDeletionPolicy.class).newInstance();
|
||||
} catch (IllegalAccessException iae) {
|
||||
err = new RuntimeException("unable to instantiate class '" + deletionPolicyName + "' as IndexDeletionPolicy");
|
||||
err.initCause(iae);
|
||||
} catch (InstantiationException ie) {
|
||||
err = new RuntimeException("unable to instantiate class '" + deletionPolicyName + "' as IndexDeletionPolicy");
|
||||
err.initCause(ie);
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
err = new RuntimeException("unable to load class '" + deletionPolicyName + "' as IndexDeletionPolicy");
|
||||
err.initCause(cnfe);
|
||||
if (deletionPolicyName.equals(NoDeletionPolicy.class.getName())) {
|
||||
return NoDeletionPolicy.INSTANCE;
|
||||
} else {
|
||||
try {
|
||||
return Class.forName(deletionPolicyName).asSubclass(IndexDeletionPolicy.class).newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("unable to instantiate class '" + deletionPolicyName + "' as IndexDeletionPolicy", e);
|
||||
}
|
||||
}
|
||||
if (err != null)
|
||||
throw err;
|
||||
return indexDeletionPolicy;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,6 +25,7 @@ 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.NoDeletionPolicy;
|
||||
import org.apache.lucene.index.NoMergePolicy;
|
||||
import org.apache.lucene.index.NoMergeScheduler;
|
||||
|
||||
|
@ -95,4 +96,11 @@ public class CreateIndexTaskTest extends BenchmarkTestCase {
|
|||
new CloseIndexTask(runData).doLogic();
|
||||
}
|
||||
|
||||
public void testNoDeletionPolicy() throws Exception {
|
||||
PerfRunData runData = createPerfRunData(null);
|
||||
runData.getConfig().set("deletion.policy", NoDeletionPolicy.class.getName());
|
||||
new CreateIndexTask(runData).doLogic();
|
||||
new CloseIndexTask(runData).doLogic();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.benchmark.utils;
|
||||
package org.apache.lucene.index;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -20,18 +20,22 @@ package org.apache.lucene.benchmark.utils;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.lucene.index.IndexCommit;
|
||||
import org.apache.lucene.index.IndexDeletionPolicy;
|
||||
/**
|
||||
* An {@link IndexDeletionPolicy} which keeps all index commits around, never
|
||||
* deleting them. This class is a singleton and can be accessed by referencing
|
||||
* {@link #INSTANCE}.
|
||||
*/
|
||||
public final class NoDeletionPolicy implements IndexDeletionPolicy {
|
||||
|
||||
public class NoDeletionPolicy implements IndexDeletionPolicy {
|
||||
|
||||
public void onCommit(List<? extends IndexCommit> commits) throws IOException {
|
||||
// TODO Auto-generated method stub
|
||||
/** The single instance of this class. */
|
||||
public static final IndexDeletionPolicy INSTANCE = new NoDeletionPolicy();
|
||||
|
||||
private NoDeletionPolicy() {
|
||||
// keep private to avoid instantiation
|
||||
}
|
||||
|
||||
public void onInit(List<? extends IndexCommit> commits) throws IOException {
|
||||
// TODO Auto-generated method stub
|
||||
public void onCommit(List<? extends IndexCommit> commits) throws IOException {}
|
||||
|
||||
public void onInit(List<? extends IndexCommit> commits) throws IOException {}
|
||||
|
||||
}
|
||||
}
|
|
@ -46,9 +46,9 @@ public class TestNoMergeScheduler extends LuceneTestCaseJ4 {
|
|||
|
||||
@Test
|
||||
public void testMethodsOverridden() throws Exception {
|
||||
// Ensures that all methods of MergePolicy are overridden. That's important
|
||||
// to ensure that NoMergePolicy overrides everything, so that no unexpected
|
||||
// behavior/error occurs
|
||||
// Ensures that all methods of MergeScheduler are overridden. That's
|
||||
// important to ensure that NoMergeScheduler overrides everything, so that
|
||||
// no unexpected behavior/error occurs
|
||||
for (Method m : NoMergeScheduler.class.getMethods()) {
|
||||
// getDeclaredMethods() returns just those methods that are declared on
|
||||
// NoMergeScheduler. getMethods() returns those that are visible in that
|
||||
|
|
Loading…
Reference in New Issue