zaaath commented on code in PR #2977:
URL: https://github.com/apache/cassandra/pull/2977#discussion_r1424391231
##########
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:
Flow chart of the above:
```mermaid
flowchart TD
A[Calculate Prefix Index] -->|Determine prefix index based on size|
B[Adjust for Smallest Prefix]
B -->|Set to 'Kilo' for sizes < 1024 bytes| C[Get Prefix Character]
C -->|Retrieve unit prefix character| D[Scale the Size]
D -->|Divide size by 2^ 10×prefixIndex | E[Format Scaled Size]
E -->|Is scaled size between -1 and 1?| F[Format Small Numbers]
E -->|Format Larger Numbers| G[Format Large Numbers]
F & G --> H[Merge Scaled Size with Prefix]
H -->|Construct final human-readable string| I[End]
```
##########
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:
Flow chart of the above:
```mermaid
flowchart TD
A[Calculate Prefix Index] -->|Determine prefix index based on size|
B[Adjust for Smallest Prefix]
B -->|Set to 'Kilo' for sizes < 1024 bytes| C[Get Prefix Character]
C -->|Retrieve unit prefix character| D[Scale the Size]
D -->|Divide size by 2^ 10×prefixIndex | E[Format Scaled Size]
E -->|Is scaled size between -1 and 1?| F[Format Small Numbers]
E -->|Format Larger Numbers| G[Format Large Numbers]
F & G --> H[Merge Scaled Size with Prefix]
H -->|Construct final human-readable string| I[End]
```
--
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]