cryptoe commented on code in PR #15399:
URL: https://github.com/apache/druid/pull/15399#discussion_r1495285487
##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/querykit/ChainedProcessorManager.java:
##########
@@ -76,22 +91,31 @@ public
ListenableFuture<Optional<ProcessorAndCallback<Object>>> next()
if (closed) {
throw new IllegalStateException();
} else if (first != null) {
- //noinspection unchecked
- final FrameProcessor<Object> tmp = (FrameProcessor<Object>) first;
- first = null;
- return Futures.immediateFuture(Optional.of(new
ProcessorAndCallback<>(tmp, this::onFirstProcessorComplete)));
- } else {
- return FutureUtils.transformAsync(
- restFuture,
- rest -> (ListenableFuture) rest.next()
- );
+ Optional<ProcessorAndCallback<A>> processorAndCallbackOptional =
Futures.getUnchecked(first.next());
+ if (processorAndCallbackOptional.isPresent()) {
+ // More processors left to run.
+ firstProcessorCount.incrementAndGet();
+ ProcessorAndCallback<A> aProcessorAndCallback =
processorAndCallbackOptional.get();
+ //noinspection unchecked
+ return
Futures.immediateFuture(Optional.of((ProcessorAndCallback<Object>)
aProcessorAndCallback));
+ } else {
+ first = null;
+ checkFirstProcessorComplete();
+ }
}
+
+ //noinspection unchecked
+ return FutureUtils.transformAsync(
+ restFuture,
+ rest -> (ListenableFuture) rest.next()
+ );
}
- private void onFirstProcessorComplete(final Object firstResult)
+ private synchronized void checkFirstProcessorComplete()
Review Comment:
Please add documentation regarding which threads need 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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]