Search in sources :

Example 6 with IgniteCostFactory

use of org.apache.ignite.internal.sql.engine.metadata.cost.IgniteCostFactory in project ignite-3 by apache.

the class IgniteReduceHashAggregate method computeSelfCost.

/**
 * {@inheritDoc}
 */
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
    IgniteCostFactory costFactory = (IgniteCostFactory) planner.getCostFactory();
    double rows = mq.getRowCount(getInput());
    double mem = 0d;
    if (aggCalls.isEmpty()) {
        mem = groupSet.cardinality() * IgniteCost.AVERAGE_FIELD_SIZE;
    } else {
        for (AggregateCall aggCall : aggCalls) {
            if (aggCall.isDistinct()) {
                mem += IgniteCost.AGG_CALL_MEM_COST * rows;
            } else {
                mem += IgniteCost.AGG_CALL_MEM_COST;
            }
        }
    }
    return costFactory.makeCost(rows, rows * IgniteCost.ROW_PASS_THROUGH_COST, 0, mem, 0);
}
Also used : AggregateCall(org.apache.calcite.rel.core.AggregateCall) IgniteCostFactory(org.apache.ignite.internal.sql.engine.metadata.cost.IgniteCostFactory)

Example 7 with IgniteCostFactory

use of org.apache.ignite.internal.sql.engine.metadata.cost.IgniteCostFactory in project ignite-3 by apache.

the class IgniteReduceSortAggregate method computeSelfCost.

/**
 * {@inheritDoc}
 */
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
    IgniteCostFactory costFactory = (IgniteCostFactory) planner.getCostFactory();
    double rows = mq.getRowCount(getInput());
    return costFactory.makeCost(rows, rows * IgniteCost.ROW_PASS_THROUGH_COST, 0);
}
Also used : IgniteCostFactory(org.apache.ignite.internal.sql.engine.metadata.cost.IgniteCostFactory)

Example 8 with IgniteCostFactory

use of org.apache.ignite.internal.sql.engine.metadata.cost.IgniteCostFactory in project ignite-3 by apache.

the class IgniteSetOp method computeSetOpCost.

/**
 * Compute cost for set op.
 */
public default RelOptCost computeSetOpCost(RelOptPlanner planner, RelMetadataQuery mq) {
    IgniteCostFactory costFactory = (IgniteCostFactory) planner.getCostFactory();
    double inputRows = 0;
    for (RelNode input : getInputs()) {
        inputRows += mq.getRowCount(input);
    }
    double mem = 0.5 * inputRows * aggregateFieldsCount() * IgniteCost.AVERAGE_FIELD_SIZE;
    return costFactory.makeCost(inputRows, inputRows * IgniteCost.ROW_PASS_THROUGH_COST, 0, mem, 0);
}
Also used : IgniteCostFactory(org.apache.ignite.internal.sql.engine.metadata.cost.IgniteCostFactory) RelNode(org.apache.calcite.rel.RelNode)

Example 9 with IgniteCostFactory

use of org.apache.ignite.internal.sql.engine.metadata.cost.IgniteCostFactory in project ignite-3 by apache.

the class IgniteMinusBase method computeSelfCost.

/**
 * {@inheritDoc}
 */
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
    IgniteCostFactory costFactory = (IgniteCostFactory) planner.getCostFactory();
    double rows = estimateRowCount(mq);
    double inputRows = 0;
    for (RelNode input : getInputs()) {
        inputRows += mq.getRowCount(input);
    }
    double mem = 0.5 * inputRows * aggregateFieldsCount() * IgniteCost.AVERAGE_FIELD_SIZE;
    return costFactory.makeCost(rows, inputRows * IgniteCost.ROW_PASS_THROUGH_COST, 0, mem, 0);
}
Also used : IgniteCostFactory(org.apache.ignite.internal.sql.engine.metadata.cost.IgniteCostFactory) RelNode(org.apache.calcite.rel.RelNode)

Example 10 with IgniteCostFactory

use of org.apache.ignite.internal.sql.engine.metadata.cost.IgniteCostFactory in project ignite-3 by apache.

the class IgniteAggregate method computeSelfCostHash.

/**
 * ComputeSelfCostHash.
 * TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
 */
public RelOptCost computeSelfCostHash(RelOptPlanner planner, RelMetadataQuery mq) {
    IgniteCostFactory costFactory = (IgniteCostFactory) planner.getCostFactory();
    double inRows = mq.getRowCount(getInput());
    double groups = estimateRowCount(mq);
    return costFactory.makeCost(inRows, inRows * IgniteCost.ROW_PASS_THROUGH_COST, 0, groups * estimateMemoryForGroup(mq), 0);
}
Also used : IgniteCostFactory(org.apache.ignite.internal.sql.engine.metadata.cost.IgniteCostFactory)

Aggregations

IgniteCostFactory (org.apache.ignite.internal.sql.engine.metadata.cost.IgniteCostFactory)15 RelNode (org.apache.calcite.rel.RelNode)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 RelOptCost (org.apache.calcite.plan.RelOptCost)1 RelTraitSet (org.apache.calcite.plan.RelTraitSet)1 RelRoot (org.apache.calcite.rel.RelRoot)1 AggregateCall (org.apache.calcite.rel.core.AggregateCall)1 RelDataTypeFactory (org.apache.calcite.rel.type.RelDataTypeFactory)1 SchemaPlus (org.apache.calcite.schema.SchemaPlus)1 SqlNode (org.apache.calcite.sql.SqlNode)1 Frameworks.newConfigBuilder (org.apache.calcite.tools.Frameworks.newConfigBuilder)1 IgnitePlanner (org.apache.ignite.internal.sql.engine.prepare.IgnitePlanner)1 PlanningContext (org.apache.ignite.internal.sql.engine.prepare.PlanningContext)1 IgniteRel (org.apache.ignite.internal.sql.engine.rel.IgniteRel)1 IgniteSchema (org.apache.ignite.internal.sql.engine.schema.IgniteSchema)1 IgniteTypeFactory (org.apache.ignite.internal.sql.engine.type.IgniteTypeFactory)1 Test (org.junit.jupiter.api.Test)1