lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r888397 - in /lucene/java/branches/flex_1458: ./ contrib/regex/src/test/org/apache/lucene/search/regex/ src/java/org/apache/lucene/index/
Date Tue, 08 Dec 2009 13:47:10 GMT
Author: mikemccand
Date: Tue Dec  8 13:47:09 2009
New Revision: 888397

URL: http://svn.apache.org/viewvc?rev=888397&view=rev
Log:
LUCENE-2136 (on flex branch): optimization: if Multi/DirectoryReader only has a single reader,
delegate enums to it

Modified:
    lucene/java/branches/flex_1458/CHANGES.txt
    lucene/java/branches/flex_1458/contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DirectoryReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/MultiReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/ParallelReader.java

Modified: lucene/java/branches/flex_1458/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/CHANGES.txt?rev=888397&r1=888396&r2=888397&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/CHANGES.txt (original)
+++ lucene/java/branches/flex_1458/CHANGES.txt Tue Dec  8 13:47:09 2009
@@ -50,6 +50,11 @@
   lots of seeking (Mike McCandless, Uwe Schindler, Robert Muir, Yonik
   Seeley)
 
+* LUCENE-2136: If the multi reader (DirectoryReader or MultiReader)
+  only has a single sub-reader, delegate all enum requests to it.
+  This avoid the overhead of using a PQ unecessarily.  (Mike
+  McCandless)
+
 Build
 
 Test Cases

Modified: lucene/java/branches/flex_1458/contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java?rev=888397&r1=888396&r2=888397&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
(original)
+++ lucene/java/branches/flex_1458/contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
Tue Dec  8 13:47:09 2009
@@ -83,7 +83,6 @@
   public void testMatchAll() throws Exception {
     RegexTermsEnum terms = (RegexTermsEnum) new RegexQuery(new Term(FN, "jum.")).getTermsEnum(searcher.getIndexReader());
     // no term should match
-    assertNull(terms.term());
     assertNull(terms.next());
   }
 

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DirectoryReader.java?rev=888397&r1=888396&r2=888397&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DirectoryReader.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DirectoryReader.java Tue
Dec  8 13:47:09 2009
@@ -763,10 +763,15 @@
     ensureOpen();
     return new MultiTermDocs(this, subReaders, starts);
   }
-  
+
   @Override
   public Fields fields() throws IOException {
-    return fields;
+    if (subReaders.length == 1) {
+      // Optimize the single reader case
+      return subReaders[0].fields();
+    } else {
+      return fields;
+    }
   }
 
   @Override

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/MultiReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/MultiReader.java?rev=888397&r1=888396&r2=888397&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/MultiReader.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/MultiReader.java Tue Dec
 8 13:47:09 2009
@@ -103,7 +103,12 @@
 
   @Override
   public Fields fields() throws IOException {
-    return fields;
+    if (subReaders.length == 1) {
+      // Optimize the single reader case
+      return subReaders[0].fields();
+    } else {
+      return fields;
+    }
   }
 
   /**

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/ParallelReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/ParallelReader.java?rev=888397&r1=888396&r2=888397&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/ParallelReader.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/ParallelReader.java Tue
Dec  8 13:47:09 2009
@@ -151,7 +151,12 @@
     @Override
     public TermsEnum terms() throws IOException {
       assert currentReader != null;
-      return currentReader.fields().terms(currentField).iterator();
+      Terms terms = currentReader.fields().terms(currentField);
+      if (terms != null) {
+        return terms.iterator();
+      } else {
+        return null;
+      }
     }
   }
 



Mime
View raw message