use of io.dingodb.meta.Location in project dingo by dingodb.
the class DingoJobVisitor method visit.
@Override
public Collection<Output> visit(@Nonnull DingoExchange rel) {
Collection<Output> inputs = dingo(rel.getInput()).accept(this);
List<Output> outputs = new LinkedList<>();
TupleSchema schema = TupleSchema.fromRelDataType(rel.getRowType());
for (Output input : inputs) {
Task task = input.getTask();
Location target = input.getTargetLocation();
if (target == null) {
target = Services.META.currentLocation();
}
if (!target.equals(task.getLocation())) {
Id id = idGenerator.get();
Id receiveId = idGenerator.get();
SendOperator send = new SendOperator(target.getHost(), target.getPort(), receiveId, schema);
send.setId(id);
task.putOperator(send);
input.setLink(send.getInput(0));
ReceiveOperator receive = new ReceiveOperator(task.getHost(), task.getLocation().getPort(), schema);
receive.setId(receiveId);
receive.getSoleOutput().copyHint(input);
Task rcvTask = job.getOrCreate(target);
rcvTask.putOperator(receive);
outputs.addAll(receive.getOutputs());
} else {
outputs.add(input);
}
}
return outputs;
}
use of io.dingodb.meta.Location 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;
}
use of io.dingodb.meta.Location 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;
}
use of io.dingodb.meta.Location 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;
}
use of io.dingodb.meta.Location 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;
}
Aggregations