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(ORDERED_UNITS::get)
            .orElse(BYTES);

    if (highestUnit == BYTES) {
      return String.format("%d %s", bytes, BYTES.getUnits()[1]);
    } else {
      double approximate = 1.0 * bytes / highestUnit.getMultiplier();
      return String.format(
          Locale.ROOT, "%.3f%s (%d bytes)", approximate, highestUnit.getUnits()[1], bytes);
    }
  }
Gets the memory size in Tebibytes (= 1024 Gibibytes).
amoro-common/src/main/java/org/apache/amoro/utils/MemorySize.java