magibney commented on a change in pull request #592:
URL: https://github.com/apache/solr/pull/592#discussion_r799880606



##########
File path: solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
##########
@@ -866,8 +876,48 @@ public BitDocSet getLiveDocSet() throws IOException {
     // but the addition of setLiveDocs means we needed to add volatile to 
"liveDocs".
     BitDocSet docs = liveDocs;
     if (docs == null) {
-      //note: maybe should instead calc manually by segment, using 
FixedBitSet.copyOf(segLiveDocs); avoid filter cache?
-      liveDocs = docs = getDocSetBits(matchAllDocsQuery);
+      switch (leafContexts.size()) {
+        case 0:
+          assert numDocs() == 0;
+          docs = new BitDocSet(BitDocSet.empty().getFixedBitSet(), 0);
+          break;
+        case 1:
+          final Bits onlySegLiveDocs = 
leafContexts.get(0).reader().getLiveDocs();
+          final FixedBitSet fbs;
+          if (onlySegLiveDocs == null) {
+            final int onlySegMaxDoc = maxDoc();
+            fbs = new FixedBitSet(onlySegMaxDoc);
+            fbs.set(0, onlySegMaxDoc);
+          } else {
+            fbs = FixedBitSet.copyOf(onlySegLiveDocs);
+          }
+          assert fbs.cardinality() == numDocs();
+          docs = new BitDocSet(fbs, numDocs());
+          break;
+        default:
+          final FixedBitSet bs = new FixedBitSet(maxDoc());
+          for (LeafReaderContext ctx : leafContexts) {
+            final LeafReader r = ctx.reader();
+            final Bits segLiveDocs = r.getLiveDocs();
+            final int segDocBase = ctx.docBase;
+            int segOrd = r.maxDoc() - 1;
+            if (segLiveDocs == null) {
+              do {
+                bs.set(segDocBase + segOrd);

Review comment:
       :+1: ha! yeah, not sure why it occurred to me above, but not here.




-- 
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: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to