use of io.dingodb.calcite.rel.DingoExchange in project dingo by dingodb.
the class DingoAggregateRule method onMatch.
@Override
public void onMatch(@Nonnull RelOptRuleCall call) {
Aggregate rel = call.rel(0);
// AVG must be transformed to SUM/COUNT before.
if (rel.getAggCallList().stream().anyMatch(agg -> agg.getAggregation().getKind() == SqlKind.AVG)) {
return;
}
RelOptCluster cluster = rel.getCluster();
TupleMapping keyMapping = getAggKeys(rel);
List<Agg> aggList = getAggList(rel);
call.transformTo(new DingoReduce(cluster, rel.getTraitSet().replace(DingoConventions.ROOT), new DingoExchange(cluster, rel.getTraitSet().replace(DingoConventions.PARTITIONED), new DingoAggregate(cluster, rel.getTraitSet().replace(DingoConventions.DISTRIBUTED), convert(rel.getInput(), DingoConventions.DISTRIBUTED), keyMapping, aggList, rel.getRowType())), keyMapping, aggList));
}
use of io.dingodb.calcite.rel.DingoExchange in project dingo by dingodb.
the class DingoExchangeRule method onMatch.
@Override
public void onMatch(@Nonnull RelOptRuleCall call) {
RelNode rel = call.rel(0);
RelOptCluster cluster = rel.getCluster();
call.transformTo(new DingoExchange(cluster, cluster.traitSetOf(DingoConventions.PARTITIONED), rel));
}
use of io.dingodb.calcite.rel.DingoExchange in project dingo by dingodb.
the class DingoPartModifyRule method onMatch.
@Override
public void onMatch(@Nonnull RelOptRuleCall call) {
DingoTableModify rel = call.rel(0);
RelNode input = rel.getInput();
RelNode convertedInput = null;
RelOptCluster cluster = rel.getCluster();
switch(rel.getOperation()) {
case INSERT:
convertedInput = new DingoExchange(cluster, rel.getTraitSet().replace(DingoConventions.DISTRIBUTED), new DingoPartition(cluster, rel.getTraitSet().replace(DingoConventions.DISTRIBUTED), convert(input, DingoConventions.DISTRIBUTED), rel.getTable()));
break;
case UPDATE:
// Only support update in part.
checkUpdateInPart(rel);
convertedInput = convert(input, DingoConventions.DISTRIBUTED);
break;
case DELETE:
convertedInput = convert(input, DingoConventions.DISTRIBUTED);
break;
default:
throw new IllegalStateException("Operation \"" + rel.getOperation() + "\" is not supported.");
}
call.transformTo(new DingoPartModify(cluster, rel.getTraitSet().replace(DingoConventions.DISTRIBUTED), convertedInput, rel.getTable(), rel.getOperation(), rel.getUpdateColumnList(), rel.getSourceExpressionList()));
}
use of io.dingodb.calcite.rel.DingoExchange in project dingo by dingodb.
the class TestDingoJobVisitor method testVisitExchange.
@Test
public void testVisitExchange() {
RelOptCluster cluster = parser.getCluster();
DingoExchange exchange = new DingoExchange(cluster, cluster.traitSetOf(DingoConventions.PARTITIONED), new DingoPartScan(cluster, cluster.traitSetOf(DingoConventions.DISTRIBUTED), table));
Job job = DingoJobVisitor.createJob(exchange);
Assert.job(job).taskNum(2).task(0, t -> t.operatorNum(2).location(MockMetaServiceProvider.LOC_0).sourceNum(2).source(0, s -> s.isPartScan(TABLE_ID, "0").soleOutput().isNull()).source(1, s -> s.isA(ReceiveOperator.class).soleOutput().isNull())).task(1, t -> t.operatorNum(2).location(MockMetaServiceProvider.LOC_1).soleSource().isPartScan(TABLE_ID, "1").soleOutput().isA(SendOperator.class));
}
use of io.dingodb.calcite.rel.DingoExchange in project dingo by dingodb.
the class TestDingoJobVisitor method testVisitCoalesce.
@Test
public void testVisitCoalesce() {
RelOptCluster cluster = parser.getCluster();
DingoCoalesce coalesce = new DingoCoalesce(cluster, cluster.traitSetOf(DingoConventions.ROOT), new DingoExchange(cluster, cluster.traitSetOf(DingoConventions.PARTITIONED), new DingoPartScan(cluster, cluster.traitSetOf(DingoConventions.DISTRIBUTED), table)));
Job job = DingoJobVisitor.createJob(coalesce);
Assert.job(job).taskNum(2).task(0, t -> t.operatorNum(3).location(MockMetaServiceProvider.LOC_0).sourceNum(2).source(0, s -> s.isPartScan(TABLE_ID, "0").soleOutput().isA(CoalesceOperator.class)).source(1, s -> s.isA(ReceiveOperator.class).soleOutput().isA(CoalesceOperator.class))).task(1, t -> t.operatorNum(2).location(MockMetaServiceProvider.LOC_1).soleSource().isPartScan(TABLE_ID, "1").soleOutput().isA(SendOperator.class));
}
Aggregations