use of io.dingodb.exec.base.Job in project dingo by dingodb.
the class DingoResultSet method getIterator.
Iterator<Object[]> getIterator() {
if (iterator == null) {
DingoSignature dingoSignature = (DingoSignature) signature;
Job job = dingoSignature.getJob();
Enumerator<Object[]> enumerator = new JobRunner(job).createEnumerator();
iterator = Linq4j.enumeratorIterator(enumerator);
try {
setFetchSize(1);
} catch (SQLException e) {
e.printStackTrace();
}
}
return iterator;
}
use of io.dingodb.exec.base.Job 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;
}
use of io.dingodb.exec.base.Job in project dingo by dingodb.
the class TestDingoJobVisitor method testVisitPartModify.
@Test
public void testVisitPartModify() {
RelOptCluster cluster = parser.getCluster();
DingoPartModify partModify = new DingoPartModify(cluster, cluster.traitSetOf(DingoConventions.DISTRIBUTED), distributedValues, table, TableModify.Operation.INSERT, null, null);
Job job = DingoJobVisitor.createJob(partModify);
Assert.job(job).taskNum(2).task(0, t -> t.location(MockMetaServiceProvider.LOC_0).operatorNum(2).soleSource().isA(ValuesOperator.class).soleOutput().isA(PartModifyOperator.class)).task(1, t -> t.location(MockMetaServiceProvider.LOC_1).operatorNum(2).soleSource().isA(ValuesOperator.class).soleOutput().isA(PartModifyOperator.class));
}
use of io.dingodb.exec.base.Job 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.base.Job in project dingo by dingodb.
the class JobRunner method run.
@SuppressWarnings("unused")
@Nonnull
public static Enumerable<Object[]> run(String serializedJob) {
try {
final Job job = JobImpl.fromString(serializedJob);
final JobRunner runner = new JobRunner(job);
return new AbstractEnumerable<Object[]>() {
@Override
public Enumerator<Object[]> enumerator() {
return runner.createEnumerator();
}
};
} catch (JsonProcessingException e) {
throw new RuntimeException("Cannot deserialize job.", e);
}
}
Aggregations