lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gsing...@apache.org
Subject svn commit: r693495 - in /lucene/java/trunk/contrib/benchmark: ./ conf/ src/java/org/apache/lucene/benchmark/byTask/feeds/ src/java/org/apache/lucene/benchmark/byTask/tasks/
Date Tue, 09 Sep 2008 15:56:42 GMT
Author: gsingers
Date: Tue Sep  9 08:56:41 2008
New Revision: 693495

URL: http://svn.apache.org/viewvc?rev=693495&view=rev
Log:
LUCENE-1243: Added new benchmark tasks

Added:
    lucene/java/trunk/contrib/benchmark/conf/sort-standard.alg
    lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/SortableSimpleDocMaker.java
  (with props)
    lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTask.java
  (with props)
    lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReopenReaderTask.java
  (with props)
    lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchWithSortTask.java
  (with props)
Modified:
    lucene/java/trunk/contrib/benchmark/CHANGES.txt
    lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java

Modified: lucene/java/trunk/contrib/benchmark/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/CHANGES.txt?rev=693495&r1=693494&r2=693495&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/CHANGES.txt (original)
+++ lucene/java/trunk/contrib/benchmark/CHANGES.txt Tue Sep  9 08:56:41 2008
@@ -4,6 +4,9 @@
 
 $Id:$
 
+9/9/08
+ LUCENE-1243: Added new sorting benchmark capabilities.  Also Reopen and commit tasks.  (Mark
Miller via Grant Ingersoll)
+
 5/10/08
   LUCENE-1090: remove relative paths assumptions from benchmark code.
   Only build.xml was modified: work-dir definition must remain so  

Added: lucene/java/trunk/contrib/benchmark/conf/sort-standard.alg
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/conf/sort-standard.alg?rev=693495&view=auto
==============================================================================
--- lucene/java/trunk/contrib/benchmark/conf/sort-standard.alg (added)
+++ lucene/java/trunk/contrib/benchmark/conf/sort-standard.alg Tue Sep  9 08:56:41 2008
@@ -0,0 +1,71 @@
+#/**
+# * 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.
+# */
+# -------------------------------------------------------------------------------------
+# multi val params are iterated by NewRound's, added to reports, start with column name.
+
+merge.factor=mrg:50
+compound=false
+
+sort.rng=20000:10000:20000:10000
+
+analyzer=org.apache.lucene.analysis.standard.StandardAnalyzer
+directory=FSDirectory
+#directory=RamDirectory
+
+doc.stored=true
+doc.tokenized=true
+doc.term.vector=false
+doc.add.log.step=100000
+
+docs.dir=reuters-out
+
+doc.maker=org.apache.lucene.benchmark.byTask.feeds.SortableSimpleDocMaker
+
+query.maker=org.apache.lucene.benchmark.byTask.feeds.SimpleQueryMaker
+
+# task at this depth or less would print when they start
+task.max.depth.log=2
+
+log.queries=true
+# -------------------------------------------------------------------------------------
+
+{ "Rounds"
+	{ "Run"
+      ResetSystemErase
+
+      { "Populate"
+        -CreateIndex
+        { "MAddDocs" AddDoc(100) > : 500000
+        -Optimize
+        -CloseIndex
+      }
+    
+      { "TestSortSpeed"
+        OpenReader  
+        { "LoadFieldCacheAndSearch" SearchWithSort(sort_field:int) > : 1 
+        { "SearchWithSort" SearchWithSort(sort_field) > : 5000
+        CloseReader 
+      
+      }
+    
+      NewRound
+     } : 4
+
+} 
+
+RepSumByName
+

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/SortableSimpleDocMaker.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/SortableSimpleDocMaker.java?rev=693495&view=auto
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/SortableSimpleDocMaker.java
(added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/SortableSimpleDocMaker.java
Tue Sep  9 08:56:41 2008
@@ -0,0 +1,38 @@
+package org.apache.lucene.benchmark.byTask.feeds;
+
+import java.util.Properties;
+import java.util.Random;
+
+import org.apache.lucene.benchmark.byTask.utils.Config;
+
+/**
+ * Adds fields appropriate for sorting.
+ * 
+ */
+public class SortableSimpleDocMaker extends SimpleDocMaker {
+  private int sortRange;
+
+  protected DocData getNextDocData() throws NoMoreDataException {
+    DocData doc = super.getNextDocData();
+    Properties props = new Properties();
+    props.put("sort_field", Integer.toString(getRandomNumber(0, sortRange)));
+    doc.setProps(props);
+    return doc;
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see SimpleDocMaker#setConfig(java.util.Properties)
+   */
+  public void setConfig(Config config) {
+    super.setConfig(config);
+    sortRange = config.get("sort.rng", 20000);
+  }
+
+  private int getRandomNumber(final int low, final int high) {
+    Random r = new Random();
+    int randInt = (Math.abs(r.nextInt()) % (high - low)) + low;
+    return randInt;
+  }
+}

Propchange: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/SortableSimpleDocMaker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 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=693495&view=auto
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTask.java
(added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTask.java
Tue Sep  9 08:56:41 2008
@@ -0,0 +1,39 @@
+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 org.apache.lucene.benchmark.byTask.PerfRunData;
+import org.apache.lucene.index.IndexWriter;
+
+/**
+ * Commits the IndexReader.
+ *
+ */
+public class CommitIndexTask extends PerfTask {
+  public CommitIndexTask(PerfRunData runData) {
+    super(runData);
+  }
+
+  public int doLogic() throws Exception {
+    IndexWriter iw = getRunData().getIndexWriter();
+    if (iw!=null) {
+      iw.commit();
+    }
+    
+    return 1;
+  }
+}

Propchange: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CommitIndexTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java?rev=693495&r1=693494&r2=693495&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java
Tue Sep  9 08:56:41 2008
@@ -17,8 +17,15 @@
  * limitations under the License.
  */
 
-import org.apache.lucene.analysis.TokenStream;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
 import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.benchmark.byTask.PerfRunData;
 import org.apache.lucene.benchmark.byTask.feeds.QueryMaker;
 import org.apache.lucene.document.Document;
@@ -27,12 +34,14 @@
 import org.apache.lucene.search.Hits;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
-import org.apache.lucene.search.highlight.*;
+import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.highlight.Highlighter;
+import org.apache.lucene.search.highlight.QueryScorer;
+import org.apache.lucene.search.highlight.SimpleHTMLFormatter;
+import org.apache.lucene.search.highlight.TextFragment;
+import org.apache.lucene.search.highlight.TokenSources;
 import org.apache.lucene.store.Directory;
 
-import java.io.IOException;
-import java.util.*;
-
 
 /**
  * Read index (abstract) task.
@@ -79,7 +88,13 @@
       IndexSearcher searcher = new IndexSearcher(ir);
       QueryMaker queryMaker = getQueryMaker();
       Query q = queryMaker.makeQuery();
-      Hits hits = searcher.search(q);
+      Sort sort = getSort();
+      Hits hits;
+      if(sort != null) {
+        hits = searcher.search(q, sort);
+      } else {
+        hits = searcher.search(q);
+      }
       //System.out.println("searched: "+q);
 
       if (withTraverse() && hits != null) {
@@ -139,6 +154,7 @@
    * Return true if search should be performed.
    */
   public abstract boolean withSearch();
+  
 
   /**
    * Return true if warming should be performed.
@@ -200,6 +216,10 @@
     TextFragment[] frag = highlighter.getBestTextFragments(ts, text, mergeContiguous, maxFragments);
     return frag != null ? frag.length : 0;
   }
+  
+  protected Sort getSort() {
+    return null;
+  }
 
   /**
    * Define the fields to highlight.  Base implementation returns all fields

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReopenReaderTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReopenReaderTask.java?rev=693495&view=auto
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReopenReaderTask.java
(added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReopenReaderTask.java
Tue Sep  9 08:56:41 2008
@@ -0,0 +1,44 @@
+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.io.IOException;
+
+import org.apache.lucene.benchmark.byTask.PerfRunData;
+import org.apache.lucene.index.IndexReader;
+
+/**
+* Reopens IndexReader and closes old IndexReader.
+*
+*/
+public class ReopenReaderTask extends PerfTask {
+  public ReopenReaderTask(PerfRunData runData) {
+    super(runData);
+  }
+
+  public int doLogic() throws IOException {
+    IndexReader ir = getRunData().getIndexReader();
+    IndexReader or = ir;
+    IndexReader nr = ir.reopen();
+    if(nr != or) {
+      getRunData().setIndexReader(nr);
+      or.close();
+    }
+    return 1;
+  }
+}

Propchange: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReopenReaderTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchWithSortTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchWithSortTask.java?rev=693495&view=auto
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchWithSortTask.java
(added)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchWithSortTask.java
Tue Sep  9 08:56:41 2008
@@ -0,0 +1,109 @@
+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 org.apache.lucene.benchmark.byTask.PerfRunData;
+import org.apache.lucene.benchmark.byTask.feeds.QueryMaker;
+import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.SortField;
+
+/**
+ * Does sort search on specified field.
+ * 
+ */
+public class SearchWithSortTask extends ReadTask {
+
+  private Sort sort;
+
+  public SearchWithSortTask(PerfRunData runData) {
+    super(runData);
+  }
+
+  /**
+   * SortFields: field:type,field:type
+   * 
+   * name,byline:int,subject:auto
+   * 
+   */
+  public void setParams(String sortField) {
+    super.setParams(sortField);
+    String[] fields = sortField.split(",");
+    SortField[] sortFields = new SortField[fields.length];
+    for (int i = 0; i < fields.length; i++) {
+      String field = fields[i];
+      int index = field.lastIndexOf(":");
+      String fieldName;
+      String typeString;
+      if (index != -1) {
+        fieldName = field.substring(0, index);
+        typeString = field.substring(index, field.length());
+      } else {
+        typeString = "auto";
+        fieldName = field;
+      }
+      int type = getType(typeString);
+      sortFields[i] = new SortField(fieldName, type);
+    }
+    this.sort = new Sort(sortFields);
+  }
+
+  private int getType(String typeString) {
+    int type;
+    if (typeString.equals("float")) {
+      type = SortField.FLOAT;
+    } else if (typeString.equals("int")) {
+      type = SortField.INT;
+    } else if (typeString.equals("string")) {
+      type = SortField.STRING;
+    } else {
+      type = SortField.AUTO;
+    }
+    return type;
+  }
+
+  public boolean supportsParams() {
+    return true;
+  }
+
+  public QueryMaker getQueryMaker() {
+    return getRunData().getQueryMaker(this);
+  }
+
+  public boolean withRetrieve() {
+    return false;
+  }
+
+  public boolean withSearch() {
+    return true;
+  }
+
+  public boolean withTraverse() {
+    return false;
+  }
+
+  public boolean withWarm() {
+    return false;
+  }
+
+  public Sort getSort() {
+    if (sort == null) {
+      throw new IllegalStateException("No sort field was set");
+    }
+    return sort;
+  }
+
+}

Propchange: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchWithSortTask.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message