azagrebin commented on a change in pull request #13284:
URL: https://github.com/apache/flink/pull/13284#discussion_r483645607



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/jobgraph/JobGraph.java
##########
@@ -300,6 +305,32 @@ public int getNumberOfVertices() {
                return this.taskVertices.size();
        }
 
+       public Set<SlotSharingGroup> getSlotSharingGroups() {
+               final Set<SlotSharingGroup> slotSharingGroups = new HashSet<>();
+               for (JobVertex vertex : getVertices()) {
+                       final SlotSharingGroup slotSharingGroup = 
vertex.getSlotSharingGroup();
+                       checkNotNull(slotSharingGroup);
+
+                       slotSharingGroups.add(slotSharingGroup);
+               }
+               return Collections.unmodifiableSet(slotSharingGroups);
+       }
+
+       public Set<CoLocationGroupDesc> getCoLocationGroupDescriptors() {
+               final Set<CoLocationGroup> coLocationGroups = new HashSet<>();
+               for (JobVertex vertex : getVertices()) {
+                       CoLocationGroup coLocationGroup = 
vertex.getCoLocationGroup();
+                       if (coLocationGroup != null) {
+                               coLocationGroups.add(coLocationGroup);
+                       }
+               }
+               final Set<CoLocationGroupDesc> coLocationGroupDescs = 
coLocationGroups
+                       .stream()
+                       .map(CoLocationGroupDesc::from)
+                       .collect(Collectors.toSet());

Review comment:
       Then maybe we substitute `Set<CoLocationGroupDesc>` with 
`Map<AbstractID, CoLocationGroupDesc>`?
   ```
   final Set<CoLocationGroupDesc> coLocationGroupDescs = getVertices()
       .stream()
       .map(vertex -> CoLocationGroupDesc.from(vertex.getCoLocationGroup()))
       .collect(Collectors.toMap(CoLocationGroupDesc::getId, d -> d))
       .values()
       .stream()
       .collect(Collectors.toSet());
   ```
   
   It can be also in a for-loop, but it is nit anyways so I think it is ok as 
it is.
   Maybe, at least a comment why we do it like this: `because equals ...`.




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

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


Reply via email to