private void buildWeightList(
      List<TDataNodeInfo> onlineDataNodes, List<TRegionReplicaSet> allocatedRegions) {
    // TODO: The remaining disk capacity of DataNode can also be calculated into the weightList
    int maximumRegionNum = 0;
    Map<TDataNodeLocation, Integer> countMap = new HashMap<>();
    for (TDataNodeInfo dataNodeInfo : onlineDataNodes) {
      maxId = Math.max(maxId, dataNodeInfo.getLocation().getDataNodeId());
      countMap.put(dataNodeInfo.getLocation(), 0);
    }
    for (TRegionReplicaSet regionReplicaSet : allocatedRegions) {
      for (TDataNodeLocation dataNodeLocation : regionReplicaSet.getDataNodeLocations()) {
        countMap.computeIfPresent(dataNodeLocation, (dataNode, count) -> (count + 1));
        maximumRegionNum = Math.max(maximumRegionNum, countMap.get(dataNodeLocation));
      }
    }
    weightList = new ArrayList<>();
    for (Map.Entry<TDataNodeLocation, Integer> countEntry : countMap.entrySet()) {
      int weight = maximumRegionNum - countEntry.getValue() + 1;
      // Repeatedly add DataNode copies equal to the number of their weights
      for (int repeat = 0; repeat < weight; repeat++) {
        weightList.add(countEntry.getKey().deepCopy());
      }
    }
  }
private void buildWeightList(
      List<TDataNodeInfo> onlineDataNodes, List<TRegionReplicaSet> allocatedRegions) {
   
    int maximumRegionNum = 0;
    Map<TDataNodeLocation, Integer> countMap = new HashMap<>();
    for (TDataNodeInfo dataNodeInfo : onlineDataNodes) {
      maxId = Math.max(maxId, dataNodeInfo.getLocation().getDataNodeId());
      countMap.put(dataNodeInfo.getLocation(), 0);
    }
    for (TRegionReplicaSet regionReplicaSet : allocatedRegions) {
      for (TDataNodeLocation dataNodeLocation : regionReplicaSet.getDataNodeLocations()) {
        countMap.computeIfPresent(dataNodeLocation, (dataNode, count) -> (count + 1));
        maximumRegionNum = Math.max(maximumRegionNum, countMap.get(dataNodeLocation));
      }
    }
    weightList = new ArrayList<>();
    for (Map.Entry<TDataNodeLocation, Integer> countEntry : countMap.entrySet()) {
      int weight = maximumRegionNum - countEntry.getValue() + 1;
     
      for (int repeat = 0; repeat < weight; repeat++) {
        weightList.add(countEntry.getKey().deepCopy());
      }
    }
  }
private void buildweightlist( list<tdatanodeinfo> onlinedatanodes, list<tregionreplicaset> allocatedregions) { int maximumregionnum = 0; map<tdatanodelocation, integer> countmap = new hashmap<>(); for (tdatanodeinfo datanodeinfo : onlinedatanodes) { maxid = math.max(maxid, datanodeinfo.getlocation().getdatanodeid()); countmap.put(datanodeinfo.getlocation(), 0); } for (tregionreplicaset regionreplicaset : allocatedregions) { for (tdatanodelocation datanodelocation : regionreplicaset.getdatanodelocations()) { countmap.computeifpresent(datanodelocation, (datanode, count) -> (count + 1)); maximumregionnum = math.max(maximumregionnum, countmap.get(datanodelocation)); } } weightlist = new arraylist<>(); for (map.entry<tdatanodelocation, integer> countentry : countmap.entryset()) { int weight = maximumregionnum - countentry.getvalue() + 1; for (int repeat = 0; repeat < weight; repeat++) { weightlist.add(countentry.getkey().deepcopy()); } } }