use of io.dingodb.exec.base.Job in project dingo by dingodb.
the class JobRunner method runOneColumn.
@SuppressWarnings("unused")
@Nonnull
public static Enumerable<Object> runOneColumn(String serializedJob) {
try {
final Job job = JobImpl.fromString(serializedJob);
final JobRunner runner = new JobRunner(job);
return new AbstractEnumerable<Object>() {
@Override
public Enumerator<Object> enumerator() {
return runner.createEnumeratorSingleColumn();
}
};
} catch (JsonProcessingException e) {
throw new RuntimeException("Cannot deserialize job.", e);
}
}
use of io.dingodb.exec.base.Job in project dingo by dingodb.
the class TestDingoJobVisitor method testVisitPartScan.
@Test
public void testVisitPartScan() {
RelOptCluster cluster = parser.getCluster();
DingoPartScan partScan = new DingoPartScan(cluster, cluster.traitSetOf(DingoConventions.DISTRIBUTED), table);
Job job = DingoJobVisitor.createJob(partScan);
Assert.job(job).taskNum(2).task(0, t -> t.operatorNum(1).location(MockMetaServiceProvider.LOC_0).soleSource().isPartScan(TABLE_ID, "0").soleOutput().isNull()).task(1, t -> t.operatorNum(1).location(MockMetaServiceProvider.LOC_1).soleSource().isPartScan(TABLE_ID, "1").soleOutput().isNull());
}
use of io.dingodb.exec.base.Job in project dingo by dingodb.
the class EnumerableRoot method implement.
@Nullable
@Override
public Result implement(@Nonnull EnumerableRelImplementor implementor, @Nonnull Prefer pref) {
PhysType physType = PhysTypeImpl.of(implementor.getTypeFactory(), getRowType(), pref.preferArray());
RelNode input = getInput();
assert input instanceof DingoRel : "The input must be DINGO.";
Job job = DingoJobVisitor.createJob(input, true);
// The result set would be treated as `Object` instead of `Object[]` if the result has only one column.
String methodName = getRowType().getFieldCount() == 1 ? "runOneColumn" : "run";
try {
Method method = JobRunner.class.getMethod(methodName, String.class);
return implementor.result(physType, Blocks.toBlock(Expressions.call(method, Expressions.constant(job.toString()))));
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
return null;
}
use of io.dingodb.exec.base.Job 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.exec.base.Job 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