zaaath commented on code in PR #2977:
URL: https://github.com/apache/cassandra/pull/2977#discussion_r1426029704
##########
src/java/org/apache/cassandra/utils/FBUtilities.java:
##########
@@ -939,6 +939,33 @@ public static String prettyPrintMemory(long size, String
separator)
UNIT_PREFIXES.charAt(UNIT_PREFIXES_BASE +
prefixIndex));
}
+ /**
+ * Convert the given size in bytes to a human-readable value using binary
(i.e. 2^10-based) modifiers
+ * with only three significant digits.
+ * For example, "4.96 KiB", "48.8 KiB", "477 MiB", "0.422 KiB", "0.000
KiB".
+ * @param size Number to convert.
+ */
+ public static String prettyPrintMemoryShort(long size)
Review Comment:
@smiklosovic thanks for the code pointer, I like the output that
`org.apache.cassandra.io.util.FileUtils.stringifyFileSize` produces, but
please note that it doesn't quite match what was agreed on in the Jira and in
the mailing list:
1. "KiB might make sense as the lowest reportable units."
2. "With a leading zero before the decimal point, there should be three
significant digits afterwards"
Comparison:
```
Expected output and FBUtilities.prettyPrintMemoryShort:
0: 0.000 KiB
5: 0.005 KiB
50: 0.049 KiB
500: 0.488 KiB
5000: 4.88 KiB
50000: 48.8 KiB
500000: 488 KiB
5000000: 4.77 MiB
50000000: 47.7 MiB
500000000: 477 MiB
FileUtils.stringifyFileSize:
0: 0 bytes
5: 5 bytes
50: 50 bytes
500: 500 bytes
5000: 4.88 KiB
50000: 48.83 KiB
500000: 488.28 KiB
5000000: 4.77 MiB
50000000: 47.68 MiB
500000000: 476.84 MiB
```
I'll switch the logic to `FileUtils.stringifyFileSize` if you think it's
warranted to not fully follow the expected output format. I'm on board with
this.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]