Search in sources :

Example 1 with GetByKeysOperator

use of io.dingodb.exec.operator.GetByKeysOperator 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)1 TableId (io.dingodb.common.table.TableId)1 Output (io.dingodb.exec.base.Output)1 Task (io.dingodb.exec.base.Task)1 GetByKeysOperator (io.dingodb.exec.operator.GetByKeysOperator)1 PartitionStrategy (io.dingodb.exec.partition.PartitionStrategy)1 SimpleHashStrategy (io.dingodb.exec.partition.SimpleHashStrategy)1 Location (io.dingodb.meta.Location)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1