Search in sources :

Example 1 with Operator

use of io.dingodb.exec.base.Operator in project dingo by dingodb.

the class TaskImpl method run.

public void run() {
    log.info("Task is starting at {}...", location);
    runList.forEach(id -> {
        final Operator operator = operators.get(id);
        assert operator instanceof SourceOperator : "Operators in run list must be source operator.";
        executorService.execute(() -> {
            try {
                while (operator.push(0, null)) {
                    log.info("Operator {} need another pushing.", operator.getId());
                }
                operator.fin(0, null);
            } catch (RuntimeException e) {
                e.printStackTrace();
                log.error("Operator:{} run catch Exception:{}", operator.getId(), e.toString(), e);
            }
        });
    });
}
Also used : AbstractOperator(io.dingodb.exec.operator.AbstractOperator) SourceOperator(io.dingodb.exec.operator.SourceOperator) RootOperator(io.dingodb.exec.operator.RootOperator) Operator(io.dingodb.exec.base.Operator) SourceOperator(io.dingodb.exec.operator.SourceOperator)

Example 2 with Operator

use of io.dingodb.exec.base.Operator in project dingo by dingodb.

the class DingoJobVisitor method visit.

@Override
public Collection<Output> visit(@Nonnull DingoCoalesce rel) {
    Collection<Output> inputs = dingo(rel.getInput()).accept(this);
    int size = inputs.size();
    if (size <= 1) {
        return inputs;
    }
    Output one = inputs.iterator().next();
    boolean isToSumUp = one.isToSumUp();
    Operator operator = isToSumUp ? new SumUpOperator(size) : new CoalesceOperator(size);
    operator.setId(idGenerator.get());
    Task task = one.getTask();
    task.putOperator(operator);
    int i = 0;
    for (Output input : inputs) {
        assert input.getTask().equals(task) : "Operator linked must be in the same task.";
        assert input.isToSumUp() == isToSumUp : "All inputs must have the same \"toSumUp\" hint.";
        input.setLink(operator.getInput(i));
        ++i;
    }
    return operator.getOutputs();
}
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) CoalesceOperator(io.dingodb.exec.operator.CoalesceOperator) Output(io.dingodb.exec.base.Output) SumUpOperator(io.dingodb.exec.operator.SumUpOperator) OutputHint(io.dingodb.exec.base.OutputHint)

Example 3 with Operator

use of io.dingodb.exec.base.Operator in project dingo by dingodb.

the class DingoJobVisitor method visit.

@Override
public Collection<Output> visit(@Nonnull DingoReduce rel) {
    Collection<Output> inputs = dingo(rel.getInput()).accept(this);
    int size = inputs.size();
    if (size <= 1) {
        return inputs;
    }
    Operator operator;
    operator = new ReduceOperator(inputs.size(), rel.getKeyMapping(), rel.getAggList());
    operator.setId(idGenerator.get());
    Output one = inputs.iterator().next();
    Task task = one.getTask();
    task.putOperator(operator);
    int i = 0;
    for (Output input : inputs) {
        assert input.getTask().equals(task) : "Operator linked must be in the same task.";
        input.setLink(operator.getInput(i));
        ++i;
    }
    return operator.getOutputs();
}
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) Output(io.dingodb.exec.base.Output) ReduceOperator(io.dingodb.exec.operator.ReduceOperator) OutputHint(io.dingodb.exec.base.OutputHint)

Example 4 with Operator

use of io.dingodb.exec.base.Operator in project dingo by dingodb.

the class DingoJobVisitor method visit.

@Override
public Collection<Output> visit(@Nonnull DingoPartModify rel) {
    Collection<Output> inputs = dingo(rel.getInput()).accept(this);
    String tableName = getSimpleName(rel.getTable());
    List<Output> outputs = new LinkedList<>();
    TableDefinition td = Services.META.getTableDefinition(tableName);
    final TableId tableId = new TableId(Services.META.getTableKey(tableName));
    for (Output input : inputs) {
        Task task = input.getTask();
        Operator operator;
        switch(rel.getOperation()) {
            case INSERT:
                operator = new PartInsertOperator(tableId, input.getHint().getPartId(), td.getTupleSchema(), td.getKeyMapping());
                break;
            case UPDATE:
                operator = new PartUpdateOperator(tableId, input.getHint().getPartId(), td.getTupleSchema(), td.getKeyMapping(), TupleMapping.of(td.getColumnIndices(rel.getUpdateColumnList())), rel.getSourceExpressionList().stream().map(RexConverter::toString).collect(Collectors.toList()));
                break;
            case DELETE:
                operator = new PartDeleteOperator(tableId, input.getHint().getPartId(), td.getTupleSchema(), td.getKeyMapping());
                break;
            default:
                throw new IllegalStateException("Operation \"" + rel.getOperation() + "\" is not supported.");
        }
        operator.setId(idGenerator.get());
        task.putOperator(operator);
        input.setLink(operator.getInput(0));
        OutputHint hint = new OutputHint();
        hint.setToSumUp(true);
        operator.getSoleOutput().setHint(hint);
        outputs.addAll(operator.getOutputs());
    }
    return outputs;
}
Also used : TableId(io.dingodb.common.table.TableId) 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) PartUpdateOperator(io.dingodb.exec.operator.PartUpdateOperator) PartDeleteOperator(io.dingodb.exec.operator.PartDeleteOperator) LinkedList(java.util.LinkedList) PartInsertOperator(io.dingodb.exec.operator.PartInsertOperator) OutputHint(io.dingodb.exec.base.OutputHint) Output(io.dingodb.exec.base.Output) TableDefinition(io.dingodb.common.table.TableDefinition)

Example 5 with Operator

use of io.dingodb.exec.base.Operator in project dingo by dingodb.

the class DingoJobVisitor method visit.

@Override
public Collection<Output> visit(@Nonnull DingoSort rel) {
    Collection<Output> inputs = dingo(rel.getInput()).accept(this);
    List<Output> outputs = new LinkedList<>();
    for (Output input : inputs) {
        Operator operator = new SortOperator(rel.getCollation().getFieldCollations().stream().map(c -> new SortCollation(c.getFieldIndex(), c.direction, c.nullDirection)).collect(Collectors.toList()), rel.fetch == null ? -1 : RexLiteral.intValue(rel.fetch), rel.offset == null ? 0 : RexLiteral.intValue(rel.offset));
        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) Output(io.dingodb.exec.base.Output) LinkedList(java.util.LinkedList) SortCollation(io.dingodb.exec.operator.SortCollation) SortOperator(io.dingodb.exec.operator.SortOperator)

Aggregations

Operator (io.dingodb.exec.base.Operator)7 RootOperator (io.dingodb.exec.operator.RootOperator)7 Output (io.dingodb.exec.base.Output)6 Task (io.dingodb.exec.base.Task)6 AggregateOperator (io.dingodb.exec.operator.AggregateOperator)6 CoalesceOperator (io.dingodb.exec.operator.CoalesceOperator)6 GetByKeysOperator (io.dingodb.exec.operator.GetByKeysOperator)6 PartDeleteOperator (io.dingodb.exec.operator.PartDeleteOperator)6 PartInsertOperator (io.dingodb.exec.operator.PartInsertOperator)6 PartScanOperator (io.dingodb.exec.operator.PartScanOperator)6 PartUpdateOperator (io.dingodb.exec.operator.PartUpdateOperator)6 PartitionOperator (io.dingodb.exec.operator.PartitionOperator)6 ProjectOperator (io.dingodb.exec.operator.ProjectOperator)6 ReceiveOperator (io.dingodb.exec.operator.ReceiveOperator)6 ReduceOperator (io.dingodb.exec.operator.ReduceOperator)6 SendOperator (io.dingodb.exec.operator.SendOperator)6 SortOperator (io.dingodb.exec.operator.SortOperator)6 SumUpOperator (io.dingodb.exec.operator.SumUpOperator)6 ValuesOperator (io.dingodb.exec.operator.ValuesOperator)6 OutputHint (io.dingodb.exec.base.OutputHint)3