Copilot commented on code in PR #7173:
URL: https://github.com/apache/hbase/pull/7173#discussion_r2231357407
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java:
##########
@@ -980,6 +980,9 @@ public void setLastRow(byte[] userInput) {
* @return the midpoint of the 2 numbers
*/
public BigInteger split2(BigInteger a, BigInteger b) {
+ if (b.equals(lastRowInt)) {
+ b = b.add(BigInteger.ONE);
+ }
return a.add(b).divide(BigInteger.valueOf(2)).abs();
Review Comment:
The use of `.abs()` on the result of the midpoint calculation is incorrect.
The midpoint of two positive BigIntegers should always be positive, and
applying abs() could mask potential issues with negative results that indicate
a logic error. Remove the `.abs()` call.
```suggestion
return a.add(b).divide(BigInteger.valueOf(2));
```
--
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]