-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all comments from |
||
{ | ||
if (!isFinite(value)) { | ||
return Double.toString(value); | ||
} | ||
else if (isNaN(value)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unnecessary else |
||
return "?"; | ||
} | ||
|
||
return DataSize.succinctDataSize(value, BYTE).toString(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
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())); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
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
andformatDataSize
, because the parameters aredouble
so we don't need to repeat that we are formatting double values.