drcrallen commented on a change in pull request #5913: Move Caching Cluster 
Client to java streams and allow parallel intermediate merges
URL: https://github.com/apache/incubator-druid/pull/5913#discussion_r213754069
 
 

 ##########
 File path: 
processing/src/main/java/io/druid/query/ChainedExecutionQueryRunner.java
 ##########
 @@ -70,87 +74,115 @@ public ChainedExecutionQueryRunner(
       QueryRunner<T>... queryables
   )
   {
-    this(exec, queryWatcher, Arrays.asList(queryables));
+    this(exec, queryWatcher, Arrays.stream(queryables));
   }
 
   public ChainedExecutionQueryRunner(
       ExecutorService exec,
       QueryWatcher queryWatcher,
       Iterable<QueryRunner<T>> queryables
   )
+  {
+    this(exec, queryWatcher, StreamSupport.stream(queryables.spliterator(), 
false));
+  }
+
+  public ChainedExecutionQueryRunner(
+      ExecutorService exec,
+      QueryWatcher queryWatcher,
+      Stream<QueryRunner<T>> queryables
+  )
   {
     // listeningDecorator will leave PrioritizedExecutorService unchanged,
     // since it already implements ListeningExecutorService
     this.exec = MoreExecutors.listeningDecorator(exec);
-    this.queryables = Iterables.unmodifiableIterable(queryables);
     this.queryWatcher = queryWatcher;
+    this.queryables = queryables;
   }
 
   @Override
   public Sequence<T> run(final QueryPlus<T> queryPlus, final Map<String, 
Object> responseContext)
   {
-    Query<T> query = queryPlus.getQuery();
+    final Query<T> query = queryPlus.getQuery();
     final int priority = QueryContexts.getPriority(query);
-    final Ordering ordering = query.getResultOrdering();
+    final Ordering<T> ordering = query.getResultOrdering();
     final QueryPlus<T> threadSafeQueryPlus = 
queryPlus.withoutThreadUnsafeState();
-    return new BaseSequence<T, Iterator<T>>(
+    return new BaseSequence<>(
         new BaseSequence.IteratorMaker<T, Iterator<T>>()
         {
           @Override
           public Iterator<T> make()
           {
             // Make it a List<> to materialize all of the values (so that it 
will submit everything to the executor)
-            ListenableFuture<List<Iterable<T>>> futures = Futures.allAsList(
-                Lists.newArrayList(
-                    Iterables.transform(
-                        queryables,
-                        input -> {
-                          if (input == null) {
-                            throw new ISE("Null queryRunner! Looks to be some 
segment unmapping action happening");
+            final ListenableFuture<List<Iterable<T>>> futures = 
GuavaUtils.allFuturesAsList(
+                queryables.peek(
 
 Review comment:
   Yes sounds good

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org

Reply via email to