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/11/15 04:57:07 UTC

svn commit: r1035137 - /lucene/dev/trunk/solr/src/java/org/apache/solr/search/Grouping.java

Author: yonik
Date: Mon Nov 15 03:57:07 2010
New Revision: 1035137

URL: http://svn.apache.org/viewvc?rev=1035137&view=rev
Log:
SOLR-236: grouping - set bottom on the pq if changed

Modified:
    lucene/dev/trunk/solr/src/java/org/apache/solr/search/Grouping.java

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/search/Grouping.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/search/Grouping.java?rev=1035137&r1=1035136&r2=1035137&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/search/Grouping.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/search/Grouping.java Mon Nov 15 03:57:07 2010
@@ -555,16 +555,27 @@ class TopGroupCollector extends GroupCol
 
     // remove before updating the group since lookup is done via comparators
     // TODO: optimize this
-    if (orderedGroups != null)
+
+    SearchGroup prevLast = null;
+    if (orderedGroups != null) {
+      prevLast = orderedGroups.last();
       orderedGroups.remove(group);
+    }
 
     group.topDoc = docBase + doc;
     // group.topDocScore = scorer.score();
     int tmp = spareSlot; spareSlot = group.comparatorSlot; group.comparatorSlot=tmp;  // swap slots
 
     // re-add the changed group
-    if (orderedGroups != null)
+    if (orderedGroups != null) {
       orderedGroups.add(group);
+      SearchGroup newLast = orderedGroups.last();
+      // if we changed the value of the last group, or changed which group was last, then update bottom
+      if (group == newLast || prevLast != newLast) {
+        for (FieldComparator fc : comparators)
+          fc.setBottom(newLast.comparatorSlot);
+      }
+    }
   }
 
   void buildSet() {