Search in sources :

Example 1 with IdGenerator

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;
}
Also used : Task(io.dingodb.exec.base.Task) Output(io.dingodb.exec.base.Output) RootOperator(io.dingodb.exec.operator.RootOperator) IdGenerator(io.dingodb.exec.base.IdGenerator) Job(io.dingodb.exec.base.Job) Nonnull(javax.annotation.Nonnull)

Aggregations

IdGenerator (io.dingodb.exec.base.IdGenerator)1 Job (io.dingodb.exec.base.Job)1 Output (io.dingodb.exec.base.Output)1 Task (io.dingodb.exec.base.Task)1 RootOperator (io.dingodb.exec.operator.RootOperator)1 Nonnull (javax.annotation.Nonnull)1