Search in sources :

Example 1 with DingoTableScan

use of io.dingodb.calcite.rel.DingoTableScan in project dingo by dingodb.

the class DingoFilterScanRule method onMatch.

@Override
public void onMatch(@Nonnull RelOptRuleCall call) {
    final Filter filter = call.rel(0);
    final DingoTableScan scan = call.rel(1);
    call.transformTo(new DingoTableScan(scan.getCluster(), scan.getTraitSet(), scan.getHints(), scan.getTable(), filter.getCondition(), scan.getSelection()));
}
Also used : Filter(org.apache.calcite.rel.core.Filter) DingoTableScan(io.dingodb.calcite.rel.DingoTableScan)

Example 2 with DingoTableScan

use of io.dingodb.calcite.rel.DingoTableScan in project dingo by dingodb.

the class DingoGetByKeysRule method onMatch.

@Override
public void onMatch(@Nonnull RelOptRuleCall call) {
    final DingoTableScan rel = call.rel(0);
    RexNode rexNode = RexUtil.toDnf(rel.getCluster().getRexBuilder(), rel.getFilter());
    TableDefinition td = dingo(rel.getTable()).getTableDefinition();
    KeyTuplesRexVisitor visitor = new KeyTuplesRexVisitor(td);
    Set<Object[]> keyTuples = rexNode.accept(visitor);
    if (checkKeyTuples(keyTuples)) {
        call.transformTo(new DingoGetByKeys(rel.getCluster(), rel.getTraitSet().replace(DingoConventions.DISTRIBUTED), rel.getTable(), keyTuples, rel.getSelection()));
    }
}
Also used : DingoTableScan(io.dingodb.calcite.rel.DingoTableScan) TableDefinition(io.dingodb.common.table.TableDefinition) DingoGetByKeys(io.dingodb.calcite.rel.DingoGetByKeys) RexNode(org.apache.calcite.rex.RexNode)

Example 3 with DingoTableScan

use of io.dingodb.calcite.rel.DingoTableScan in project dingo by dingodb.

the class DingoProjectScanRule method onMatch.

@Override
public void onMatch(@Nonnull RelOptRuleCall call) {
    final LogicalProject project = call.rel(0);
    final DingoTableScan scan = call.rel(1);
    List<Integer> selectedColumns = getSelectedColumns(project.getProjects());
    DingoTableScan newScan = new DingoTableScan(scan.getCluster(), scan.getTraitSet(), scan.getHints(), scan.getTable(), scan.getFilter(), TupleMapping.of(selectedColumns));
    Mapping mapping = Mappings.target(selectedColumns, scan.getRowType().getFieldCount());
    final List<RexNode> newProjectRexNodes = RexUtil.apply(mapping, project.getProjects());
    if (RexUtil.isIdentity(newProjectRexNodes, newScan.getRowType())) {
        call.transformTo(newScan);
    } else {
        call.transformTo(call.builder().push(newScan).project(newProjectRexNodes).build());
    }
}
Also used : DingoTableScan(io.dingodb.calcite.rel.DingoTableScan) TupleMapping(io.dingodb.common.table.TupleMapping) Mapping(org.apache.calcite.util.mapping.Mapping) LogicalProject(org.apache.calcite.rel.logical.LogicalProject) RexNode(org.apache.calcite.rex.RexNode)

Example 4 with DingoTableScan

use of io.dingodb.calcite.rel.DingoTableScan in project dingo by dingodb.

the class DingoPartScanRule method onMatch.

@Override
public void onMatch(@Nonnull RelOptRuleCall call) {
    DingoTableScan rel = call.rel(0);
    call.transformTo(new DingoPartScan(rel.getCluster(), rel.getTraitSet().replace(DingoConventions.DISTRIBUTED), rel.getTable(), rel.getFilter(), rel.getSelection()));
}
Also used : DingoPartScan(io.dingodb.calcite.rel.DingoPartScan) DingoTableScan(io.dingodb.calcite.rel.DingoTableScan)

Aggregations

DingoTableScan (io.dingodb.calcite.rel.DingoTableScan)4 RexNode (org.apache.calcite.rex.RexNode)2 DingoGetByKeys (io.dingodb.calcite.rel.DingoGetByKeys)1 DingoPartScan (io.dingodb.calcite.rel.DingoPartScan)1 TableDefinition (io.dingodb.common.table.TableDefinition)1 TupleMapping (io.dingodb.common.table.TupleMapping)1 Filter (org.apache.calcite.rel.core.Filter)1 LogicalProject (org.apache.calcite.rel.logical.LogicalProject)1 Mapping (org.apache.calcite.util.mapping.Mapping)1