Search in sources :

Example 1 with TypedSymbol

use of io.prestosql.sql.planner.planprinter.NodeRepresentation.TypedSymbol in project hetu-core by openlookeng.

the class TextRenderer method printEstimates.

private String printEstimates(PlanRepresentation plan, NodeRepresentation node) {
    if (node.getEstimatedStats().stream().allMatch(PlanNodeStatsEstimate::isOutputRowCountUnknown) && node.getEstimatedCost().stream().allMatch(c -> c.equals(PlanCostEstimate.unknown()))) {
        return "";
    }
    StringBuilder output = new StringBuilder();
    int estimateCount = node.getEstimatedStats().size();
    output.append("Estimates: ");
    for (int i = 0; i < estimateCount; i++) {
        PlanNodeStatsEstimate stats = node.getEstimatedStats().get(i);
        PlanCostEstimate cost = node.getEstimatedCost().get(i);
        List<Symbol> outputSymbols = node.getOutputs().stream().map(TypedSymbol::getSymbol).collect(toList());
        output.append(format("{rows: %s (%s), cpu: %s, memory: %s, network: %s}", formatAsLong(stats.getOutputRowCount()), formatAsDataSize(stats.getOutputSizeInBytes(outputSymbols, plan.getTypes())), formatAsCpuCost(cost.getCpuCost()), formatAsDataSize(cost.getMaxMemory()), formatAsDataSize(cost.getNetworkCost())));
        if (i < estimateCount - 1) {
            output.append("/");
        }
    }
    output.append("\n");
    return output.toString();
}
Also used : Symbol(io.prestosql.spi.plan.Symbol) POSITIVE_INFINITY(java.lang.Double.POSITIVE_INFINITY) Collections.emptyMap(java.util.Collections.emptyMap) TypedSymbol(io.prestosql.sql.planner.planprinter.NodeRepresentation.TypedSymbol) PlanNodeStatsEstimate(io.prestosql.cost.PlanNodeStatsEstimate) Iterator(java.util.Iterator) ImmutableMap(com.google.common.collect.ImmutableMap) Set(java.util.Set) Iterables.getOnlyElement(com.google.common.collect.Iterables.getOnlyElement) NEGATIVE_INFINITY(java.lang.Double.NEGATIVE_INFINITY) String.format(java.lang.String.format) Collectors.joining(java.util.stream.Collectors.joining) Strings(com.google.common.base.Strings) DataSize(io.airlift.units.DataSize) PlanCostEstimate(io.prestosql.cost.PlanCostEstimate) List(java.util.List) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Collectors.toList(java.util.stream.Collectors.toList) Double.isNaN(java.lang.Double.isNaN) Locale(java.util.Locale) Map(java.util.Map) Optional(java.util.Optional) Double.isFinite(java.lang.Double.isFinite) BYTE(io.airlift.units.DataSize.Unit.BYTE) PlanCostEstimate(io.prestosql.cost.PlanCostEstimate) PlanNodeStatsEstimate(io.prestosql.cost.PlanNodeStatsEstimate) Symbol(io.prestosql.spi.plan.Symbol) TypedSymbol(io.prestosql.sql.planner.planprinter.NodeRepresentation.TypedSymbol)

Aggregations

Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Strings (com.google.common.base.Strings)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Iterables.getOnlyElement (com.google.common.collect.Iterables.getOnlyElement)1 DataSize (io.airlift.units.DataSize)1 BYTE (io.airlift.units.DataSize.Unit.BYTE)1 PlanCostEstimate (io.prestosql.cost.PlanCostEstimate)1 PlanNodeStatsEstimate (io.prestosql.cost.PlanNodeStatsEstimate)1 Symbol (io.prestosql.spi.plan.Symbol)1 TypedSymbol (io.prestosql.sql.planner.planprinter.NodeRepresentation.TypedSymbol)1 NEGATIVE_INFINITY (java.lang.Double.NEGATIVE_INFINITY)1 POSITIVE_INFINITY (java.lang.Double.POSITIVE_INFINITY)1 Double.isFinite (java.lang.Double.isFinite)1 Double.isNaN (java.lang.Double.isNaN)1 String.format (java.lang.String.format)1 Collections.emptyMap (java.util.Collections.emptyMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1