use of io.dingodb.exec.operator.RootOperator in project dingo by dingodb.
the class DingoJobVisitor method createJob.
@Nonnull
public static Job createJob(RelNode input, boolean addRoot) {
IdGenerator idGenerator = new IdGenerator();
DingoJobVisitor visitor = new DingoJobVisitor(idGenerator);
Collection<Output> outputs = dingo(input).accept(visitor);
if (addRoot) {
if (outputs.size() == 1) {
Output output = sole(outputs);
Task task = output.getTask();
RootOperator root = new RootOperator(TupleSchema.fromRelDataType(input.getRowType()));
root.setId(idGenerator.get());
task.putOperator(root);
output.setLink(root.getInput(0));
} else if (!outputs.isEmpty()) {
throw new IllegalStateException("There must be zero or one output to job root.");
}
}
Job job = visitor.getJob();
log.info("job = {}", job);
return job;
}
use of io.dingodb.exec.operator.RootOperator in project dingo by dingodb.
the class TestTaskImpl method testValues.
@Test
public void testValues() {
Task task = new TaskImpl("", Mockito.mock(Location.class));
ValuesOperator values = new ValuesOperator(ImmutableList.of(new Object[] { 1, "Alice", 1.0 }, new Object[] { 2, "Betty", 2.0 }));
values.setId(idGenerator.get());
task.putOperator(values);
RootOperator root = new RootOperator(TupleSchema.ofTypes("INTEGER", "STRING", "DOUBLE"));
root.setId(idGenerator.get());
task.putOperator(root);
values.getOutputs().get(0).setLink(root.getInput(0));
task.init();
task.run();
assertThat(root.popValue()).containsExactly(1, "Alice", 1.0);
task.run();
assertThat(root.popValue()).containsExactly(2, "Betty", 2.0);
}
Aggregations