Search in sources :

Example 16 with Task

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;
}
Also used : SumUpOperator(io.dingodb.exec.operator.SumUpOperator) AggregateOperator(io.dingodb.exec.operator.AggregateOperator) SortOperator(io.dingodb.exec.operator.SortOperator) RootOperator(io.dingodb.exec.operator.RootOperator) PartScanOperator(io.dingodb.exec.operator.PartScanOperator) SendOperator(io.dingodb.exec.operator.SendOperator) ReceiveOperator(io.dingodb.exec.operator.ReceiveOperator) ProjectOperator(io.dingodb.exec.operator.ProjectOperator) ValuesOperator(io.dingodb.exec.operator.ValuesOperator) PartUpdateOperator(io.dingodb.exec.operator.PartUpdateOperator) ReduceOperator(io.dingodb.exec.operator.ReduceOperator) Operator(io.dingodb.exec.base.Operator) GetByKeysOperator(io.dingodb.exec.operator.GetByKeysOperator) PartitionOperator(io.dingodb.exec.operator.PartitionOperator) PartDeleteOperator(io.dingodb.exec.operator.PartDeleteOperator) PartInsertOperator(io.dingodb.exec.operator.PartInsertOperator) CoalesceOperator(io.dingodb.exec.operator.CoalesceOperator) Task(io.dingodb.exec.base.Task) ProjectOperator(io.dingodb.exec.operator.ProjectOperator) Output(io.dingodb.exec.base.Output) ArrayList(java.util.ArrayList)

Example 17 with Task

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;
}
Also used : Task(io.dingodb.exec.base.Task) Message(io.dingodb.net.Message) SimpleMessage(io.dingodb.net.SimpleMessage) Channel(io.dingodb.net.Channel) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Location(io.dingodb.meta.Location)

Example 18 with Task

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);
}
Also used : Task(io.dingodb.exec.base.Task) RootOperator(io.dingodb.exec.operator.RootOperator) ValuesOperator(io.dingodb.exec.operator.ValuesOperator) Location(io.dingodb.meta.Location) Test(org.junit.jupiter.api.Test)

Aggregations

Task (io.dingodb.exec.base.Task)18 Output (io.dingodb.exec.base.Output)12 ValuesOperator (io.dingodb.exec.operator.ValuesOperator)9 RootOperator (io.dingodb.exec.operator.RootOperator)8 SendOperator (io.dingodb.exec.operator.SendOperator)8 GetByKeysOperator (io.dingodb.exec.operator.GetByKeysOperator)7 PartScanOperator (io.dingodb.exec.operator.PartScanOperator)7 PartitionOperator (io.dingodb.exec.operator.PartitionOperator)7 ReceiveOperator (io.dingodb.exec.operator.ReceiveOperator)7 Location (io.dingodb.meta.Location)7 LinkedList (java.util.LinkedList)7 Operator (io.dingodb.exec.base.Operator)6 AggregateOperator (io.dingodb.exec.operator.AggregateOperator)6 CoalesceOperator (io.dingodb.exec.operator.CoalesceOperator)6 PartDeleteOperator (io.dingodb.exec.operator.PartDeleteOperator)6 PartInsertOperator (io.dingodb.exec.operator.PartInsertOperator)6 PartUpdateOperator (io.dingodb.exec.operator.PartUpdateOperator)6 ProjectOperator (io.dingodb.exec.operator.ProjectOperator)6 ReduceOperator (io.dingodb.exec.operator.ReduceOperator)6 SortOperator (io.dingodb.exec.operator.SortOperator)6