echonesis commented on code in PR #11114:
URL: https://github.com/apache/ozone/pull/11114#discussion_r3877590833


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/pipeline/Pipeline.java:
##########
@@ -245,7 +247,13 @@ public int getReplicaIndex(DatanodeDetails dn) {
    * Get the replicaIndex Map.
    */
   public Map<DatanodeDetails, Integer> getReplicaIndexes() {
-    return 
this.getNodes().stream().collect(Collectors.toMap(Function.identity(), 
this::getReplicaIndex));
+    Map<DatanodeDetails, Integer> view = replicaIndexesView;
+    if (view == null) {
+      view = Collections.unmodifiableMap(getNodes().stream()
+          .collect(Collectors.toMap(Function.identity(), 
this::getReplicaIndex)));

Review Comment:
   nit: `ImmutableMap` is already imported. Using 
ImmutableMap.toImmutableMap(Function.identity(), this::getReplicaIndex) gives 
an inherently immutable, single-object result with no unmodifiableMap wrapper 
and makes immutability explicit in the type.



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

Reply via email to