use of io.dingodb.exec.operator.ValuesOperator 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.exec.operator.ValuesOperator in project dingo by dingodb.
the class TestDingoJobVisitor method testVisitValues.
@Test
public void testVisitValues() {
Job job = DingoJobVisitor.createJob(values);
ValuesOperator operator = (ValuesOperator) Assert.job(job).soleTask().location(MockMetaServiceProvider.LOC_0).operatorNum(1).soleSource().isA(ValuesOperator.class).getInstance();
List<Object[]> tuples = operator.getTuples();
assertThat(tuples).element(0).satisfies(obj -> {
assertThat(obj[0]).isEqualTo(BigDecimal.valueOf(1));
assertThat(obj[1]).isEqualTo("Alice");
assertThat(obj[2]).isEqualTo(BigDecimal.valueOf(1));
});
}
use of io.dingodb.exec.operator.ValuesOperator in project dingo by dingodb.
the class DingoJobVisitor method visit.
@Override
public Collection<Output> visit(@Nonnull DingoValues rel) {
Task task = job.getOrCreate(Services.META.currentLocation());
ValuesOperator operator = new ValuesOperator(rel.getValues());
operator.setId(idGenerator.get());
task.putOperator(operator);
return operator.getOutputs();
}
use of io.dingodb.exec.operator.ValuesOperator in project dingo by dingodb.
the class TestTaskImpl method testValues.
@Test
public void testValues() {
Task task = new TaskImpl("", Mockito.mock(Location.class));
ValuesOperator values = new ValuesOperator(ImmutableList.of(new Object[] { 1, "Alice", 1.0 }, new Object[] { 2, "Betty", 2.0 }));
values.setId(idGenerator.get());
task.putOperator(values);
RootOperator root = new RootOperator(TupleSchema.ofTypes("INTEGER", "STRING", "DOUBLE"));
root.setId(idGenerator.get());
task.putOperator(root);
values.getOutputs().get(0).setLink(root.getInput(0));
task.init();
task.run();
assertThat(root.popValue()).containsExactly(1, "Alice", 1.0);
task.run();
assertThat(root.popValue()).containsExactly(2, "Betty", 2.0);
}
Aggregations