atris commented on a change in pull request #725: LUCENE-8865: Use incoming 
thread for execution if IndexSearcher has an executor
URL: https://github.com/apache/lucene-solr/pull/725#discussion_r294382238
 
 

 ##########
 File path: lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java
 ##########
 @@ -636,16 +636,45 @@ public TopFieldDocs reduce(Collection<TopFieldCollector> 
collectors) throws IOEx
       query = rewrite(query);
       final Weight weight = createWeight(query, scoreMode, 1);
       final List<Future<C>> topDocsFutures = new 
ArrayList<>(leafSlices.length);
+
       for (int i = 0; i < leafSlices.length; ++i) {
         final LeafReaderContext[] leaves = leafSlices[i].leaves;
         final C collector = collectors.get(i);
-        topDocsFutures.add(executor.submit(new Callable<C>() {
-          @Override
-          public C call() throws Exception {
+        if (i == leafSlices.length-1) { // execute the last on the caller 
thread
+          search(Arrays.asList(leaves), weight, collector);
+          topDocsFutures.add(new Future<>() {
+
+            @Override
+            public boolean cancel(boolean mayInterruptIfRunning) {
+              return false;
+            }
+
+            @Override
+            public boolean isCancelled() {
+              return false;
+            }
+
+            @Override
+            public boolean isDone() {
+              return true;
+            }
+
+            @Override
+            public C get() {
+              return collector;
+            }
+
+            @Override
+            public C get(long timeout, TimeUnit unit) {
+              return get();
+            }
 
 Review comment:
   Nice Change! I am curious to understand though -- did we see this as an 
issue, or did we think of this as an optimization? Of course, that is not a 
blocker to this change

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

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

Reply via email to