xuqinya1 commented on a change in pull request #1273: HBASE-23967 Improve the
accuracy of the method sizeToString
URL: https://github.com/apache/hbase/pull/1273#discussion_r391065633
##########
File path:
hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettings.java
##########
@@ -173,12 +173,12 @@ protected String ownerToString() {
}
protected static String sizeToString(final long size) {
- if (size >= (1L << 50)) return String.format("%dP", size / (1L << 50));
- if (size >= (1L << 40)) return String.format("%dT", size / (1L << 40));
- if (size >= (1L << 30)) return String.format("%dG", size / (1L << 30));
- if (size >= (1L << 20)) return String.format("%dM", size / (1L << 20));
- if (size >= (1L << 10)) return String.format("%dK", size / (1L << 10));
- return String.format("%dB", size);
+ if (size >= (1L << 50)) return String.format("%.2fP", (double)size / (1L
<< 50));
Review comment:
> Please try to provide formatting for every condition i.e.
>
> ```
> if (size >= (1L << 50)) {
> return String.format("%.2fP", (double)size / (1L << 50));
> }
> ```
Formatted, thanks for your review
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services