caishunfeng commented on code in PR #14563:
URL: 
https://github.com/apache/dolphinscheduler/pull/14563#discussion_r1274284072


##########
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/utils/DagHelper.java:
##########
@@ -424,19 +424,61 @@ private static List<Long> skipTaskNode4Switch(TaskNode 
taskNode,
         int resultConditionLocation = 
switchParameters.getResultConditionLocation();
         List<SwitchResultVo> conditionResultVoList = 
switchParameters.getDependTaskList();
         List<Long> switchTaskList = 
conditionResultVoList.get(resultConditionLocation).getNextNode();
+        Set<Long> switchNeedWorkCodes = new HashSet<>();
         if (CollectionUtils.isEmpty(switchTaskList)) {
             switchTaskList = new ArrayList<>();
+        } else {
+            // get all downstream nodes of the branch that the switch node 
needs to execute
+            for (Long switchTaskCode : switchTaskList) {
+                getSwitchNeedWorkCodes(switchTaskCode, dag, 
switchNeedWorkCodes);
+            }
         }
         // conditionResultVoList.remove(resultConditionLocation);
         for (SwitchResultVo info : conditionResultVoList) {
             if (CollectionUtils.isEmpty(info.getNextNode())) {
                 continue;
             }
-            setTaskNodeSkip(info.getNextNode().get(0), dag, completeTaskList, 
skipTaskNodeList);
+            setSwitchTaskNodeSkip(info.getNextNode().get(0), dag, 
completeTaskList, skipTaskNodeList,

Review Comment:
   `info.getNextNode().get(0)` is skipNode? If true, I think it's better to add 
method like `getFirstSkipNode` for  `SwitchResultVo`, WDYT?



##########
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/utils/DagHelper.java:
##########
@@ -424,19 +424,61 @@ private static List<Long> skipTaskNode4Switch(TaskNode 
taskNode,
         int resultConditionLocation = 
switchParameters.getResultConditionLocation();
         List<SwitchResultVo> conditionResultVoList = 
switchParameters.getDependTaskList();
         List<Long> switchTaskList = 
conditionResultVoList.get(resultConditionLocation).getNextNode();
+        Set<Long> switchNeedWorkCodes = new HashSet<>();
         if (CollectionUtils.isEmpty(switchTaskList)) {
             switchTaskList = new ArrayList<>();
+        } else {
+            // get all downstream nodes of the branch that the switch node 
needs to execute
+            for (Long switchTaskCode : switchTaskList) {
+                getSwitchNeedWorkCodes(switchTaskCode, dag, 
switchNeedWorkCodes);
+            }
         }

Review Comment:
   ```suggestion
           if (CollectionUtils.isEmpty(switchTaskList)) {
               return new ArrayList<>();
           } 
             // get all downstream nodes of the branch that the switch node 
needs to execute
             for (Long switchTaskCode : switchTaskList) {
                 getSwitchNeedWorkCodes(switchTaskCode, dag, 
switchNeedWorkCodes);
             }
   ```



##########
dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/utils/DagHelperTest.java:
##########
@@ -436,11 +454,13 @@ private DAG<Long, TaskNode, TaskNodeRelation> 
generateDag() throws IOException {
 
     /**
      * DAG graph:
-     *    2
-     *    ↑
-     * 0->1(switch)
-     *    ↓
-     *    4
+     *           -> 2->
+     *         /        \
+     *      /               \
+     * 0->1(switch)->5          6

Review Comment:
   :+1: 



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

Reply via email to