Search in sources :

Example 1 with PartitionOperator

use of io.dingodb.exec.operator.PartitionOperator in project dingo by dingodb.

the class DingoJobVisitor method visit.

@Override
public Collection<Output> visit(@Nonnull DingoPartition rel) {
    Collection<Output> inputs = dingo(rel.getInput()).accept(this);
    String tableName = getSimpleName(rel.getTable());
    List<Output> outputs = new LinkedList<>();
    final Map<String, Location> partLocations = Services.META.getPartLocations(tableName);
    final TableDefinition td = Services.META.getTableDefinition(tableName);
    final PartitionStrategy ps = new SimpleHashStrategy(partLocations.size());
    for (Output input : inputs) {
        Task task = input.getTask();
        PartitionOperator operator = new PartitionOperator(ps, td.getKeyMapping());
        operator.setId(idGenerator.get());
        operator.createOutputs(tableName, partLocations);
        task.putOperator(operator);
        input.setLink(operator.getInput(0));
        outputs.addAll(operator.getOutputs());
    }
    return outputs;
}
Also used : Task(io.dingodb.exec.base.Task) PartitionOperator(io.dingodb.exec.operator.PartitionOperator) Output(io.dingodb.exec.base.Output) TableDefinition(io.dingodb.common.table.TableDefinition) SimpleHashStrategy(io.dingodb.exec.partition.SimpleHashStrategy) LinkedList(java.util.LinkedList) Location(io.dingodb.meta.Location) PartitionStrategy(io.dingodb.exec.partition.PartitionStrategy)

Aggregations

TableDefinition (io.dingodb.common.table.TableDefinition)1 Output (io.dingodb.exec.base.Output)1 Task (io.dingodb.exec.base.Task)1 PartitionOperator (io.dingodb.exec.operator.PartitionOperator)1 PartitionStrategy (io.dingodb.exec.partition.PartitionStrategy)1 SimpleHashStrategy (io.dingodb.exec.partition.SimpleHashStrategy)1 Location (io.dingodb.meta.Location)1 LinkedList (java.util.LinkedList)1