Search in sources :

Example 1 with PartitionStrategy

use of io.dingodb.exec.partition.PartitionStrategy in project dingo by dingodb.

the class DingoJobVisitor method visit.

@Override
public Collection<Output> visit(@Nonnull DingoDistributedValues rel) {
    List<Output> outputs = new LinkedList<>();
    String tableName = getSimpleName(rel.getTable());
    final Map<String, Location> partLocations = Services.META.getPartLocations(tableName);
    final PartitionStrategy ps = new SimpleHashStrategy(partLocations.size());
    final TableDefinition td = Services.META.getTableDefinition(tableName);
    Map<String, List<Object[]>> partMap = ps.partTuples(rel.getValues(), td.getKeyMapping());
    for (Map.Entry<String, List<Object[]>> entry : partMap.entrySet()) {
        Object partId = entry.getKey();
        ValuesOperator operator = new ValuesOperator(entry.getValue());
        operator.setId(idGenerator.get());
        OutputHint hint = new OutputHint();
        hint.setPartId(partId);
        Location location = partLocations.get(partId);
        hint.setLocation(location);
        operator.getSoleOutput().setHint(hint);
        Task task = job.getOrCreate(location);
        task.putOperator(operator);
        outputs.addAll(operator.getOutputs());
    }
    return outputs;
}
Also used : Task(io.dingodb.exec.base.Task) LinkedList(java.util.LinkedList) OutputHint(io.dingodb.exec.base.OutputHint) 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) ValuesOperator(io.dingodb.exec.operator.ValuesOperator) Map(java.util.Map) Location(io.dingodb.meta.Location) PartitionStrategy(io.dingodb.exec.partition.PartitionStrategy)

Example 2 with PartitionStrategy

use of io.dingodb.exec.partition.PartitionStrategy 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 3 with PartitionStrategy

use of io.dingodb.exec.partition.PartitionStrategy 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

TableDefinition (io.dingodb.common.table.TableDefinition)3 Output (io.dingodb.exec.base.Output)3 Task (io.dingodb.exec.base.Task)3 PartitionStrategy (io.dingodb.exec.partition.PartitionStrategy)3 SimpleHashStrategy (io.dingodb.exec.partition.SimpleHashStrategy)3 Location (io.dingodb.meta.Location)3 LinkedList (java.util.LinkedList)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 TableId (io.dingodb.common.table.TableId)1 OutputHint (io.dingodb.exec.base.OutputHint)1 GetByKeysOperator (io.dingodb.exec.operator.GetByKeysOperator)1 PartitionOperator (io.dingodb.exec.operator.PartitionOperator)1 ValuesOperator (io.dingodb.exec.operator.ValuesOperator)1