use of io.dingodb.exec.operator.PartUpdateOperator 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;
}
Aggregations