FrankChen021 commented on a change in pull request #10635:
URL: https://github.com/apache/druid/pull/10635#discussion_r537244973
##########
File path:
core/src/main/java/org/apache/druid/java/util/common/HumanReadableBytes.java
##########
@@ -208,4 +208,108 @@ private static long parseInner(String rawNumber)
throw new IAE("Invalid format or out of range of long: %s", rawNumber);
}
}
+
+ public enum UnitSystem
+ {
+ /**
+ * also known as IEC format
+ * eg: B, KiB, MiB, GiB ...
+ */
+ BINARY_BYTE,
+
+ /**
+ * also known as SI format
+ * eg: B, KB, MB ...
+ */
+ DECIMAL_BYTE,
+
+ /**
+ * simplified SI format without 'B' indicator
+ * eg: K, M, G ...
+ */
+ DECIMAL
+ }
+
+ /**
+ * Returns a human-readable string version of input value
+ *
+ * @param bytes input value. Negative value is also allowed
+ * @param precision [0,3]
+ * @param unitSystem which unit system is adopted to format the input value,
see {@link UnitSystem}
+ * @param hasSpace if it's true, there's an extra space between the number
and the unit suffix
+ */
+ public static String format(long bytes, int precision, UnitSystem
unitSystem, boolean hasSpace)
Review comment:
We intended to expose this parameter at the SQL/native query level at
first, but found that this parameter is not so vital. So we still keep it in
the underlying implementation but hide it from the SQL level.
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]