atris commented on a change in pull request #731: LUCENE-8865: Move to executor 
in IndexSearcher
URL: https://github.com/apache/lucene-solr/pull/731#discussion_r295279917
 
 

 ##########
 File path: lucene/core/src/test/org/apache/lucene/search/TestIndexSearcher.java
 ##########
 @@ -237,4 +241,28 @@ public void testGetSlices() throws Exception {
     service.shutdown();
     IOUtils.close(r, dir);
   }
+
+  public void testOneSegmentExecutesOnTheCallerThread() throws IOException {
+    List<LeafReaderContext> leaves = reader.leaves();
+    AtomicInteger numExecutions = new AtomicInteger(0);
+    IndexSearcher searcher = new IndexSearcher(reader, task -> {
+      numExecutions.incrementAndGet();
+      task.run();
+    }) {
+      @Override
+      protected LeafSlice[] slices(List<LeafReaderContext> leaves) {
+        ArrayList<LeafSlice> slices = new ArrayList<>();
+        for (LeafReaderContext ctx : leaves) {
+          slices.add(new LeafSlice(Arrays.asList(ctx)));
+        }
+        return slices.toArray(new LeafSlice[0]);
+      }
+    };
+    searcher.search(new MatchAllDocsQuery(), 10);
+    if (leaves.size() <= 1) {
+      assertEquals(0, numExecutions.get());
+    } else {
+      assertEquals(leaves.size()-1, numExecutions.get());
 
 Review comment:
   Nit: Spacing

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