Search in sources :

Example 11 with IgniteCostFactory

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

the class IgniteAggregate method computeSelfCostSort.

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

Example 12 with IgniteCostFactory

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

the class IgniteTableSpool method computeSelfCost.

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

Example 13 with IgniteCostFactory

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

the class IgniteExchange method computeSelfCost.

/**
 * {@inheritDoc}
 */
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
    double rowCount = mq.getRowCount(getInput());
    double bytesPerRow = getRowType().getFieldCount() * IgniteCost.AVERAGE_FIELD_SIZE;
    double totalBytes = rowCount * bytesPerRow;
    IgniteCostFactory costFactory = (IgniteCostFactory) planner.getCostFactory();
    if (RelDistributions.BROADCAST_DISTRIBUTED.equals(distribution)) {
        totalBytes *= IgniteCost.BROADCAST_DISTRIBUTION_PENALTY;
    }
    return costFactory.makeCost(rowCount, rowCount * IgniteCost.ROW_PASS_THROUGH_COST, 0, 0, totalBytes);
}
Also used : IgniteCostFactory(org.apache.ignite.internal.sql.engine.metadata.cost.IgniteCostFactory)

Example 14 with IgniteCostFactory

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

the class IgniteMergeJoin method computeSelfCost.

/**
 * {@inheritDoc}
 */
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
    IgniteCostFactory costFactory = (IgniteCostFactory) planner.getCostFactory();
    double leftCount = mq.getRowCount(getLeft());
    if (Double.isInfinite(leftCount)) {
        return costFactory.makeInfiniteCost();
    }
    double rightCount = mq.getRowCount(getRight());
    if (Double.isInfinite(rightCount)) {
        return costFactory.makeInfiniteCost();
    }
    double rows = leftCount + rightCount;
    return costFactory.makeCost(rows, rows * (IgniteCost.ROW_COMPARISON_COST + IgniteCost.ROW_PASS_THROUGH_COST), 0);
}
Also used : IgniteCostFactory(org.apache.ignite.internal.sql.engine.metadata.cost.IgniteCostFactory)

Example 15 with IgniteCostFactory

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

the class IgniteNestedLoopJoin method computeSelfCost.

/**
 * {@inheritDoc}
 */
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
    IgniteCostFactory costFactory = (IgniteCostFactory) planner.getCostFactory();
    double leftCount = mq.getRowCount(getLeft());
    if (Double.isInfinite(leftCount)) {
        return costFactory.makeInfiniteCost();
    }
    double rightCount = mq.getRowCount(getRight());
    if (Double.isInfinite(rightCount)) {
        return costFactory.makeInfiniteCost();
    }
    double rows = leftCount * rightCount;
    double rightSize = rightCount * getRight().getRowType().getFieldCount() * IgniteCost.AVERAGE_FIELD_SIZE;
    return costFactory.makeCost(rows, rows * (IgniteCost.ROW_COMPARISON_COST + IgniteCost.ROW_PASS_THROUGH_COST), 0, rightSize, 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