lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sh...@apache.org
Subject svn commit: r932129 - in /lucene/dev/trunk/lucene: ./ contrib/benchmark/ contrib/benchmark/conf/ contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ contrib/benchmark/src/java/org/apache/lucene/benchmark/utils/ contrib/benchmark/src/te...
Date Thu, 08 Apr 2010 21:34:12 GMT
Author: shaie
Date: Thu Apr  8 21:34:11 2010
New Revision: 932129

URL: http://svn.apache.org/viewvc?rev=932129&view=rev
Log:
LUCENE-2385: Move NoDeletionPolicy from benchmark to core

Added:
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/NoDeletionPolicy.java
      - copied, changed from r932055, lucene/dev/trunk/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/utils/NoDeletionPolicy.java
Removed:
    lucene/dev/trunk/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/utils/NoDeletionPolicy.java
Modified:
    lucene/dev/trunk/lucene/CHANGES.txt
    lucene/dev/trunk/lucene/contrib/benchmark/conf/deletepercent.alg
    lucene/dev/trunk/lucene/contrib/benchmark/sortBench.py
    lucene/dev/trunk/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.java
    lucene/dev/trunk/lucene/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTaskTest.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestNoMergeScheduler.java

Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=932129&r1=932128&r2=932129&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Thu Apr  8 21:34:11 2010
@@ -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

Modified: lucene/dev/trunk/lucene/contrib/benchmark/conf/deletepercent.alg
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/benchmark/conf/deletepercent.alg?rev=932129&r1=932128&r2=932129&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/benchmark/conf/deletepercent.alg (original)
+++ lucene/dev/trunk/lucene/contrib/benchmark/conf/deletepercent.alg Thu Apr  8 21:34:11 2010
@@ -35,7 +35,7 @@ content.source=org.apache.lucene.benchma
 
 #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

Modified: lucene/dev/trunk/lucene/contrib/benchmark/sortBench.py
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/benchmark/sortBench.py?rev=932129&r1=932128&r2=932129&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/benchmark/sortBench.py (original)
+++ lucene/dev/trunk/lucene/contrib/benchmark/sortBench.py Thu Apr  8 21:34:11 2010
@@ -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

Modified: lucene/dev/trunk/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.java?rev=932129&r1=932128&r2=932129&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.java
(original)
+++ lucene/dev/trunk/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.java
Thu Apr  8 21:34:11 2010
@@ -25,6 +25,7 @@ import org.apache.lucene.index.IndexWrit
 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 Per
   
   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

Modified: lucene/dev/trunk/lucene/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTaskTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTaskTest.java?rev=932129&r1=932128&r2=932129&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTaskTest.java
(original)
+++ lucene/dev/trunk/lucene/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTaskTest.java
Thu Apr  8 21:34:11 2010
@@ -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;
 
@@ -94,5 +95,12 @@ public class CreateIndexTaskTest extends
     new CreateIndexTask(runData).doLogic();
     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();
+  }
   
 }

Copied: lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/NoDeletionPolicy.java (from
r932055, lucene/dev/trunk/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/utils/NoDeletionPolicy.java)
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/NoDeletionPolicy.java?p2=lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/NoDeletionPolicy.java&p1=lucene/dev/trunk/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/utils/NoDeletionPolicy.java&r1=932055&r2=932129&rev=932129&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/utils/NoDeletionPolicy.java
(original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/NoDeletionPolicy.java Thu Apr
 8 21:34:11 2010
@@ -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.util
 import java.io.IOException;
 import java.util.List;
 
-import org.apache.lucene.index.IndexCommit;
-import org.apache.lucene.index.IndexDeletionPolicy;
-
-public class NoDeletionPolicy implements 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 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 onCommit(List<? extends IndexCommit> commits) throws IOException {}
 
-  public void onInit(List<? extends IndexCommit> commits) throws IOException {
-    // TODO Auto-generated method stub
-    
-  }
+  public void onInit(List<? extends IndexCommit> commits) throws IOException {}
+  
 }

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestNoMergeScheduler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestNoMergeScheduler.java?rev=932129&r1=932128&r2=932129&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestNoMergeScheduler.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestNoMergeScheduler.java Thu
Apr  8 21:34:11 2010
@@ -46,9 +46,9 @@ public class TestNoMergeScheduler extend
 
   @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



Mime
View raw message