lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sh...@apache.org
Subject svn commit: r931502 - in /lucene/dev/trunk/lucene/contrib/benchmark: CHANGES.txt src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.java src/test/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTaskTest.java
Date Wed, 07 Apr 2010 11:03:32 GMT
Author: shaie
Date: Wed Apr  7 11:03:32 2010
New Revision: 931502

URL: http://svn.apache.org/viewvc?rev=931502&view=rev
Log:
LUCENE-2377: Enable the use of NoMergePolicy and NoMergeScheduler by Benchmark

Modified:
    lucene/dev/trunk/lucene/contrib/benchmark/CHANGES.txt
    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

Modified: lucene/dev/trunk/lucene/contrib/benchmark/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/benchmark/CHANGES.txt?rev=931502&r1=931501&r2=931502&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/benchmark/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/contrib/benchmark/CHANGES.txt Wed Apr  7 11:03:32 2010
@@ -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)

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=931502&r1=931501&r2=931502&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
Wed Apr  7 11:03:32 2010
@@ -25,6 +25,8 @@ 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.NoMergePolicy;
+import org.apache.lucene.index.NoMergeScheduler;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
 import org.apache.lucene.util.Version;
 
@@ -70,34 +72,42 @@ public class CreateIndexTask extends Per
 
     final String mergeScheduler = config.get("merge.scheduler",
                                              "org.apache.lucene.index.ConcurrentMergeScheduler");
-    try {
-      writer.setMergeScheduler(Class.forName(mergeScheduler).asSubclass(MergeScheduler.class).newInstance());
-    } catch (Exception e) {
-      throw new RuntimeException("unable to instantiate class '" + mergeScheduler + "' as
merge scheduler", e);
-    }
-
-    if (mergeScheduler.equals("org.apache.lucene.index.ConcurrentMergeScheduler")) {
-      ConcurrentMergeScheduler cms = (ConcurrentMergeScheduler) writer.getMergeScheduler();
-      int v = config.get("concurrent.merge.scheduler.max.thread.count", -1);
-      if (v != -1) {
-        cms.setMaxThreadCount(v);
+    if (mergeScheduler.equals(NoMergeScheduler.class.getName())) {
+      writer.setMergeScheduler(NoMergeScheduler.INSTANCE);
+    } else {
+      try {
+        writer.setMergeScheduler(Class.forName(mergeScheduler).asSubclass(MergeScheduler.class).newInstance());
+      } catch (Exception e) {
+        throw new RuntimeException("unable to instantiate class '" + mergeScheduler + "'
as merge scheduler", e);
       }
-      v = config.get("concurrent.merge.scheduler.max.merge.count", -1);
-      if (v != -1) {
-        cms.setMaxMergeCount(v);
+      
+      if (mergeScheduler.equals("org.apache.lucene.index.ConcurrentMergeScheduler")) {
+        ConcurrentMergeScheduler cms = (ConcurrentMergeScheduler) writer.getMergeScheduler();
+        int v = config.get("concurrent.merge.scheduler.max.thread.count", -1);
+        if (v != -1) {
+          cms.setMaxThreadCount(v);
+        }
+        v = config.get("concurrent.merge.scheduler.max.merge.count", -1);
+        if (v != -1) {
+          cms.setMaxMergeCount(v);
+        }
       }
     }
 
     final String mergePolicy = config.get("merge.policy",
                                           "org.apache.lucene.index.LogByteSizeMergePolicy");
-    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);
+    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(isCompound);
+      writer.setMergeFactor(config.get("merge.factor",OpenIndexTask.DEFAULT_MERGE_PFACTOR));
     }
-
-    writer.setUseCompoundFile(config.get("compound",true));
-    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);

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=931502&r1=931501&r2=931502&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
Wed Apr  7 11:03:32 2010
@@ -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
     Properties props = new Properties();
     props.setProperty("print.props", "false"); // don't print anything
     props.setProperty("directory", "RAMDirectory");
-    props.setProperty("writer.info.stream", infoStreamValue);
+    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
     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();
+  }
+  
 }



Mime
View raw message