diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/LineDocMaker.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/LineDocMaker.java index d737f4d013c..7539b9ee46c 100644 --- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/LineDocMaker.java +++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/LineDocMaker.java @@ -85,10 +85,18 @@ public class LineDocMaker extends BasicDocMaker { public Document setFields(String line) { // title date body int spot = line.indexOf(SEP); - titleField.setValue(line.substring(0, spot)); - int spot2 = line.indexOf(SEP, 1+spot); - dateField.setValue(line.substring(1+spot, spot2)); - bodyField.setValue(line.substring(1+spot2, line.length())); + if (spot != -1) { + titleField.setValue(line.substring(0, spot)); + int spot2 = line.indexOf(SEP, 1+spot); + if (spot2 != -1) { + dateField.setValue(line.substring(1+spot, spot2)); + bodyField.setValue(line.substring(1+spot2, line.length())); + } else { + dateField.setValue(""); + bodyField.setValue(""); + } + } else + titleField.setValue(""); return doc; } } @@ -121,12 +129,10 @@ public class LineDocMaker extends BasicDocMaker { while(true) { line = fileIn.readLine(); if (line == null) { + // Reset the file + openFile(); if (!forever) throw new NoMoreDataException(); - else { - // Reset the file - openFile(); - } } else { break; } diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.java index eb72ff4984b..2386049678a 100644 --- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.java +++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.java @@ -57,12 +57,8 @@ public class CreateIndexTask extends PerfTask { iw.setUseCompoundFile(cmpnd); iw.setMergeFactor(mrgf); iw.setMaxFieldLength(mxfl); - if (flushAtRAMUsage > 0) - iw.setRAMBufferSizeMB(flushAtRAMUsage); - else if (mxbf != 0) - iw.setMaxBufferedDocs(mxbf); - else - throw new RuntimeException("either max.buffered or ram.flush.mb must be non-zero"); + iw.setRAMBufferSizeMB(flushAtRAMUsage); + iw.setMaxBufferedDocs(mxbf); getRunData().setIndexWriter(iw); return 1; } diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/OpenIndexTask.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/OpenIndexTask.java index 4d4910a7d04..e650fa3f93a 100644 --- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/OpenIndexTask.java +++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/OpenIndexTask.java @@ -61,12 +61,8 @@ public class OpenIndexTask extends PerfTask { IndexWriter writer = new IndexWriter(dir, autoCommit, analyzer, false); // must update params for newly opened writer - if (flushAtRAMUsage > 0) - writer.setRAMBufferSizeMB(flushAtRAMUsage); - else if (mxbf != 0) - writer.setMaxBufferedDocs(mxbf); - else - throw new RuntimeException("either max.buffered or ram.flush.mb must be non-zero"); + writer.setRAMBufferSizeMB(flushAtRAMUsage); + writer.setMaxBufferedDocs(mxbf); writer.setMaxFieldLength(mxfl); writer.setMergeFactor(mrgf); writer.setUseCompoundFile(cmpnd); // this one redundant? diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java index df88b7eb0ba..1136c904096 100644 --- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java +++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java @@ -38,6 +38,8 @@ public class TaskSequence extends PerfTask { private String seqName; private boolean exhausted = false; private boolean resetExhausted = false; + private PerfTask[] tasksArray; + private boolean anyExhaustableTasks; public TaskSequence (PerfRunData runData, String name, TaskSequence parent, boolean parallel) { super(runData); @@ -49,6 +51,18 @@ public class TaskSequence extends PerfTask { tasks = new ArrayList(); } + private void initTasksArray() { + if (tasksArray == null) { + final int numTasks = tasks.size(); + tasksArray = new PerfTask[numTasks]; + for(int k=0;k 0) { //System.out.println("wait: "+waitMore+" for rate: "+ratePerMin+" (delayStep="+delayStep+")"); @@ -135,7 +148,8 @@ public class TaskSequence extends PerfTask { nextStartTime += delayStep; // this aims at avarage rate. try { count += task.runAndMaybeStats(letChildReport); - updateExhausted(task); + if (anyExhaustableTasks) + updateExhausted(task); } catch (NoMoreDataException e) { exhausted = true; } @@ -149,28 +163,27 @@ public class TaskSequence extends PerfTask { if (task instanceof ResetInputsTask) { exhausted = false; resetExhausted = true; - } else { - if (task instanceof TaskSequence) { - TaskSequence t = (TaskSequence) task; - if (t.resetExhausted) { - exhausted = false; - resetExhausted = true; - t.resetExhausted = false; - } else { - exhausted |= t.exhausted; - } + } else if (task instanceof TaskSequence) { + TaskSequence t = (TaskSequence) task; + if (t.resetExhausted) { + exhausted = false; + resetExhausted = true; + t.resetExhausted = false; + } else { + exhausted |= t.exhausted; } } } private int doParallelTasks() throws Exception { + initTasksArray(); final int count [] = {0}; Thread t[] = new Thread [repetitions * tasks.size()]; // prepare threads int indx = 0; for (int k=0; k : * ", + " CloseIndex", + "} : 2", + }; + + // 2. execute the algorithm (required in every "logic" test) + Benchmark benchmark = execBenchmark(algLines); + + // 3. test number of docs in the index + IndexReader ir = IndexReader.open(benchmark.getRunData().getDirectory()); + int ndocsExpected = 20; // Reuters20DocMaker exhausts after 20 docs. + assertEquals("wrong number of docs in the index!", ndocsExpected, ir.numDocs()); + ir.close(); + } }