use of io.dingodb.exec.base.Task in project dingo by dingodb.
the class DingoJobVisitor method visit.
@Override
public Collection<Output> visit(@Nonnull DingoProject rel) {
Collection<Output> inputs = dingo(rel.getInput()).accept(this);
List<Output> outputs = new ArrayList<>(inputs.size());
for (Output input : inputs) {
Operator operator = new ProjectOperator(RexConverter.toString(rel.getProjects()), TupleSchema.fromRelDataType(rel.getInput().getRowType()));
Task task = input.getTask();
operator.setId(idGenerator.get());
task.putOperator(operator);
input.setLink(operator.getInput(0));
operator.getSoleOutput().copyHint(input);
outputs.addAll(operator.getOutputs());
}
return outputs;
}
use of io.dingodb.exec.base.Task in project dingo by dingodb.
the class JobRunner method distributeTasks.
/**
* Distribute the tasks.
*
* @return the root task
*/
private Task distributeTasks() {
Task rootTask = null;
for (Task task : job.getTasks()) {
if (task.getRoot() != null) {
rootTask = task;
continue;
}
Location location = task.getLocation();
if (!location.equals(Services.META.currentLocation())) {
try {
Channel channel = Services.openNewSysChannel(location.getHost(), location.getPort());
Message msg = SimpleMessage.builder().tag(SimpleTag.TASK_TAG).content(task.serialize()).build();
channel.send(msg);
channel.close();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Error to distribute tasks.", e);
}
}
}
assert rootTask != null : "There must be one and only one root task.";
return rootTask;
}
use of io.dingodb.exec.base.Task 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