hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [hbase] Apache9 commented on a change in pull request #3575: HBASE-26178 Improve data structure and algorithm for BalanceClusterSt…
Date Fri, 13 Aug 2021 13:08:52 GMT

Apache9 commented on a change in pull request #3575:
URL: https://github.com/apache/hbase/pull/3575#discussion_r688499232



##########
File path: hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/BalancerClusterState.java
##########
@@ -207,15 +212,20 @@ public String getRack(ServerName server) {
 
     serverIndexToHostIndex = new int[numServers];
     serverIndexToRackIndex = new int[numServers];
-    regionsPerServer = new int[numServers][];
-    serverIndexToRegionsOffset = new int[numServers];
-    regionsPerHost = new int[numHosts][];
-    regionsPerRack = new int[numRacks][];
-    primariesOfRegionsPerServer = new int[numServers][];
-    primariesOfRegionsPerHost = new int[numHosts][];
-    primariesOfRegionsPerRack = new int[numRacks][];
+    regionsPerServer = new ArrayList<ArrayList<Integer>>(numServers);
+    regionsPerHost = new ArrayList<HashSet<Integer>>(numHosts);
+    regionsPerRack = new ArrayList<HashSet<Integer>>(numRacks);
+    primariesOfRegionsPerServer = new ArrayList<HashMap<Integer, ArrayList<Integer>>>(numServers);
+    primariesOfRegionsPerHost = new ArrayList<HashMap<Integer, ArrayList<Integer>>>(numHosts);

Review comment:
       And do we really need HashMap here? The key is just a index?

##########
File path: hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/BalancerClusterState.java
##########
@@ -207,15 +212,20 @@ public String getRack(ServerName server) {
 
     serverIndexToHostIndex = new int[numServers];
     serverIndexToRackIndex = new int[numServers];
-    regionsPerServer = new int[numServers][];
-    serverIndexToRegionsOffset = new int[numServers];
-    regionsPerHost = new int[numHosts][];
-    regionsPerRack = new int[numRacks][];
-    primariesOfRegionsPerServer = new int[numServers][];
-    primariesOfRegionsPerHost = new int[numHosts][];
-    primariesOfRegionsPerRack = new int[numRacks][];
+    regionsPerServer = new ArrayList<ArrayList<Integer>>(numServers);
+    regionsPerHost = new ArrayList<HashSet<Integer>>(numHosts);
+    regionsPerRack = new ArrayList<HashSet<Integer>>(numRacks);
+    primariesOfRegionsPerServer = new ArrayList<HashMap<Integer, ArrayList<Integer>>>(numServers);
+    primariesOfRegionsPerHost = new ArrayList<HashMap<Integer, ArrayList<Integer>>>(numHosts);

Review comment:
       Could just be new HashMap[numHosts]

##########
File path: hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/BalancerClusterState.java
##########
@@ -207,15 +212,20 @@ public String getRack(ServerName server) {
 
     serverIndexToHostIndex = new int[numServers];
     serverIndexToRackIndex = new int[numServers];
-    regionsPerServer = new int[numServers][];
-    serverIndexToRegionsOffset = new int[numServers];
-    regionsPerHost = new int[numHosts][];
-    regionsPerRack = new int[numRacks][];
-    primariesOfRegionsPerServer = new int[numServers][];
-    primariesOfRegionsPerHost = new int[numHosts][];
-    primariesOfRegionsPerRack = new int[numRacks][];
+    regionsPerServer = new ArrayList<ArrayList<Integer>>(numServers);

Review comment:
       I think we could implement a simple IntArrayList, this could save a lot of memory,
so here we could write code like
   
   regionsPerServer = new IntArrayList[numServers];




-- 
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: issues-unsubscribe@hbase.apache.org

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



Mime
View raw message