peterxcli commented on PR #11550:
URL: https://github.com/apache/ozone/pull/11550#issuecomment-6339062297
Actually dag doesnt have order issue at same level. so we can just only one
queue anyway.
```diff
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/diff/SnapDiffDependencyGraph.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/diff/SnapDiffDependencyGraph.java
index dae0171..b715817 100644
---
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/diff/SnapDiffDependencyGraph.java
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/diff/SnapDiffDependencyGraph.java
@@ -145,25 +145,21 @@ List<Integer> getOrderedNodeIds() {
// Work on a local copy of the in-degrees so the method is idempotent
and
// does not mutate the graph's shared state.
int[] remainingInDegree = Arrays.copyOf(inDegree, nodeCount);
- // Among nodes whose dependencies are already satisfied, DELETEs are
emitted
- // before other types. This retains the baseline "deletes first"
ordering
- // wherever the dependency edges leave the order free.
- Queue<Integer> deleteReady = new ArrayDeque<>();
- Queue<Integer> otherReady = new ArrayDeque<>();
+ Queue<Integer> ready = new ArrayDeque<>();
for (int nodeId = 0; nodeId < nodeCount; nodeId++) {
if (remainingInDegree[nodeId] == 0) {
- enqueueReady(nodeId, deleteReady, otherReady);
+ ready.add(nodeId);
}
}
List<Integer> orderedNodeIds = new ArrayList<>(nodeCount);
Integer nodeId;
- while ((nodeId = pollReady(deleteReady, otherReady)) != null) {
+ while ((nodeId = ready.poll()) != null) {
orderedNodeIds.add(nodeId);
for (int i = adjOffsets[nodeId]; i < adjOffsets[nodeId + 1]; i++) {
int dependentNodeId = adjTargets[i];
if (--remainingInDegree[dependentNodeId] == 0) {
- enqueueReady(dependentNodeId, deleteReady, otherReady);
+ ready.add(dependentNodeId);
}
}
}
@@ -183,18 +179,6 @@ List<Integer> getOrderedNodeIds() {
return orderedNodeIds;
}
- private void enqueueReady(int nodeId, Queue<Integer> deleteReady,
Queue<Integer> otherReady) {
- if (nodes.get(nodeId).isDelete()) {
- deleteReady.add(nodeId);
- } else {
- otherReady.add(nodeId);
- }
- }
-
- private static Integer pollReady(Queue<Integer> deleteReady,
Queue<Integer> otherReady) {
- return deleteReady.isEmpty() ? otherReady.poll() : deleteReady.poll();
- }
-
private List<String> collectUnresolvedNodes(List<Integer> orderedNodeIds)
{
Set<Integer> resolved = new
HashSet<>(expectedHashMapCapacity(orderedNodeIds.size()));
resolved.addAll(orderedNodeIds);
```
--
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]