xiaoyuyao commented on a change in pull request #1023:
URL: https://github.com/apache/hadoop-ozone/pull/1023#discussion_r448010316



##########
File path: 
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmKeyLocationInfoGroup.java
##########
@@ -30,12 +30,23 @@
  */
 public class OmKeyLocationInfoGroup {
   private final long version;
-  private final List<OmKeyLocationInfo> locationList;
+  private final Map<Long, List<OmKeyLocationInfo>> locationVersionList;
 
   public OmKeyLocationInfoGroup(long version,
                                 List<OmKeyLocationInfo> locations) {
     this.version = version;
-    this.locationList = locations;
+    this.locationVersionList = locations.stream()
+        .collect(Collectors.groupingBy(OmKeyLocationInfo::getCreateVersion));
+    //prevent NPE
+    this.locationVersionList.putIfAbsent(version, new ArrayList<>());
+  }
+
+  public OmKeyLocationInfoGroup(long version,
+                                Map<Long, List<OmKeyLocationInfo>> locations) {
+    this.version = version;
+    this.locationVersionList = locations;

Review comment:
       should we change the order of 47/49 so that there is always an ArrayList 
for the version and the locations is added to that arraylist.




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



---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org

Reply via email to