Index: contrib/benchmark/CHANGES.txt
===================================================================
--- contrib/benchmark/CHANGES.txt (revision 800002)
+++ contrib/benchmark/CHANGES.txt (working copy)
@@ -4,6 +4,15 @@
$Id:$
+8/03/2009
+ LUCENE-1778: Add support for log.step setting per task type. Perviously, if
+ you included a log.step line in the .alg file, it had been applied to all
+ tasks. Now, you can include a log.step.AddDoc, or log.step.DeleteDoc (for
+ example) to control logging for just these tasks. If you want to ommit logging
+ for any other task, include log.step=-1. The syntax is "log.step." together
+ with the Task's 'short' name (i.e., without the 'Task' part).
+ (Shai Erera via Mark Miller)
+
7/24/2009
LUCENE-1595: Deprecate LineDocMaker and EnwikiDocMaker in favor of
using DocMaker directly, with content.source = LineDocSource or
Index: contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/DeleteDocTask.java
===================================================================
--- contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/DeleteDocTask.java (revision 800002)
+++ contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/DeleteDocTask.java (working copy)
@@ -1,7 +1,5 @@
package org.apache.lucene.benchmark.byTask.tasks;
-import org.apache.lucene.benchmark.byTask.PerfRunData;
-
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -19,12 +17,11 @@
* limitations under the License.
*/
+import org.apache.lucene.benchmark.byTask.PerfRunData;
+
/**
- * Delete a document by docid.
- *
Other side effects: none.
- *
Relevant properties: doc.delete.step, delete.log.step.
- *
If no docid param is supplied, deletes doc with id = last-deleted-doc + doc.delete.step.
- *
Takes optional param: document id.
+ * Delete a document by docid. If no docid param is supplied, deletes doc with
+ * id = last-deleted-doc + doc.delete.step.
*/
public class DeleteDocTask extends PerfTask {
@@ -35,11 +32,6 @@
public DeleteDocTask(PerfRunData runData) {
super(runData);
- // Override log.step, which is read by PerfTask
- int deleteLogStep = runData.getConfig().get("delete.log.step", -1);
- if (deleteLogStep != -1) {
- logStep = deleteLogStep;
- }
}
private int deleteStep = -1;
Index: contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/PerfTask.java
===================================================================
--- contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/PerfTask.java (revision 800002)
+++ contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/PerfTask.java (working copy)
@@ -31,11 +31,23 @@
* {@link #doLogic()} method, which performss the actual task.
* Tasks performing some work that should be measured for the task, can overide
* {@link #setup()} and/or {@link #tearDown()} and place that work there.
- * Relevant properties: task.max.depth.log.
+ * Relevant properties: task.max.depth.log.
+ * Also supports the following logging attributes:
+ *
+ * - log.step - specifies how often to log messages about the current running
+ * task. Default is 1000 {@link #doLogic()} invocations. Set to -1 to disable
+ * logging.
+ *
- log.step.[class Task Name] - specifies the same as 'log.step', only for a
+ * particular task name. For example, log.step.AddDoc will be applied only for
+ * {@link AddDocTask}, but not for {@link DeleteDocTask}. It's a way to control
+ * per task logging settings. If you want to ommit logging for any other task,
+ * include log.step=-1. The syntax is "log.step." together with the Task's
+ * 'short' name (i.e., without the 'Task' part).
+ *
*/
public abstract class PerfTask implements Cloneable {
- private static final int DEFAULT_LOG_STEP = 1000;
+ static final int DEFAULT_LOG_STEP = 1000;
private PerfRunData runData;
@@ -66,14 +78,14 @@
private void checkObsoleteSettings(Config config) {
if (config.get("doc.add.log.step", null) != null) {
throw new RuntimeException("doc.add.log.step is not supported anymore. " +
- "Use log.step and refer to CHANGES to read on the recent API changes " +
- "done to Benchmark's DocMaker and Task-based logging.");
+ "Use log.step.AddDoc and refer to CHANGES to read on the recent " +
+ "API changes done to Benchmark's DocMaker and Task-based logging.");
}
if (config.get("doc.delete.log.step", null) != null) {
throw new RuntimeException("doc.delete.log.step is not supported anymore. " +
- "Use delete.log.step and refer to CHANGES to read on the recent API changes " +
- "done to Benchmark's DocMaker and Task-based logging.");
+ "Use log.step.DeleteDoc and refer to CHANGES to read on the recent " +
+ "API changes done to Benchmark's DocMaker and Task-based logging.");
}
}
@@ -82,7 +94,21 @@
this.runData = runData;
Config config = runData.getConfig();
this.maxDepthLogStart = config.get("task.max.depth.log",0);
- logStep = config.get("log.step", DEFAULT_LOG_STEP);
+
+ String logStepAtt = "log.step";
+ // TODO (1.5): call getClass().getSimpleName() instead.
+ String taskName = getClass().getName();
+ int idx = taskName.lastIndexOf('.');
+ // To support test internal classes. when we move to getSimpleName, this can be removed.
+ int idx2 = taskName.indexOf('$', idx);
+ if (idx2 != -1) idx = idx2;
+ String taskLogStepAtt = "log.step." + taskName.substring(idx + 1, taskName.length() - 4 /* w/o the 'Task' part */);
+ if (config.get(taskLogStepAtt, null) != null) {
+ logStepAtt = taskLogStepAtt;
+ }
+
+ // It's important to read this from Config, to support vals-by-round.
+ logStep = config.get(logStepAtt, DEFAULT_LOG_STEP);
// To avoid the check 'if (logStep > 0)' in tearDown(). This effectively
// turns logging off.
if (logStep <= 0) {
Index: contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/PerfTaskTest.java
===================================================================
--- contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/PerfTaskTest.java (revision 0)
+++ contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/PerfTaskTest.java (revision 0)
@@ -0,0 +1,72 @@
+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;
+
+/** Tests the functionality of the abstract {@link PerfTask}. */
+public class PerfTaskTest extends BenchmarkTestCase {
+
+ private static final class MyPerfTask extends PerfTask {
+
+ public MyPerfTask(PerfRunData runData) {
+ super(runData);
+ }
+
+ public int doLogic() throws Exception {
+ return 0;
+ }
+
+ public int getLogStep() { return logStep; }
+
+ }
+
+ private PerfRunData createPerfRunData(boolean setLogStep, int logStepVal,
+ boolean setTaskLogStep, int taskLogStepVal) throws Exception {
+ Properties props = new Properties();
+ if (setLogStep) {
+ props.setProperty("log.step", Integer.toString(logStepVal));
+ }
+ if (setTaskLogStep) {
+ props.setProperty("log.step.MyPerf", Integer.toString(taskLogStepVal));
+ }
+ props.setProperty("directory", "RAMDirectory"); // no accidental FS dir.
+ Config config = new Config(props);
+ return new PerfRunData(config);
+ }
+
+ private void doLogStepTest(boolean setLogStep, int logStepVal,
+ boolean setTaskLogStep, int taskLogStepVal, int expLogStepValue) throws Exception {
+ PerfRunData runData = createPerfRunData(setLogStep, logStepVal, setTaskLogStep, taskLogStepVal);
+ MyPerfTask mpt = new MyPerfTask(runData);
+ assertEquals(expLogStepValue, mpt.getLogStep());
+ }
+
+ public void testLogStep() throws Exception {
+ doLogStepTest(false, -1, false, -1, PerfTask.DEFAULT_LOG_STEP);
+ doLogStepTest(true, -1, false, -1, Integer.MAX_VALUE);
+ doLogStepTest(true, 100, false, -1, 100);
+ doLogStepTest(false, -1, true, -1, Integer.MAX_VALUE);
+ doLogStepTest(false, -1, true, 100, 100);
+ }
+
+}
Property changes on: contrib\benchmark\src\test\org\apache\lucene\benchmark\byTask\tasks\PerfTaskTest.java
___________________________________________________________________
Added: svn:keywords
+ Date Author Id Revision HeadURL
Added: svn:eol-style
+ native