use of io.dingodb.exec.base.IdGenerator 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;
}
Aggregations