lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r833763 - in /lucene/java/trunk/contrib/benchmark: CHANGES.txt src/java/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTask.java
Date Sat, 07 Nov 2009 21:11:42 GMT
Author: mikemccand
Date: Sat Nov  7 21:11:42 2009
New Revision: 833763

URL: http://svn.apache.org/viewvc?rev=833763&view=rev
Log:
LUCENE-2043: CommitIndexTask also commits pending changes in the open IndexReader

Modified:
    lucene/java/trunk/contrib/benchmark/CHANGES.txt
    lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTask.java

Modified: lucene/java/trunk/contrib/benchmark/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/CHANGES.txt?rev=833763&r1=833762&r2=833763&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/CHANGES.txt (original)
+++ lucene/java/trunk/contrib/benchmark/CHANGES.txt Sat Nov  7 21:11:42 2009
@@ -5,6 +5,10 @@
 $Id:$
 
 11/07/2009
+  LUCENE-2043: Fix CommitIndexTask to also commit pending IndexReader
+  changes (Mike McCandless)
+
+11/07/2009
   LUCENE-2042: Added print.hits.field, to print each hit from the
   Search* tasks.  (Mike McCandless)
 

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTask.java?rev=833763&r1=833762&r2=833763&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTask.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTask.java
Sat Nov  7 21:11:42 2009
@@ -21,14 +21,15 @@
 
 import org.apache.lucene.benchmark.byTask.PerfRunData;
 import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexReader;
 
 /**
  * Commits the IndexWriter.
  *
  */
 public class CommitIndexTask extends PerfTask {
-  String commitUserData = null;
-  
+  Map<String,String> commitUserData;
+
   public CommitIndexTask(PerfRunData runData) {
     super(runData);
   }
@@ -38,17 +39,20 @@
   }
   
   public void setParams(String params) {
-    commitUserData = params;
+    commitUserData = new HashMap<String,String>();
+    commitUserData.put(OpenReaderTask.USER_DATA, params);
   }
   
   public int doLogic() throws Exception {
     IndexWriter iw = getRunData().getIndexWriter();
     if (iw != null) {
-      if (commitUserData == null) iw.commit();
-      else {
-        Map<String,String> map = new HashMap<String,String>();
-        map.put(OpenReaderTask.USER_DATA, commitUserData);
-        iw.commit(map);
+      iw.commit(commitUserData);
+    } else {
+      IndexReader r = getRunData().getIndexReader();
+      if (r != null) {
+        r.commit(commitUserData);
+      } else {
+        throw new IllegalStateException("neither IndexWriter nor IndexReader is currently
open");
       }
     }
     



Mime
View raw message