You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by yo...@apache.org on 2010/05/04 22:39:38 UTC

svn commit: r941029 - in /lucene/dev/trunk/solr: CHANGES.txt src/java/org/apache/solr/request/SimpleFacets.java

Author: yonik
Date: Tue May  4 20:39:38 2010
New Revision: 941029

URL: http://svn.apache.org/viewvc?rev=941029&view=rev
Log:
SOLR-1904: use HashDocSet.exists in facet.enum

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/src/java/org/apache/solr/request/SimpleFacets.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=941029&r1=941028&r2=941029&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Tue May  4 20:39:38 2010
@@ -167,6 +167,9 @@ Optimizations
   the "threads" local param on the facet.field param.  This algorithm will
   only be faster in the presence of rapid index changes.  (yonik)
 
+* SOLR-1904: When facet.enum.cache.minDf > 0 and the base doc set is a
+  SortedIntSet, convert to HashDocSet for better performance. (yonik)
+
 Bug Fixes
 ----------------------
 

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/request/SimpleFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/request/SimpleFacets.java?rev=941029&r1=941028&r2=941029&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/request/SimpleFacets.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/request/SimpleFacets.java Tue May  4 20:39:38 2010
@@ -493,6 +493,14 @@ public class SimpleFacets {
     // Minimum term docFreq in order to use the filterCache for that term.
     int minDfFilterCache = params.getFieldInt(field, FacetParams.FACET_ENUM_CACHE_MINDF, 0);
 
+    // make sure we have a set that is fast for random access, if we will use it for that
+    DocSet fastForRandomSet = docs;
+    if (minDfFilterCache>0 && docs instanceof SortedIntDocSet) {
+      SortedIntDocSet sset = (SortedIntDocSet)docs;
+      fastForRandomSet = new HashDocSet(sset.getDocs(), 0, sset.size());
+    }
+
+
     IndexSchema schema = searcher.getSchema();
     IndexReader r = searcher.getReader();
     FieldType ft = schema.getFieldType(field);
@@ -576,7 +584,7 @@ public class SimpleFacets {
               int[] docArr = bulk.docs.ints;  // this might be movable outside the loop, but perhaps not worth the risk.
               int end = bulk.docs.offset + nDocs;
               for (int i=bulk.docs.offset; i<end; i++) {
-                if (docs.exists(docArr[i])) c++;
+                if (fastForRandomSet.exists(docArr[i])) c++;
               }
             }
           }