dsmiley commented on code in PR #4487:
URL: https://github.com/apache/solr/pull/4487#discussion_r3338900179


##########
solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java:
##########


Review Comment:
   surprisingly a net increase in LOC ... but more documentation so that's good



##########
solr/core/src/java/org/apache/solr/search/SolrCollectorManagers.java:
##########
@@ -0,0 +1,602 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.search;
+
+import java.io.IOException;
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.LongAdder;
+import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.search.Collector;
+import org.apache.lucene.search.CollectorManager;
+import org.apache.lucene.search.ScoreMode;
+import org.apache.lucene.search.SimpleCollector;
+import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.search.TopDocsCollector;
+import org.apache.lucene.search.TopFieldDocs;
+import org.apache.lucene.util.FixedBitSet;
+import org.apache.solr.core.CancellableQueryTracker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Holders for the {@link CollectorManager} implementations used by Solr's 
search paths. Shared
+ * across the single-slice and multi-slice (parallel-segment) execution paths.
+ */
+final class SolrCollectorManagers {
+
+  private SolrCollectorManagers() {}
+
+  static class MaxScoreResult {
+    final float maxScore;
+
+    MaxScoreResult(float maxScore) {
+      this.maxScore = maxScore;
+    }
+  }
+
+  static class TopDocsResult {
+    final TopDocs topDocs;
+    final int totalHits;
+
+    TopDocsResult(TopDocs topDocs, int totalHits) {
+      this.topDocs = topDocs;
+      this.totalHits = totalHits;
+    }
+  }
+
+  static class SearchResult {
+    final ScoreMode scoreMode;
+    private final Object[] result;
+
+    SearchResult(ScoreMode scoreMode, Object[] result) {
+      this.scoreMode = scoreMode;
+      this.result = result;
+    }
+
+    public TopDocsResult getTopDocsResult() {
+      for (Object res : result) {
+        if (res instanceof TopDocsResult) {
+          return (TopDocsResult) res;
+        }
+      }
+      return null;
+    }
+
+    public float getMaxScore(int totalHits) {
+      if (totalHits > 0) {
+        for (Object res : result) {
+          if (res instanceof MaxScoreResult) {
+            return ((MaxScoreResult) res).maxScore;
+          }
+        }
+        return Float.NaN;
+      } else {
+        return 0.0f;
+      }
+    }
+
+    public DocSet getDocSet() {
+      for (Object res : result) {
+        if (res instanceof DocSet) {
+          return (DocSet) res;
+        }
+        if (res instanceof FixedBitSet fbs) {
+          return new BitDocSet(fbs);
+        }
+      }
+      return null;
+    }
+  }
+
+  static class FixedBitSetCollector extends SimpleCollector {

Review Comment:
   could use a bit more docs/comments to explain what's going on



-- 
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