You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2020/03/03 13:45:31 UTC
[GitHub] [lucene-solr] chatman opened a new pull request #1310: SOLR-13350:
Multithreaded search using collector managers
chatman opened a new pull request #1310: SOLR-13350: Multithreaded search using collector managers
URL: https://github.com/apache/lucene-solr/pull/1310
This is almost complete. Here, all queries are multi-threaded.
TODO: Implement a query time parameter (default: off) to enable multi-threaded searching.
Tests pass.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] dsmiley commented on a change in pull request #1310:
SOLR-13350: Multithreaded search using collector managers
Posted by GitBox <gi...@apache.org>.
dsmiley commented on a change in pull request #1310: SOLR-13350: Multithreaded search using collector managers
URL: https://github.com/apache/lucene-solr/pull/1310#discussion_r397828321
##########
File path: solr/core/src/java/org/apache/solr/core/CoreContainer.java
##########
@@ -353,6 +355,8 @@ public CoreContainer(NodeConfig config, Properties properties, CoresLocator loca
ExecutorUtil.newMDCAwareCachedThreadPool(
cfg.getReplayUpdatesThreads(),
new DefaultSolrThreadFactory("replayUpdatesExecutor")));
+ this.collectorExecutor = ExecutorUtil.newMDCAwareCachedThreadPool(cfg.getCollectorsPoolSize(),
+ new DefaultSolrThreadFactory("searcherCollectorExecutor"));
Review comment:
nit: maybe drop "Executor" in the name as it's not an interesting word. Shorter thread names.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] dsmiley commented on a change in pull request #1310:
SOLR-13350: Multithreaded search using collector managers
Posted by GitBox <gi...@apache.org>.
dsmiley commented on a change in pull request #1310: SOLR-13350: Multithreaded search using collector managers
URL: https://github.com/apache/lucene-solr/pull/1310#discussion_r397833643
##########
File path: solr/core/src/java/org/apache/solr/core/CoreContainer.java
##########
@@ -543,6 +547,7 @@ protected CoreContainer(Object testConstructor) {
cfg = null;
containerProperties = null;
replayUpdatesExecutor = null;
+ this.collectorExecutor = ExecutorUtil.newMDCAwareCachedThreadPool(new DefaultSolrThreadFactory("searcherCollectorExecutor"));
Review comment:
Wait; didn't you already initialize this?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] dsmiley commented on a change in pull request #1310:
SOLR-13350: Multithreaded search using collector managers
Posted by GitBox <gi...@apache.org>.
dsmiley commented on a change in pull request #1310: SOLR-13350: Multithreaded search using collector managers
URL: https://github.com/apache/lucene-solr/pull/1310#discussion_r397839456
##########
File path: lucene/core/src/java/org/apache/lucene/search/MultiCollector.java
##########
@@ -115,6 +116,11 @@ public ScoreMode scoreMode() {
return scoreMode;
}
+ // nocommit: need to raise a LUCENE jira for this?
+ public List<Collector> getCollectors() {
Review comment:
This change is small and simple enough that I suggest just at-mentioning one or two people you think would care about this to get their opinion if it's worth a separate JIRA, and separately if it's even worth a Lucene changes.txt entry. I think not worth it. Remember the higher javadoc standards :-)
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] dsmiley commented on a change in pull request #1310:
SOLR-13350: Multithreaded search using collector managers
Posted by GitBox <gi...@apache.org>.
dsmiley commented on a change in pull request #1310: SOLR-13350: Multithreaded search using collector managers
URL: https://github.com/apache/lucene-solr/pull/1310#discussion_r397827663
##########
File path: solr/core/src/java/org/apache/solr/core/CoreContainer.java
##########
@@ -184,6 +184,8 @@ public CoreLoadFailure(CoreDescriptor cd, Exception loadFailure) {
private volatile ExecutorService coreContainerWorkExecutor = ExecutorUtil.newMDCAwareCachedThreadPool(
new DefaultSolrThreadFactory("coreContainerWorkExecutor"));
+ final private ExecutorService collectorExecutor;
Review comment:
nitpick: regular order is private than final.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] dsmiley commented on a change in pull request #1310:
SOLR-13350: Multithreaded search using collector managers
Posted by GitBox <gi...@apache.org>.
dsmiley commented on a change in pull request #1310: SOLR-13350: Multithreaded search using collector managers
URL: https://github.com/apache/lucene-solr/pull/1310#discussion_r397854900
##########
File path: solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
##########
@@ -1643,6 +1660,83 @@ public ScoreMode scoreMode() {
qr.setDocList(new DocSlice(0, sliceLen, ids, scores, totalHits, maxScore));
}
+ CollectorManagerResult searchCollectorManagers(int len, QueryCommand cmd, Query query,
+ boolean needTopDocs, boolean needMaxScore, boolean needDocSet) throws IOException {
+ CollectorManager<MultiCollector, CollectorManagerResult> manager = new CollectorManager<MultiCollector, CollectorManagerResult>() {
+ @Override
+ public MultiCollector newCollector() throws IOException {
+ // nocommit: Here, creating a MultiCollector for every segment (correctness > speed).
+ // Need to explore sharing a single MultiCollector with every segment. Are these
+ // sub-collectors thread-safe? DocSetCollector seems like not thread-safe, does someone know?
+ Collection<Collector> collectors = new ArrayList<Collector>();
+ if (needTopDocs) collectors.add(buildTopDocsCollector(len, cmd));
+ if (needMaxScore) collectors.add(new MaxScoreCollector());
+ if (needDocSet) collectors.add(new DocSetCollector(maxDoc()));
+ return (MultiCollector) MultiCollector.wrap(collectors);
+ }
+
+ @Override
+ public CollectorManagerResult reduce(Collection<MultiCollector> multiCollectors) throws IOException {
+ final TopDocs[] topDocs = new TopDocs[multiCollectors.size()];
+ float maxScore = 0.0f;
+ DocSet docSet = new BitDocSet(new FixedBitSet(maxDoc())); // TODO: if docset is not needed, avoid this initialization
+ int i = 0;
+ for (MultiCollector multiCollector: multiCollectors) {
+ int c = 0;
+ List<Collector> subCollectors = multiCollector.getCollectors();
+ TopDocsCollector topDocsCollector = needTopDocs? ((TopDocsCollector) subCollectors.get(c++)): null;
+ MaxScoreCollector maxScoreCollector = needMaxScore? ((MaxScoreCollector) subCollectors.get(c++)): null;
+ DocSetCollector docSetCollector = needDocSet? ((DocSetCollector) subCollectors.get(c++)): null;
+
+ if (needTopDocs) topDocs[i++] = (topDocsCollector instanceof TopFieldCollector)? ((TopFieldCollector)topDocsCollector).topDocs(0, len): topDocsCollector.topDocs(0, len);
Review comment:
The ternary check & cast is not necessary 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] dsmiley commented on a change in pull request #1310:
SOLR-13350: Multithreaded search using collector managers
Posted by GitBox <gi...@apache.org>.
dsmiley commented on a change in pull request #1310: SOLR-13350: Multithreaded search using collector managers
URL: https://github.com/apache/lucene-solr/pull/1310#discussion_r397857397
##########
File path: solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
##########
@@ -1643,6 +1660,83 @@ public ScoreMode scoreMode() {
qr.setDocList(new DocSlice(0, sliceLen, ids, scores, totalHits, maxScore));
}
+ CollectorManagerResult searchCollectorManagers(int len, QueryCommand cmd, Query query,
+ boolean needTopDocs, boolean needMaxScore, boolean needDocSet) throws IOException {
+ CollectorManager<MultiCollector, CollectorManagerResult> manager = new CollectorManager<MultiCollector, CollectorManagerResult>() {
+ @Override
+ public MultiCollector newCollector() throws IOException {
+ // nocommit: Here, creating a MultiCollector for every segment (correctness > speed).
+ // Need to explore sharing a single MultiCollector with every segment. Are these
+ // sub-collectors thread-safe? DocSetCollector seems like not thread-safe, does someone know?
+ Collection<Collector> collectors = new ArrayList<Collector>();
+ if (needTopDocs) collectors.add(buildTopDocsCollector(len, cmd));
+ if (needMaxScore) collectors.add(new MaxScoreCollector());
+ if (needDocSet) collectors.add(new DocSetCollector(maxDoc()));
+ return (MultiCollector) MultiCollector.wrap(collectors);
+ }
+
+ @Override
+ public CollectorManagerResult reduce(Collection<MultiCollector> multiCollectors) throws IOException {
+ final TopDocs[] topDocs = new TopDocs[multiCollectors.size()];
+ float maxScore = 0.0f;
+ DocSet docSet = new BitDocSet(new FixedBitSet(maxDoc())); // TODO: if docset is not needed, avoid this initialization
+ int i = 0;
+ for (MultiCollector multiCollector: multiCollectors) {
+ int c = 0;
+ List<Collector> subCollectors = multiCollector.getCollectors();
+ TopDocsCollector topDocsCollector = needTopDocs? ((TopDocsCollector) subCollectors.get(c++)): null;
+ MaxScoreCollector maxScoreCollector = needMaxScore? ((MaxScoreCollector) subCollectors.get(c++)): null;
+ DocSetCollector docSetCollector = needDocSet? ((DocSetCollector) subCollectors.get(c++)): null;
+
+ if (needTopDocs) topDocs[i++] = (topDocsCollector instanceof TopFieldCollector)? ((TopFieldCollector)topDocsCollector).topDocs(0, len): topDocsCollector.topDocs(0, len);
+ if (needMaxScore)
+ if (!Float.isNaN(maxScoreCollector.getMaxScore()))
+ maxScore = Math.max(maxScore, maxScoreCollector.getMaxScore());
+ if (needDocSet) docSet = docSet.union(docSetCollector.getDocSet());
+ }
+ TopDocs mergedTopDocs;
+ if (topDocs != null && topDocs.length>0 && topDocs[0] instanceof TopFieldDocs) {
+ TopFieldDocs[] topFieldDocs = Arrays.copyOf(topDocs, topDocs.length, TopFieldDocs[].class);
+ mergedTopDocs = TopFieldDocs.merge(weightSort(cmd.getSort()), len, topFieldDocs);
+ } else {
+ mergedTopDocs = needTopDocs? TopDocs.merge(0, len, topDocs): null;
+ }
+ int totalHits = needTopDocs? (int)mergedTopDocs.totalHits.value: -1;
+ maxScore = totalHits > 0 ? maxScore : 0.0f;
+ return new CollectorManagerResult(mergedTopDocs, docSet, maxScore, totalHits);
+ }
+
+ };
+
+ CollectorManagerResult ret;
+ try {
+ ret = super.search(query, manager);
+ } catch (Exception ex) {
+ if (ex instanceof RuntimeException &&
Review comment:
Yuck! Any ideas to improve this?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] dsmiley commented on a change in pull request #1310:
SOLR-13350: Multithreaded search using collector managers
Posted by GitBox <gi...@apache.org>.
dsmiley commented on a change in pull request #1310: SOLR-13350: Multithreaded search using collector managers
URL: https://github.com/apache/lucene-solr/pull/1310#discussion_r397862858
##########
File path: solr/core/src/test/org/apache/solr/search/TestFiltering.java
##########
@@ -86,21 +86,38 @@ public void testLiveDocsSharing() throws Exception {
QueryResult res = new QueryResult();
searcher.search(res, cmd);
set = res.getDocSet();
- assertTrue( set == live );
+ assertTrue( equals(live, set) );
cmd.setQuery( QParser.getParser(qstr + " OR id:0", null, req).getQuery() );
cmd.setFilterList( QParser.getParser(qstr + " OR id:1", null, req).getQuery() );
res = new QueryResult();
searcher.search(res, cmd);
set = res.getDocSet();
- assertTrue( set == live );
+ assertTrue( equals(live, set) );
}
} finally {
req.close();
}
}
+ boolean equals(DocSet ds1, DocSet ds2) {
+ DocSet smaller = ds1.getFixedBitSet().length() < ds2.getFixedBitSet().length() ? ds1: ds2;
Review comment:
Do we really need this much code here to check this? I think I've seen DocSet equality elsewhere; perhaps DocSet should implement this for real. I had taken this away recently but it could return.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] dsmiley commented on a change in pull request #1310:
SOLR-13350: Multithreaded search using collector managers
Posted by GitBox <gi...@apache.org>.
dsmiley commented on a change in pull request #1310: SOLR-13350: Multithreaded search using collector managers
URL: https://github.com/apache/lucene-solr/pull/1310#discussion_r397858537
##########
File path: solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
##########
@@ -1643,6 +1660,83 @@ public ScoreMode scoreMode() {
qr.setDocList(new DocSlice(0, sliceLen, ids, scores, totalHits, maxScore));
}
+ CollectorManagerResult searchCollectorManagers(int len, QueryCommand cmd, Query query,
+ boolean needTopDocs, boolean needMaxScore, boolean needDocSet) throws IOException {
+ CollectorManager<MultiCollector, CollectorManagerResult> manager = new CollectorManager<MultiCollector, CollectorManagerResult>() {
+ @Override
+ public MultiCollector newCollector() throws IOException {
+ // nocommit: Here, creating a MultiCollector for every segment (correctness > speed).
+ // Need to explore sharing a single MultiCollector with every segment. Are these
+ // sub-collectors thread-safe? DocSetCollector seems like not thread-safe, does someone know?
+ Collection<Collector> collectors = new ArrayList<Collector>();
+ if (needTopDocs) collectors.add(buildTopDocsCollector(len, cmd));
+ if (needMaxScore) collectors.add(new MaxScoreCollector());
+ if (needDocSet) collectors.add(new DocSetCollector(maxDoc()));
+ return (MultiCollector) MultiCollector.wrap(collectors);
+ }
+
+ @Override
+ public CollectorManagerResult reduce(Collection<MultiCollector> multiCollectors) throws IOException {
+ final TopDocs[] topDocs = new TopDocs[multiCollectors.size()];
+ float maxScore = 0.0f;
+ DocSet docSet = new BitDocSet(new FixedBitSet(maxDoc())); // TODO: if docset is not needed, avoid this initialization
+ int i = 0;
+ for (MultiCollector multiCollector: multiCollectors) {
+ int c = 0;
+ List<Collector> subCollectors = multiCollector.getCollectors();
+ TopDocsCollector topDocsCollector = needTopDocs? ((TopDocsCollector) subCollectors.get(c++)): null;
+ MaxScoreCollector maxScoreCollector = needMaxScore? ((MaxScoreCollector) subCollectors.get(c++)): null;
+ DocSetCollector docSetCollector = needDocSet? ((DocSetCollector) subCollectors.get(c++)): null;
+
+ if (needTopDocs) topDocs[i++] = (topDocsCollector instanceof TopFieldCollector)? ((TopFieldCollector)topDocsCollector).topDocs(0, len): topDocsCollector.topDocs(0, len);
+ if (needMaxScore)
+ if (!Float.isNaN(maxScoreCollector.getMaxScore()))
+ maxScore = Math.max(maxScore, maxScoreCollector.getMaxScore());
+ if (needDocSet) docSet = docSet.union(docSetCollector.getDocSet());
+ }
+ TopDocs mergedTopDocs;
+ if (topDocs != null && topDocs.length>0 && topDocs[0] instanceof TopFieldDocs) {
+ TopFieldDocs[] topFieldDocs = Arrays.copyOf(topDocs, topDocs.length, TopFieldDocs[].class);
+ mergedTopDocs = TopFieldDocs.merge(weightSort(cmd.getSort()), len, topFieldDocs);
+ } else {
+ mergedTopDocs = needTopDocs? TopDocs.merge(0, len, topDocs): null;
+ }
+ int totalHits = needTopDocs? (int)mergedTopDocs.totalHits.value: -1;
+ maxScore = totalHits > 0 ? maxScore : 0.0f;
+ return new CollectorManagerResult(mergedTopDocs, docSet, maxScore, totalHits);
+ }
+
+ };
+
+ CollectorManagerResult ret;
+ try {
+ ret = super.search(query, manager);
+ } catch (Exception ex) {
+ if (ex instanceof RuntimeException &&
+ ex.getCause() != null & ex.getCause() instanceof ExecutionException
+ && ex.getCause().getCause() != null && ex.getCause().getCause() instanceof RuntimeException) {
+ throw (RuntimeException)ex.getCause().getCause();
+ } else {
+ throw ex;
+ }
+ }
+ return ret;
+ }
+
+ class CollectorManagerResult {
Review comment:
Make all fields final if you can
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] dsmiley commented on a change in pull request #1310:
SOLR-13350: Multithreaded search using collector managers
Posted by GitBox <gi...@apache.org>.
dsmiley commented on a change in pull request #1310: SOLR-13350: Multithreaded search using collector managers
URL: https://github.com/apache/lucene-solr/pull/1310#discussion_r397863596
##########
File path: solr/core/src/java/org/apache/solr/request/SolrRequestInfo.java
##########
@@ -67,6 +70,19 @@ public static void setRequestInfo(SolrRequestInfo info) {
threadLocal.set(info);
}
+ public static void init() {
Review comment:
No usages found
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] dsmiley commented on a change in pull request #1310:
SOLR-13350: Multithreaded search using collector managers
Posted by GitBox <gi...@apache.org>.
dsmiley commented on a change in pull request #1310: SOLR-13350: Multithreaded search using collector managers
URL: https://github.com/apache/lucene-solr/pull/1310#discussion_r397859647
##########
File path: solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
##########
@@ -1643,6 +1660,83 @@ public ScoreMode scoreMode() {
qr.setDocList(new DocSlice(0, sliceLen, ids, scores, totalHits, maxScore));
}
+ CollectorManagerResult searchCollectorManagers(int len, QueryCommand cmd, Query query,
+ boolean needTopDocs, boolean needMaxScore, boolean needDocSet) throws IOException {
+ CollectorManager<MultiCollector, CollectorManagerResult> manager = new CollectorManager<MultiCollector, CollectorManagerResult>() {
+ @Override
+ public MultiCollector newCollector() throws IOException {
+ // nocommit: Here, creating a MultiCollector for every segment (correctness > speed).
+ // Need to explore sharing a single MultiCollector with every segment. Are these
+ // sub-collectors thread-safe? DocSetCollector seems like not thread-safe, does someone know?
Review comment:
DocSetCollector is *not* threadsafe. That is something Etsy tried to tackle. I think if we had per-segment DocSets (and thus segment oriented filter cache), then this would be a non-issue? I don't think you should tackle this in this issue; it's a TODO for another day.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] dsmiley commented on a change in pull request #1310:
SOLR-13350: Multithreaded search using collector managers
Posted by GitBox <gi...@apache.org>.
dsmiley commented on a change in pull request #1310: SOLR-13350: Multithreaded search using collector managers
URL: https://github.com/apache/lucene-solr/pull/1310#discussion_r397855612
##########
File path: solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
##########
@@ -1643,6 +1660,83 @@ public ScoreMode scoreMode() {
qr.setDocList(new DocSlice(0, sliceLen, ids, scores, totalHits, maxScore));
}
+ CollectorManagerResult searchCollectorManagers(int len, QueryCommand cmd, Query query,
+ boolean needTopDocs, boolean needMaxScore, boolean needDocSet) throws IOException {
+ CollectorManager<MultiCollector, CollectorManagerResult> manager = new CollectorManager<MultiCollector, CollectorManagerResult>() {
+ @Override
+ public MultiCollector newCollector() throws IOException {
+ // nocommit: Here, creating a MultiCollector for every segment (correctness > speed).
+ // Need to explore sharing a single MultiCollector with every segment. Are these
+ // sub-collectors thread-safe? DocSetCollector seems like not thread-safe, does someone know?
+ Collection<Collector> collectors = new ArrayList<Collector>();
+ if (needTopDocs) collectors.add(buildTopDocsCollector(len, cmd));
+ if (needMaxScore) collectors.add(new MaxScoreCollector());
+ if (needDocSet) collectors.add(new DocSetCollector(maxDoc()));
+ return (MultiCollector) MultiCollector.wrap(collectors);
+ }
+
+ @Override
+ public CollectorManagerResult reduce(Collection<MultiCollector> multiCollectors) throws IOException {
+ final TopDocs[] topDocs = new TopDocs[multiCollectors.size()];
+ float maxScore = 0.0f;
+ DocSet docSet = new BitDocSet(new FixedBitSet(maxDoc())); // TODO: if docset is not needed, avoid this initialization
Review comment:
I disagree that we even need this. Init to null. Instead of calling union, if null just set it.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] dsmiley commented on a change in pull request #1310:
SOLR-13350: Multithreaded search using collector managers
Posted by GitBox <gi...@apache.org>.
dsmiley commented on a change in pull request #1310: SOLR-13350: Multithreaded search using collector managers
URL: https://github.com/apache/lucene-solr/pull/1310#discussion_r397860433
##########
File path: solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
##########
@@ -1712,33 +1806,47 @@ public ScoreMode scoreMode() {
// no docs on this page, so cursor doesn't change
qr.setNextCursorMark(cmd.getCursorMark());
} else {
-
- final TopDocsCollector topCollector = buildTopDocsCollector(len, cmd);
- DocSetCollector setCollector = new DocSetCollector(maxDoc);
- MaxScoreCollector maxScoreCollector = null;
- List<Collector> collectors = new ArrayList<>(Arrays.asList(topCollector, setCollector));
-
- if ((cmd.getFlags() & GET_SCORES) != 0) {
- maxScoreCollector = new MaxScoreCollector();
- collectors.add(maxScoreCollector);
+ TopDocs topDocs;
+ if (pf.postFilter != null || cmd.getSegmentTerminateEarly() || cmd.getTimeAllowed() > 0
+ || query instanceof RankQuery || query instanceof GraphQuery) {
Review comment:
What makes GraphQuery so special? Maybe we should define a marker interface here? What if the Query is a BooleanQuery that somewhere inside _contains_ a GraphQuery?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org