[Improvement-17057][Master] Check if the WorkflowGrapth is a dag at constructor#17058
[Improvement-17057][Master] Check if the WorkflowGrapth is a dag at constructor#17058yingh0ng wants to merge 6 commits intoapache:devfrom
Conversation
|
Thanks for opening this pull request! Please check out our contributing guidelines. (https://github.com/apache/dolphinscheduler/blob/dev/docs/docs/en/contribute/join/pull-request.md) |
| Queue<Long> queue = new ArrayDeque<>(); | ||
| for (Map.Entry<Long, Integer> entry : inDegreeCount.entrySet()) { | ||
| if (entry.getValue() == 0 && visitTable.add(entry.getKey())) { | ||
| queue.offer(entry.getKey()); |
Check notice
Code scanning / CodeQL
Ignored error status of call
| inDegreeCount.put(postCode, inDegreeCount.get(postCode) - 1); | ||
|
|
||
| if (inDegreeCount.get(postCode) == 0) { | ||
| queue.offer(postCode); |
Check notice
Code scanning / CodeQL
Ignored error status of call
|
Update: When a ring exists, it is not a DAG |
|
@SbloodyS Hello, please take a look. |
|
@SbloodyS The Mergeable check failed because this PR was not added to the milestone. |
| } | ||
|
|
||
| private void checkIfDAG(List<WorkflowTaskRelation> workflowTaskRelations, List<TaskDefinition> taskDefinitions) { | ||
| DAG<Long, TaskDefinition, WorkflowTaskRelation> graph = new DAG<>(); |
There was a problem hiding this comment.
Please don't use DAG, this class will be removed in the future.
There was a problem hiding this comment.
つ﹏⊂
So, are there other implemented classes?
Otherwise I will implement it using my previous commit.
There was a problem hiding this comment.
WorkflowGraph is used to replace DAG
ce52582 to
c537e51
Compare
|
@ruanwenjun PTAL |
a85f8a9 to
88863d5
Compare
88863d5 to
c664d33
Compare
|
c664d33 to
66db1e9
Compare
66db1e9 to
b772a6d
Compare
|
@ruanwenjun @SbloodyS PTAL |
|
Can somebody review this again. |
| addTaskEdge(workflowTaskRelations); | ||
| } | ||
|
|
||
| private void checkIfDAG(List<WorkflowTaskRelation> workflowTaskRelations, List<TaskDefinition> taskDefinitions) { |
There was a problem hiding this comment.
It seems we can directly use DFS to check if this is DAG after addTaskNodes and addTaskEdge.
There was a problem hiding this comment.
Yes, DFS can check whether a graph is a DAG. My implementation is Kahn's algorithm.
Both methods can perform DAG detection.
There was a problem hiding this comment.
Hey, if you have question or suggestion for this, please tell me.
|
Please retry analysis of this Pull-Request directly on SonarQube Cloud |
b772a6d to
b7a2d0f
Compare
|
Closing for inactivity. |



Purpose of the pull request
Check if the WorkflowGrapth is a dag close #17057
Brief change log
Conclusion: A graph is not a DAG if its task length is less than the total number of tasks after topological sorting
Verify this pull request
This change added tests and can be verified as follows:
Pull Request Notice
Pull Request Notice
If your pull request contains incompatible change, you should also add it to
docs/docs/en/guide/upgrade/incompatible.md