cpoerschke commented on code in PR #2248:
URL: https://github.com/apache/solr/pull/2248#discussion_r1689870031


##########
solr/core/src/java/org/apache/solr/search/MultiThreadedSearcher.java:
##########
@@ -0,0 +1,423 @@
+/*
+ * 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.Iterator;
+import java.util.LinkedList;
+import java.util.concurrent.ExecutionException;
+import java.util.function.Supplier;
+import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.Collector;
+import org.apache.lucene.search.CollectorManager;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.QueryVisitor;
+import org.apache.lucene.search.ScoreMode;
+import org.apache.lucene.search.SimpleCollector;
+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.lucene.util.automaton.ByteRunAutomaton;
+import org.apache.solr.search.join.GraphQuery;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MultiThreadedSearcher {
+  private static final Logger log = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+  final SolrIndexSearcher searcher;
+
+  public MultiThreadedSearcher(SolrIndexSearcher searcher) {
+    this.searcher = searcher;
+  }
+
+  SearchResult searchCollectorManagers(
+      int len,
+      QueryCommand cmd,
+      Query query,
+      boolean needTopDocs,
+      boolean needMaxScore,
+      boolean needDocSet)
+      throws IOException {
+    Collection<CollectorManager<Collector, Object>> collectors = new 
ArrayList<>();
+
+    int firstCollectorsSize = 0;
+
+    final int firstTopDocsCollectorIndex;
+    if (needTopDocs) {
+      firstTopDocsCollectorIndex = firstCollectorsSize;
+      firstCollectorsSize++;
+    } else {
+      firstTopDocsCollectorIndex = -1;
+    }
+
+    final int firstMaxScoreCollectorIndex;
+    if (needMaxScore) {
+      firstMaxScoreCollectorIndex = firstCollectorsSize;
+      firstCollectorsSize++;
+    } else {
+      firstMaxScoreCollectorIndex = -1;
+    }
+
+    Collector[] firstCollectors = new Collector[firstCollectorsSize];
+
+    if (needTopDocs) {
+
+      collectors.add(new TopDocsCM(len, cmd, firstCollectors, 
firstTopDocsCollectorIndex));
+    }
+    if (needMaxScore) {
+      collectors.add(new MaxScoreCM(firstCollectors, 
firstMaxScoreCollectorIndex));
+    }
+    if (needDocSet) {
+      int maxDoc = searcher.getRawReader().maxDoc();
+      log.error("raw read max={}", searcher.getRawReader().maxDoc());

Review Comment:
   Am unclear on why we log an error here. Also since the overall bit set is 
now computed as union of per-segment bit sets, perhaps there is no need to 
'know' the max doc and it could be computed from the per-segment bit sets?



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