Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print cost metrics as data size #11443

Closed
wants to merge 1 commit into from
Closed
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 @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -476,6 +478,23 @@ private void printWindowOperatorStats(int indent, WindowOperatorStats stats)
output.append('\n');
}

private static String formatDoubleAsCpuCost(double value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can simply rename these methods as formatCpuCost and formatDataSize, because the parameters are double so we don't need to repeat that we are formatting double values.

{
return formatDoubleAsDataSize(value).replaceAll("B$", "");
}

private static String formatDoubleAsDataSize(double value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all comments from formatDoubleAsCpuCost

{
if (!isFinite(value)) {
return Double.toString(value);
}
else if (isNaN(value)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary else

return "?";
}

return DataSize.succinctDataSize(value, BYTE).toString();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • static import succinctDataSize
  • you can also use succinctBytes((long) value)

}

private static String formatDouble(double value)
{
if (isFinite(value)) {
Expand Down Expand Up @@ -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()));
}
}

Expand Down