Search in sources :

Example 1 with IgniteLogicalIndexScan

use of org.apache.ignite.internal.sql.engine.rel.logical.IgniteLogicalIndexScan in project ignite-3 by apache.

the class ExposeIndexRule method onMatch.

/**
 * {@inheritDoc}
 */
@Override
public void onMatch(RelOptRuleCall call) {
    IgniteLogicalTableScan scan = call.rel(0);
    RelOptCluster cluster = scan.getCluster();
    RelOptTable optTable = scan.getTable();
    InternalIgniteTable igniteTable = optTable.unwrap(InternalIgniteTable.class);
    List<RexNode> proj = scan.projects();
    RexNode condition = scan.condition();
    ImmutableBitSet requiredCols = scan.requiredColumns();
    List<IgniteLogicalIndexScan> indexes = igniteTable.indexes().keySet().stream().map(idxName -> igniteTable.toRel(cluster, optTable, idxName, proj, condition, requiredCols)).collect(Collectors.toList());
    if (indexes.isEmpty()) {
        return;
    }
    Map<RelNode, RelNode> equivMap = new HashMap<>(indexes.size());
    for (int i = 1; i < indexes.size(); i++) {
        equivMap.put(indexes.get(i), scan);
    }
    call.transformTo(indexes.get(0), equivMap);
}
Also used : RelOptCluster(org.apache.calcite.plan.RelOptCluster) RelOptCluster(org.apache.calcite.plan.RelOptCluster) ImmutableBitSet(org.apache.calcite.util.ImmutableBitSet) HashMap(java.util.HashMap) RelRule(org.apache.calcite.plan.RelRule) RelNode(org.apache.calcite.rel.RelNode) Collectors(java.util.stream.Collectors) RelOptRuleCall(org.apache.calcite.plan.RelOptRuleCall) RelOptTable(org.apache.calcite.plan.RelOptTable) RelOptRule(org.apache.calcite.plan.RelOptRule) List(java.util.List) IgniteLogicalIndexScan(org.apache.ignite.internal.sql.engine.rel.logical.IgniteLogicalIndexScan) InternalIgniteTable(org.apache.ignite.internal.sql.engine.schema.InternalIgniteTable) IgniteLogicalTableScan(org.apache.ignite.internal.sql.engine.rel.logical.IgniteLogicalTableScan) RexNode(org.apache.calcite.rex.RexNode) Value(org.immutables.value.Value) Map(java.util.Map) InternalIgniteTable(org.apache.ignite.internal.sql.engine.schema.InternalIgniteTable) ImmutableBitSet(org.apache.calcite.util.ImmutableBitSet) HashMap(java.util.HashMap) IgniteLogicalTableScan(org.apache.ignite.internal.sql.engine.rel.logical.IgniteLogicalTableScan) RelNode(org.apache.calcite.rel.RelNode) IgniteLogicalIndexScan(org.apache.ignite.internal.sql.engine.rel.logical.IgniteLogicalIndexScan) RelOptTable(org.apache.calcite.plan.RelOptTable) RexNode(org.apache.calcite.rex.RexNode)

Aggregations

HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 RelOptCluster (org.apache.calcite.plan.RelOptCluster)1 RelOptRule (org.apache.calcite.plan.RelOptRule)1 RelOptRuleCall (org.apache.calcite.plan.RelOptRuleCall)1 RelOptTable (org.apache.calcite.plan.RelOptTable)1 RelRule (org.apache.calcite.plan.RelRule)1 RelNode (org.apache.calcite.rel.RelNode)1 RexNode (org.apache.calcite.rex.RexNode)1 ImmutableBitSet (org.apache.calcite.util.ImmutableBitSet)1 IgniteLogicalIndexScan (org.apache.ignite.internal.sql.engine.rel.logical.IgniteLogicalIndexScan)1 IgniteLogicalTableScan (org.apache.ignite.internal.sql.engine.rel.logical.IgniteLogicalTableScan)1 InternalIgniteTable (org.apache.ignite.internal.sql.engine.schema.InternalIgniteTable)1 Value (org.immutables.value.Value)1