lihaosky commented on code in PR #14696:
URL: https://github.com/apache/kafka/pull/14696#discussion_r1399571144


##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/Graph.java:
##########
@@ -117,6 +131,8 @@ private Graph(final boolean isResidualGraph) {
     }
 
     public void addEdge(final V u, final V v, final int capacity, final int 
cost, final int flow) {
+        Objects.requireNonNull(u);
+        Objects.requireNonNull(v);

Review Comment:
   `null` is a special node we introduced in graph as dummy source to detect 
negative cycle. So users can use it



##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/Graph.java:
##########
@@ -103,8 +104,21 @@ public String toString() {
         }
     }
 
-    private final SortedMap<V, SortedMap<V, Edge>> adjList = new TreeMap<>();
-    private final SortedSet<V> nodes = new TreeSet<>();
+    private class KeyComparator implements Comparator<V> {
+
+        @Override
+        public int compare(final V o1, final V o2) {
+            if (o1 == null || o2 == null) {
+                return -1;

Review Comment:
   Good point, if both are `null`, we can return 0;



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to