You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2013/05/02 07:33:54 UTC

svn commit: r1478273 - in /lucene/dev/trunk/lucene: CHANGES.txt benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTask.java benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTaskTest.java

Author: shaie
Date: Thu May  2 05:33:53 2013
New Revision: 1478273

URL: http://svn.apache.org/r1478273
Log:
LUCENE-4974: CommitIndexTask broken if no params are set

Added:
    lucene/dev/trunk/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTaskTest.java   (with props)
Modified:
    lucene/dev/trunk/lucene/CHANGES.txt
    lucene/dev/trunk/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTask.java

Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=1478273&r1=1478272&r2=1478273&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Thu May  2 05:33:53 2013
@@ -76,6 +76,8 @@ Bug Fixes
 * LUCENE-4970: Fix boost value of rewritten NGramPhraseQuery.
   (Shingo Sasaki via Adrien Grand)
 
+* LUCENE-4974: CommitIndexTask was broken if no params were set. (Shai Erera)
+
 Optimizations
 
 * LUCENE-4938: Don't use an unnecessarily large priority queue in IndexSearcher

Modified: lucene/dev/trunk/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTask.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTask.java?rev=1478273&r1=1478272&r2=1478273&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTask.java (original)
+++ lucene/dev/trunk/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTask.java Thu May  2 05:33:53 2013
@@ -1,4 +1,5 @@
 package org.apache.lucene.benchmark.byTask.tasks;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -49,7 +50,9 @@ public class CommitIndexTask extends Per
   public int doLogic() throws Exception {
     IndexWriter iw = getRunData().getIndexWriter();
     if (iw != null) {
-      iw.setCommitData(commitUserData);
+      if (commitUserData != null) {
+        iw.setCommitData(commitUserData);
+      }
       iw.commit();
     }
     

Added: lucene/dev/trunk/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTaskTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTaskTest.java?rev=1478273&view=auto
==============================================================================
--- lucene/dev/trunk/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTaskTest.java (added)
+++ lucene/dev/trunk/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTaskTest.java Thu May  2 05:33:53 2013
@@ -0,0 +1,58 @@
+package org.apache.lucene.benchmark.byTask.tasks;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+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.SegmentInfos;
+
+/** Tests the functionality of {@link CreateIndexTask}. */
+public class CommitIndexTaskTest extends BenchmarkTestCase {
+
+  private PerfRunData createPerfRunData() throws Exception {
+    Properties props = new Properties();
+    props.setProperty("writer.version", TEST_VERSION_CURRENT.toString());
+    props.setProperty("print.props", "false"); // don't print anything
+    props.setProperty("directory", "RAMDirectory");
+    Config config = new Config(props);
+    return new PerfRunData(config);
+  }
+
+  public void testNoParams() throws Exception {
+    PerfRunData runData = createPerfRunData();
+    new CreateIndexTask(runData).doLogic();
+    new CommitIndexTask(runData).doLogic();
+    new CloseIndexTask(runData).doLogic();
+  }
+  
+  public void testCommitData() throws Exception {
+    PerfRunData runData = createPerfRunData();
+    new CreateIndexTask(runData).doLogic();
+    CommitIndexTask task = new CommitIndexTask(runData);
+    task.setParams("params");
+    task.doLogic();
+    SegmentInfos infos = new SegmentInfos();
+    infos.read(runData.getDirectory());
+    assertEquals("params", infos.getUserData().get(OpenReaderTask.USER_DATA));
+    new CloseIndexTask(runData).doLogic();
+  }
+
+}