risdenk commented on code in PR #1184:
URL: https://github.com/apache/solr/pull/1184#discussion_r1026817305


##########
solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java:
##########
@@ -1211,17 +1211,28 @@ public ProcessedFilter getProcessedFilter(DocSet 
setFilter, List<Query> queries)
     }
 
     // Are all of our normal cached filters negative?
-    if (end > 0 && answer == null) {
-      answer = getLiveDocSet();
-    }
+    if (end > 0) {
+      if (answer == null) {
+        answer = getLiveDocSet();
+      }
 
-    // do negative queries first to shrink set size
-    for (int i = 0; i < end; i++) {
-      if (neg[i]) answer = answer.andNot(sets[i]);
-    }
+      // This optimizes for the case where we have more than 2 filters and 
instead
+      // of copying the bitsets we make one mutable bitset. We only need to do 
this
+      // for BitDocSet since it clones the backing bitset for andNot and 
intersection.
+      if (end > 1 && answer instanceof BitDocSet) {

Review Comment:
   the line 1214 is checking if `end > 0` - which was just an expansion of the 
previous if statement that was there. Previously `end > 0` was checked before 
updating `answer` only and then the for loops would skip since i = 0 and end = 
0 in that case. I wanted it to be clear - if `end <= 0` we don't need to do 
this whole block.
   
   The end > 1 here is to make sure we have 2 bitsets to work with?
   
   Unless I'm misunderstanding your command.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to