LakshSingla commented on code in PR #16911:
URL: https://github.com/apache/druid/pull/16911#discussion_r1721005643


##########
processing/src/main/java/org/apache/druid/frame/processor/SuperSorter.java:
##########
@@ -382,29 +388,42 @@ private void runWorkersIfPossible()
   @GuardedBy("runWorkersLock")
   private void setAllDoneIfPossible()
   {
-    if (totalInputFrames == 0 && outputPartitionsFuture.isDone()) {
-      // No input data -- generate empty output channels.
-      final ClusterByPartitions partitions = getOutputPartitions();
-      final List<OutputChannel> channels = new ArrayList<>(partitions.size());
+    try {
+      if (totalInputFrames == 0 && outputPartitionsFuture.isDone()) {
+        // No input data -- generate empty output channels.
+        final ClusterByPartitions partitions = getOutputPartitions();
+        final List<OutputChannel> channels = new 
ArrayList<>(partitions.size());
 
-      for (int partitionNum = 0; partitionNum < partitions.size(); 
partitionNum++) {
-        channels.add(outputChannelFactory.openNilChannel(partitionNum));
-      }
+        for (int partitionNum = 0; partitionNum < partitions.size(); 
partitionNum++) {
+          channels.add(outputChannelFactory.openNilChannel(partitionNum));
+        }
+
+        // OK to use wrap, not wrapReadOnly, because nil channels are already 
read-only.
+        allDone.set(OutputChannels.wrap(channels));
+      } else if (rowLimit == 0 && activeProcessors == 0) {
+        // We had a row limit, and got it all the way down to zero.
+        // Generate empty output channels for any partitions that we haven't 
written yet.
+        superSorterProgressTracker.markTriviallyComplete();

Review Comment:
   If there was a row limit initially and we brought it down to zero, should it 
be called trivially completed? Trivially completed means that there wasn't any 
data to begin with. 



##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/querykit/groupby/GroupByQueryKit.java:
##########


Review Comment:
   Can similar optimisation be applied for ScanQueryKit as well? 



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

Reply via email to