lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r881984 - /lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java
Date Wed, 18 Nov 2009 23:01:06 GMT
Author: uschindler
Date: Wed Nov 18 23:01:05 2009
New Revision: 881984

URL: http://svn.apache.org/viewvc?rev=881984&view=rev
Log:
remove unneeded TermGenerator in MTQWF (no longer Filter.bits()). This is a small speed improvement.
I will apply this to 3.0, too, if a new RC comes.

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java?rev=881984&r1=881983&r2=881984&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java Wed
Nov 18 23:01:05 2009
@@ -93,9 +93,20 @@
   public void clearTotalNumberOfTerms() {
     query.clearTotalNumberOfTerms();
   }
-
-  abstract class TermGenerator {
-    public void generate(IndexReader reader, TermEnum enumerator) throws IOException {
+  
+  /**
+   * Returns a DocIdSet with documents that should be
+   * permitted in search results.
+   */
+  @Override
+  public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
+    final TermEnum enumerator = query.getEnum(reader);
+    try {
+      // if current term in enum is null, the enum is empty -> shortcut
+      if (enumerator.term() == null)
+        return DocIdSet.EMPTY_DOCIDSET;
+      // else fill into a OpenBitSet
+      final OpenBitSet bitSet = new OpenBitSet(reader.maxDoc());
       final int[] docs = new int[32];
       final int[] freqs = new int[32];
       TermDocs termDocs = reader.termDocs();
@@ -111,7 +122,7 @@
             final int count = termDocs.read(docs, freqs);
             if (count != 0) {
               for(int i=0;i<count;i++) {
-                handleDoc(docs[i]);
+                bitSet.set(docs[i]);
               }
             } else {
               break;
@@ -124,29 +135,6 @@
       } finally {
         termDocs.close();
       }
-    }
-    abstract public void handleDoc(int doc);
-  }
-  
-  /**
-   * Returns a DocIdSet with documents that should be
-   * permitted in search results.
-   */
-  @Override
-  public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
-    final TermEnum enumerator = query.getEnum(reader);
-    try {
-      // if current term in enum is null, the enum is empty -> shortcut
-      if (enumerator.term() == null)
-        return DocIdSet.EMPTY_DOCIDSET;
-      // else fill into a OpenBitSet
-      final OpenBitSet bitSet = new OpenBitSet(reader.maxDoc());
-      new TermGenerator() {
-        @Override
-        public void handleDoc(int doc) {
-          bitSet.set(doc);
-        }
-      }.generate(reader, enumerator);
       return bitSet;
     } finally {
       enumerator.close();



Mime
View raw message