Search in sources :

Example 6 with Output

use of io.dingodb.exec.base.Output 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)

Example 7 with Output

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

the class DingoJobVisitor method createJob.

@Nonnull
public static Job createJob(RelNode input, boolean addRoot) {
    IdGenerator idGenerator = new IdGenerator();
    DingoJobVisitor visitor = new DingoJobVisitor(idGenerator);
    Collection<Output> outputs = dingo(input).accept(visitor);
    if (addRoot) {
        if (outputs.size() == 1) {
            Output output = sole(outputs);
            Task task = output.getTask();
            RootOperator root = new RootOperator(TupleSchema.fromRelDataType(input.getRowType()));
            root.setId(idGenerator.get());
            task.putOperator(root);
            output.setLink(root.getInput(0));
        } else if (!outputs.isEmpty()) {
            throw new IllegalStateException("There must be zero or one output to job root.");
        }
    }
    Job job = visitor.getJob();
    log.info("job = {}", job);
    return job;
}
Also used : Task(io.dingodb.exec.base.Task) Output(io.dingodb.exec.base.Output) RootOperator(io.dingodb.exec.operator.RootOperator) IdGenerator(io.dingodb.exec.base.IdGenerator) Job(io.dingodb.exec.base.Job) Nonnull(javax.annotation.Nonnull)

Example 8 with Output

use of io.dingodb.exec.base.Output 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)

Example 9 with Output

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

the class DingoJobVisitor method visit.

@Override
public Collection<Output> visit(@Nonnull DingoPartScan rel) {
    String tableName = getSimpleName(rel.getTable());
    TableDefinition td = Services.META.getTableDefinition(tableName);
    Map<String, Location> parts = Services.META.getPartLocations(tableName);
    List<Output> outputs = new ArrayList<>(parts.size());
    TableId tableId = new TableId(Services.META.getTableKey(tableName));
    String filterStr = null;
    if (rel.getFilter() != null) {
        filterStr = RexConverter.convert(rel.getFilter()).toString();
    }
    for (Map.Entry<String, Location> entry : parts.entrySet()) {
        final Object partId = entry.getKey();
        PartScanOperator operator = new PartScanOperator(tableId, entry.getKey(), td.getTupleSchema(), td.getKeyMapping(), filterStr, rel.getSelection());
        operator.setId(idGenerator.get());
        Task task = job.getOrCreate(entry.getValue());
        task.putOperator(operator);
        operator.getSoleOutput().setHint(OutputHint.of(tableName, partId));
        outputs.addAll(operator.getOutputs());
    }
    return outputs;
}
Also used : TableId(io.dingodb.common.table.TableId) Task(io.dingodb.exec.base.Task) ArrayList(java.util.ArrayList) PartScanOperator(io.dingodb.exec.operator.PartScanOperator) Output(io.dingodb.exec.base.Output) TableDefinition(io.dingodb.common.table.TableDefinition) Map(java.util.Map) Location(io.dingodb.meta.Location)

Example 10 with Output

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

the class DingoJobVisitor method visit.

@Override
public Collection<Output> visit(@Nonnull DingoGetByKeys rel) {
    String tableName = getSimpleName(rel.getTable());
    final Map<String, Location> partLocations = Services.META.getPartLocations(tableName);
    final TableDefinition td = Services.META.getTableDefinition(tableName);
    final PartitionStrategy ps = new SimpleHashStrategy(partLocations.size());
    final TableId tableId = new TableId(Services.META.getTableKey(tableName));
    Map<String, List<Object[]>> partMap = ps.partKeyTuples(rel.getKeyTuples());
    List<Output> outputs = new LinkedList<>();
    for (Map.Entry<String, List<Object[]>> entry : partMap.entrySet()) {
        final Object partId = entry.getKey();
        GetByKeysOperator operator = new GetByKeysOperator(tableId, partId, td.getTupleSchema(), td.getKeyMapping(), entry.getValue(), rel.getSelection());
        operator.setId(idGenerator.get());
        Task task = job.getOrCreate(partLocations.get(entry.getKey()));
        task.putOperator(operator);
        operator.getSoleOutput().setHint(OutputHint.of(tableName, partId));
        outputs.addAll(operator.getOutputs());
    }
    return outputs;
}
Also used : TableId(io.dingodb.common.table.TableId) Task(io.dingodb.exec.base.Task) LinkedList(java.util.LinkedList) GetByKeysOperator(io.dingodb.exec.operator.GetByKeysOperator) Output(io.dingodb.exec.base.Output) TableDefinition(io.dingodb.common.table.TableDefinition) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) SimpleHashStrategy(io.dingodb.exec.partition.SimpleHashStrategy) Map(java.util.Map) Location(io.dingodb.meta.Location) PartitionStrategy(io.dingodb.exec.partition.PartitionStrategy)

Aggregations

Output (io.dingodb.exec.base.Output)13 Task (io.dingodb.exec.base.Task)12 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 RootOperator (io.dingodb.exec.operator.RootOperator)7 SendOperator (io.dingodb.exec.operator.SendOperator)7 ValuesOperator (io.dingodb.exec.operator.ValuesOperator)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 SumUpOperator (io.dingodb.exec.operator.SumUpOperator)6