Copilot commented on code in PR #7035:
URL: https://github.com/apache/hbase/pull/7035#discussion_r2107423735
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.java:
##########
@@ -322,14 +322,24 @@ private double getAverageRegionSizeMb(final
List<RegionInfo> tableRegions,
avgRegionSize = targetRegionSize;
} else {
final int regionCount = tableRegions.size();
- final long totalSizeMb =
tableRegions.stream().mapToLong(this::getRegionSizeMB).sum();
+ // Count of regions whose size is known
+ int regionCountKnownSize = 0;
+ long totalSizeMb = 0;
+ for (RegionInfo regionInfo : tableRegions) {
+ long regionSize = getRegionSizeMB(regionInfo);
+ if(regionSize != -1) {
+ totalSizeMb += regionSize;
+ regionCountKnownSize++;
+ }
+ }
if (targetRegionCount > 0) {
- avgRegionSize = totalSizeMb / (double) targetRegionCount;
+ avgRegionSize = totalSizeMb / (double) targetRegionCount -
(regionCount - regionCountKnownSize);
Review Comment:
Subtracting (regionCount - regionCountKnownSize) after the division appears
to yield an incorrect average. Consider computing the average solely based on
the total known region sizes divided by regionCountKnownSize.
```suggestion
avgRegionSize = totalSizeMb / (double) regionCountKnownSize;
```
--
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]