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



##########
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:
       The key is the value of primary index that we need to look up in the 
collection and the value of hash map  is the list of region indexes of all 
colocated replicas here so we don't need to do O(n) look up on 
regionIndexToPrimaryIndex at 
https://github.com/apache/hbase/blob/master/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/RegionReplicaCandidateGenerator.java#L72




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


Reply via email to