Search in sources :

Example 6 with Job

use of io.dingodb.exec.base.Job in project dingo by dingodb.

the class JobRunner method runOneColumn.

@SuppressWarnings("unused")
@Nonnull
public static Enumerable<Object> runOneColumn(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.createEnumeratorSingleColumn();
            }
        };
    } catch (JsonProcessingException e) {
        throw new RuntimeException("Cannot deserialize job.", e);
    }
}
Also used : AbstractEnumerable(org.apache.calcite.linq4j.AbstractEnumerable) Job(io.dingodb.exec.base.Job) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Nonnull(javax.annotation.Nonnull)

Example 7 with Job

use of io.dingodb.exec.base.Job in project dingo by dingodb.

the class TestDingoJobVisitor method testVisitPartScan.

@Test
public void testVisitPartScan() {
    RelOptCluster cluster = parser.getCluster();
    DingoPartScan partScan = new DingoPartScan(cluster, cluster.traitSetOf(DingoConventions.DISTRIBUTED), table);
    Job job = DingoJobVisitor.createJob(partScan);
    Assert.job(job).taskNum(2).task(0, t -> t.operatorNum(1).location(MockMetaServiceProvider.LOC_0).soleSource().isPartScan(TABLE_ID, "0").soleOutput().isNull()).task(1, t -> t.operatorNum(1).location(MockMetaServiceProvider.LOC_1).soleSource().isPartScan(TABLE_ID, "1").soleOutput().isNull());
}
Also used : RelOptCluster(org.apache.calcite.plan.RelOptCluster) DingoExchange(io.dingodb.calcite.rel.DingoExchange) RelDataTypeFactory(org.apache.calcite.rel.type.RelDataTypeFactory) DingoParserContext(io.dingodb.calcite.DingoParserContext) ValuesOperator(io.dingodb.exec.operator.ValuesOperator) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assert(io.dingodb.calcite.assertion.Assert) DingoDistributedValues(io.dingodb.calcite.rel.DingoDistributedValues) RelOptTable(org.apache.calcite.plan.RelOptTable) Job(io.dingodb.exec.base.Job) BigDecimal(java.math.BigDecimal) DingoConventions(io.dingodb.calcite.DingoConventions) DingoPartModify(io.dingodb.calcite.rel.DingoPartModify) ImmutableList(com.google.common.collect.ImmutableList) BeforeAll(org.junit.jupiter.api.BeforeAll) DingoCoalesce(io.dingodb.calcite.rel.DingoCoalesce) MockMetaServiceProvider(io.dingodb.calcite.mock.MockMetaServiceProvider) TableModify(org.apache.calcite.rel.core.TableModify) PartModifyOperator(io.dingodb.exec.operator.PartModifyOperator) RelOptCluster(org.apache.calcite.plan.RelOptCluster) RelDataType(org.apache.calcite.rel.type.RelDataType) SqlTypeName(org.apache.calcite.sql.type.SqlTypeName) TableId(io.dingodb.common.table.TableId) StandardCharsets(java.nio.charset.StandardCharsets) Test(org.junit.jupiter.api.Test) DingoParser(io.dingodb.calcite.DingoParser) SendOperator(io.dingodb.exec.operator.SendOperator) List(java.util.List) DingoPartScan(io.dingodb.calcite.rel.DingoPartScan) ReceiveOperator(io.dingodb.exec.operator.ReceiveOperator) DingoValues(io.dingodb.calcite.rel.DingoValues) CoalesceOperator(io.dingodb.exec.operator.CoalesceOperator) DingoPartScan(io.dingodb.calcite.rel.DingoPartScan) Job(io.dingodb.exec.base.Job) Test(org.junit.jupiter.api.Test)

Example 8 with Job

use of io.dingodb.exec.base.Job in project dingo by dingodb.

the class EnumerableRoot method implement.

@Nullable
@Override
public Result implement(@Nonnull EnumerableRelImplementor implementor, @Nonnull Prefer pref) {
    PhysType physType = PhysTypeImpl.of(implementor.getTypeFactory(), getRowType(), pref.preferArray());
    RelNode input = getInput();
    assert input instanceof DingoRel : "The input must be DINGO.";
    Job job = DingoJobVisitor.createJob(input, true);
    // The result set would be treated as `Object` instead of `Object[]` if the result has only one column.
    String methodName = getRowType().getFieldCount() == 1 ? "runOneColumn" : "run";
    try {
        Method method = JobRunner.class.getMethod(methodName, String.class);
        return implementor.result(physType, Blocks.toBlock(Expressions.call(method, Expressions.constant(job.toString()))));
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    }
    return null;
}
Also used : PhysType(org.apache.calcite.adapter.enumerable.PhysType) RelNode(org.apache.calcite.rel.RelNode) Method(java.lang.reflect.Method) Job(io.dingodb.exec.base.Job) Nullable(javax.annotation.Nullable)

Example 9 with Job

use of io.dingodb.exec.base.Job in project dingo by dingodb.

the class TestDingoJobVisitor method testVisitExchange.

@Test
public void testVisitExchange() {
    RelOptCluster cluster = parser.getCluster();
    DingoExchange exchange = new DingoExchange(cluster, cluster.traitSetOf(DingoConventions.PARTITIONED), new DingoPartScan(cluster, cluster.traitSetOf(DingoConventions.DISTRIBUTED), table));
    Job job = DingoJobVisitor.createJob(exchange);
    Assert.job(job).taskNum(2).task(0, t -> t.operatorNum(2).location(MockMetaServiceProvider.LOC_0).sourceNum(2).source(0, s -> s.isPartScan(TABLE_ID, "0").soleOutput().isNull()).source(1, s -> s.isA(ReceiveOperator.class).soleOutput().isNull())).task(1, t -> t.operatorNum(2).location(MockMetaServiceProvider.LOC_1).soleSource().isPartScan(TABLE_ID, "1").soleOutput().isA(SendOperator.class));
}
Also used : RelOptCluster(org.apache.calcite.plan.RelOptCluster) DingoExchange(io.dingodb.calcite.rel.DingoExchange) RelDataTypeFactory(org.apache.calcite.rel.type.RelDataTypeFactory) DingoParserContext(io.dingodb.calcite.DingoParserContext) ValuesOperator(io.dingodb.exec.operator.ValuesOperator) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assert(io.dingodb.calcite.assertion.Assert) DingoDistributedValues(io.dingodb.calcite.rel.DingoDistributedValues) RelOptTable(org.apache.calcite.plan.RelOptTable) Job(io.dingodb.exec.base.Job) BigDecimal(java.math.BigDecimal) DingoConventions(io.dingodb.calcite.DingoConventions) DingoPartModify(io.dingodb.calcite.rel.DingoPartModify) ImmutableList(com.google.common.collect.ImmutableList) BeforeAll(org.junit.jupiter.api.BeforeAll) DingoCoalesce(io.dingodb.calcite.rel.DingoCoalesce) MockMetaServiceProvider(io.dingodb.calcite.mock.MockMetaServiceProvider) TableModify(org.apache.calcite.rel.core.TableModify) PartModifyOperator(io.dingodb.exec.operator.PartModifyOperator) RelOptCluster(org.apache.calcite.plan.RelOptCluster) RelDataType(org.apache.calcite.rel.type.RelDataType) SqlTypeName(org.apache.calcite.sql.type.SqlTypeName) TableId(io.dingodb.common.table.TableId) StandardCharsets(java.nio.charset.StandardCharsets) Test(org.junit.jupiter.api.Test) DingoParser(io.dingodb.calcite.DingoParser) SendOperator(io.dingodb.exec.operator.SendOperator) List(java.util.List) DingoPartScan(io.dingodb.calcite.rel.DingoPartScan) ReceiveOperator(io.dingodb.exec.operator.ReceiveOperator) DingoValues(io.dingodb.calcite.rel.DingoValues) CoalesceOperator(io.dingodb.exec.operator.CoalesceOperator) ReceiveOperator(io.dingodb.exec.operator.ReceiveOperator) DingoPartScan(io.dingodb.calcite.rel.DingoPartScan) Job(io.dingodb.exec.base.Job) SendOperator(io.dingodb.exec.operator.SendOperator) DingoExchange(io.dingodb.calcite.rel.DingoExchange) Test(org.junit.jupiter.api.Test)

Example 10 with Job

use of io.dingodb.exec.base.Job in project dingo by dingodb.

the class TestDingoJobVisitor method testVisitCoalesce.

@Test
public void testVisitCoalesce() {
    RelOptCluster cluster = parser.getCluster();
    DingoCoalesce coalesce = new DingoCoalesce(cluster, cluster.traitSetOf(DingoConventions.ROOT), new DingoExchange(cluster, cluster.traitSetOf(DingoConventions.PARTITIONED), new DingoPartScan(cluster, cluster.traitSetOf(DingoConventions.DISTRIBUTED), table)));
    Job job = DingoJobVisitor.createJob(coalesce);
    Assert.job(job).taskNum(2).task(0, t -> t.operatorNum(3).location(MockMetaServiceProvider.LOC_0).sourceNum(2).source(0, s -> s.isPartScan(TABLE_ID, "0").soleOutput().isA(CoalesceOperator.class)).source(1, s -> s.isA(ReceiveOperator.class).soleOutput().isA(CoalesceOperator.class))).task(1, t -> t.operatorNum(2).location(MockMetaServiceProvider.LOC_1).soleSource().isPartScan(TABLE_ID, "1").soleOutput().isA(SendOperator.class));
}
Also used : RelOptCluster(org.apache.calcite.plan.RelOptCluster) DingoExchange(io.dingodb.calcite.rel.DingoExchange) RelDataTypeFactory(org.apache.calcite.rel.type.RelDataTypeFactory) DingoParserContext(io.dingodb.calcite.DingoParserContext) ValuesOperator(io.dingodb.exec.operator.ValuesOperator) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assert(io.dingodb.calcite.assertion.Assert) DingoDistributedValues(io.dingodb.calcite.rel.DingoDistributedValues) RelOptTable(org.apache.calcite.plan.RelOptTable) Job(io.dingodb.exec.base.Job) BigDecimal(java.math.BigDecimal) DingoConventions(io.dingodb.calcite.DingoConventions) DingoPartModify(io.dingodb.calcite.rel.DingoPartModify) ImmutableList(com.google.common.collect.ImmutableList) BeforeAll(org.junit.jupiter.api.BeforeAll) DingoCoalesce(io.dingodb.calcite.rel.DingoCoalesce) MockMetaServiceProvider(io.dingodb.calcite.mock.MockMetaServiceProvider) TableModify(org.apache.calcite.rel.core.TableModify) PartModifyOperator(io.dingodb.exec.operator.PartModifyOperator) RelOptCluster(org.apache.calcite.plan.RelOptCluster) RelDataType(org.apache.calcite.rel.type.RelDataType) SqlTypeName(org.apache.calcite.sql.type.SqlTypeName) TableId(io.dingodb.common.table.TableId) StandardCharsets(java.nio.charset.StandardCharsets) Test(org.junit.jupiter.api.Test) DingoParser(io.dingodb.calcite.DingoParser) SendOperator(io.dingodb.exec.operator.SendOperator) List(java.util.List) DingoPartScan(io.dingodb.calcite.rel.DingoPartScan) ReceiveOperator(io.dingodb.exec.operator.ReceiveOperator) DingoValues(io.dingodb.calcite.rel.DingoValues) CoalesceOperator(io.dingodb.exec.operator.CoalesceOperator) ReceiveOperator(io.dingodb.exec.operator.ReceiveOperator) DingoPartScan(io.dingodb.calcite.rel.DingoPartScan) CoalesceOperator(io.dingodb.exec.operator.CoalesceOperator) DingoCoalesce(io.dingodb.calcite.rel.DingoCoalesce) Job(io.dingodb.exec.base.Job) SendOperator(io.dingodb.exec.operator.SendOperator) DingoExchange(io.dingodb.calcite.rel.DingoExchange) Test(org.junit.jupiter.api.Test)

Aggregations

Job (io.dingodb.exec.base.Job)11 ImmutableList (com.google.common.collect.ImmutableList)5 ValuesOperator (io.dingodb.exec.operator.ValuesOperator)5 List (java.util.List)5 RelDataType (org.apache.calcite.rel.type.RelDataType)5 Test (org.junit.jupiter.api.Test)5 DingoConventions (io.dingodb.calcite.DingoConventions)4 DingoParser (io.dingodb.calcite.DingoParser)4 DingoParserContext (io.dingodb.calcite.DingoParserContext)4 Assert (io.dingodb.calcite.assertion.Assert)4 MockMetaServiceProvider (io.dingodb.calcite.mock.MockMetaServiceProvider)4 DingoCoalesce (io.dingodb.calcite.rel.DingoCoalesce)4 DingoDistributedValues (io.dingodb.calcite.rel.DingoDistributedValues)4 DingoExchange (io.dingodb.calcite.rel.DingoExchange)4 DingoPartModify (io.dingodb.calcite.rel.DingoPartModify)4 DingoPartScan (io.dingodb.calcite.rel.DingoPartScan)4 DingoValues (io.dingodb.calcite.rel.DingoValues)4 TableId (io.dingodb.common.table.TableId)4 CoalesceOperator (io.dingodb.exec.operator.CoalesceOperator)4 PartModifyOperator (io.dingodb.exec.operator.PartModifyOperator)4