Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import io.airlift.units.DataSize;
import io.prestosql.cost.PlanCostEstimate;
import io.prestosql.cost.PlanNodeStatsEstimate;
import io.prestosql.sql.planner.Symbol;
Expand All @@ -27,7 +28,9 @@
import java.util.Set;

import static com.google.common.collect.Iterables.getOnlyElement;
import static io.airlift.units.DataSize.succinctBytes;
import static io.airlift.units.DataSize.Unit.BYTE;
import static java.lang.Double.NEGATIVE_INFINITY;
import static java.lang.Double.POSITIVE_INFINITY;
import static java.lang.Double.isFinite;
import static java.lang.Double.isNaN;
import static java.lang.String.format;
Expand Down Expand Up @@ -228,10 +231,10 @@ private String printEstimates(PlanRepresentation plan, NodeRepresentation node)

output.append(format("{rows: %s (%s), cpu: %s, memory: %s, network: %s}",
formatAsLong(stats.getOutputRowCount()),
formatEstimateAsDataSize(stats.getOutputSizeInBytes(outputSymbols, plan.getTypes())),
formatDouble(cost.getCpuCost()),
formatDouble(cost.getMaxMemory()),
formatDouble(cost.getNetworkCost())));
formatAsDataSize(stats.getOutputSizeInBytes(outputSymbols, plan.getTypes())),
formatAsCpuCost(cost.getCpuCost()),
formatAsDataSize(cost.getMaxMemory()),
formatAsDataSize(cost.getNetworkCost())));

if (i < estimateCount - 1) {
output.append("/");
Expand All @@ -242,11 +245,6 @@ private String printEstimates(PlanRepresentation plan, NodeRepresentation node)
return output.toString();
}

private static String formatEstimateAsDataSize(double value)
{
return isNaN(value) ? "?" : succinctBytes((long) value).toString();
}

private static String formatAsLong(double value)
{
if (isFinite(value)) {
Expand All @@ -256,6 +254,26 @@ private static String formatAsLong(double value)
return "?";
}

private static String formatAsCpuCost(double value)
{
return formatAsDataSize(value).replaceAll("B$", "");
}

private static String formatAsDataSize(double value)
{
if (isNaN(value)) {
return "?";
}
if (value == POSITIVE_INFINITY) {
return "+\u221E";
}
if (value == NEGATIVE_INFINITY) {
return "-\u221E";
}

return DataSize.succinctDataSize(value, BYTE).toString();
}

static String formatDouble(double value)
{
if (isFinite(value)) {
Expand Down