timothy-e commented on code in PR #18791:
URL: https://github.com/apache/pinot/pull/18791#discussion_r3475718066


##########
pinot-query-planner/src/main/java/org/apache/pinot/query/planner/physical/FragmentType.java:
##########
@@ -0,0 +1,81 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.planner.physical;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.apache.calcite.rel.RelDistribution;
+import org.apache.pinot.query.planner.plannode.MailboxReceiveNode;
+import org.apache.pinot.query.planner.plannode.MailboxSendNode;
+import org.apache.pinot.query.planner.plannode.PlanNode;
+
+
+/**
+ * Classifies dispatchable physical-plan fragments that participate in 
mailbox-based stage execution.
+ * <p>
+ * The values describe whether a fragment is a scanning leaf, a leaf reached 
through singleton exchanges,
+ * or an intermediate stage. Fragments outside this scope are left 
unclassified: {@link #classify(PlanNode,
+ * boolean, Map)} returns {@code null} when the fragment root is not a {@link 
MailboxSendNode}.
+ */
+public enum FragmentType {
+  // Scans a fact table; non-SINGLETON sender
+  LEAF,
+  // Dim-table leaf via SINGLETON exchange, with a leaf upstream sender
+  SINGLETON_LEAF,
+  // Non-scanning stage (join, agg, sort); timings reflect upstream cascade 
delays
+  INTERMEDIATE;
+
+  public static FragmentType classify(PlanNode root, boolean hasScannedTable,
+      Map<Integer, DispatchablePlanMetadata> metadataMap) {
+    if (!(root instanceof MailboxSendNode)) {
+      return null;
+    }
+    if (!hasScannedTable) {
+      return INTERMEDIATE;
+    }
+    List<Integer> singletonSenderStageIds = 
getSingletonReceiveSenderStageIds(root);

Review Comment:
   This is an awesome suggestion, thanks Xiang! I implemented it, retested, and 
the results are much better! 
   
   Repeating the testing from 2 days ago, we see 25% lower error counts during 
induced server latency with this latest change. 
   
   <img width="1794" height="1647" alt="image" 
src="https://github.com/user-attachments/assets/72686498-6dda-4a83-b9c2-10afdda40ba1";
 />
   



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