diff --git a/presto-main/src/main/java/com/facebook/presto/sql/planner/planPrinter/PlanPrinter.java b/presto-main/src/main/java/com/facebook/presto/sql/planner/planPrinter/PlanPrinter.java index eb97b7350606..d9146aeee4c2 100644 --- a/presto-main/src/main/java/com/facebook/presto/sql/planner/planPrinter/PlanPrinter.java +++ b/presto-main/src/main/java/com/facebook/presto/sql/planner/planPrinter/PlanPrinter.java @@ -104,6 +104,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import io.airlift.slice.Slice; +import io.airlift.units.DataSize; import java.util.ArrayList; import java.util.LinkedList; @@ -126,6 +127,7 @@ import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.collect.ImmutableMap.toImmutableMap; import static com.google.common.collect.Iterables.getOnlyElement; +import static io.airlift.units.DataSize.Unit.BYTE; import static io.airlift.units.DataSize.succinctBytes; import static java.lang.Double.isFinite; import static java.lang.Double.isNaN; @@ -476,6 +478,23 @@ private void printWindowOperatorStats(int indent, WindowOperatorStats stats) output.append('\n'); } + private static String formatDoubleAsCpuCost(double value) + { + return formatDoubleAsDataSize(value).replaceAll("B$", ""); + } + + private static String formatDoubleAsDataSize(double value) + { + if (!isFinite(value)) { + return Double.toString(value); + } + else if (isNaN(value)) { + return "?"; + } + + return DataSize.succinctDataSize(value, BYTE).toString(); + } + private static String formatDouble(double value) { if (isFinite(value)) { @@ -1405,9 +1424,9 @@ private String formatPlanNodeStatsAndCost(PlanNode node) return format("{rows: %s (%s), cpu: %s, memory: %s, network: %s}", formatAsLong(stats.getOutputRowCount()), formatEstimateAsDataSize(stats.getOutputSizeInBytes(node.getOutputSymbols(), types)), - formatDouble(cost.getCpuCost()), - formatDouble(cost.getMemoryCost()), - formatDouble(cost.getNetworkCost())); + formatDoubleAsCpuCost(cost.getCpuCost()), + formatDoubleAsDataSize(cost.getMemoryCost()), + formatDoubleAsDataSize(cost.getNetworkCost())); } }