private String formatToString() {
    MemoryUnit highestIntegerUnit =
        IntStream.range(0, ORDERED_UNITS.size())
            .sequential()
            .filter(idx -> bytes % ORDERED_UNITS.get(idx).getMultiplier() != 0)
            .boxed()
            .findFirst()
            .map(
                idx -> {
                  if (idx == 0) {
                    return ORDERED_UNITS.get(0);
                  } else {
                    return ORDERED_UNITS.get(idx - 1);
                  }
                })
            .orElse(BYTES);

    return String.format(
        "%d %s", bytes / highestIntegerUnit.getMultiplier(), highestIntegerUnit.getUnits()[1]);
  }
Gets the memory size in Tebibytes (= 1024 Gibibytes).
amoro-common/src/main/java/org/apache/amoro/utils/MemorySize.java