tillrohrmann commented on a change in pull request #10785: [FLINK-15375][core]
Improve MemorySize to print / parse with better readability.
URL: https://github.com/apache/flink/pull/10785#discussion_r367991584
##########
File path:
flink-core/src/main/java/org/apache/flink/configuration/MemorySize.java
##########
@@ -158,6 +162,38 @@ private String formatToString() {
highestIntegerUnit.getUnits()[1]);
}
+ public String toHumanReadableString() {
+ if (humanReadableStr == null) {
+ humanReadableStr = formatToHumanReadableString();
+ }
+
+ return humanReadableStr;
+ }
+
+ private String formatToHumanReadableString() {
+ MemoryUnit highestUnit = IntStream.range(0,
ORDERED_UNITS.size())
+ .sequential()
+ .filter(idx -> bytes >
ORDERED_UNITS.get(idx).getMultiplier())
+ .boxed()
+ .max(Comparator.naturalOrder())
+ .map(idx -> ORDERED_UNITS.get(idx))
Review comment:
nit: could be replaced with lambda method reference.
----------------------------------------------------------------
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