You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2020/07/04 14:06:23 UTC

[GitHub] [hadoop-ozone] esahekmat commented on a change in pull request #1023: HDDS-3718: Improve OmKeyLocationInfoGroup internal data structure

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



##########
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:
       It will cause a redundant instantiation of the map and provides no benefit because the map reassigned by the constructor parameter.




----------------------------------------------------------------
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:
users@infra.apache.org



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