Search in sources :

Example 1 with Screen

use of org.apache.drill.exec.physical.config.Screen in project drill by apache.

the class ScreenPrel method getPhysicalOperator.

@Override
public PhysicalOperator getPhysicalOperator(PhysicalPlanCreator creator) throws IOException {
    Prel child = (Prel) this.getInput();
    PhysicalOperator childPOP = child.getPhysicalOperator(creator);
    Screen s = new Screen(childPOP, creator.getContext().getCurrentEndpoint());
    return creator.addMetadata(this, s);
}
Also used : PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) Screen(org.apache.drill.exec.physical.config.Screen)

Example 2 with Screen

use of org.apache.drill.exec.physical.config.Screen in project drill by apache.

the class TestInjectionValue method testInjected.

@Test
public void testInjected() throws Exception {
    PhysicalPlanReader r = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(config);
    PhysicalPlan p = r.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile("/physical_screen.json"), Charsets.UTF_8));
    List<PhysicalOperator> o = p.getSortedOperators(false);
    PhysicalOperator op = o.iterator().next();
    assertEquals(Screen.class, op.getClass());
    Screen s = (Screen) op;
    assertEquals(DrillbitEndpoint.getDefaultInstance(), s.getEndpoint());
}
Also used : PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) PhysicalPlanReader(org.apache.drill.exec.planner.PhysicalPlanReader) PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) Screen(org.apache.drill.exec.physical.config.Screen) Test(org.junit.Test) ExecTest(org.apache.drill.exec.ExecTest)

Example 3 with Screen

use of org.apache.drill.exec.physical.config.Screen in project drill by apache.

the class DirectPlan method createDirectPlan.

public static <T> PhysicalPlan createDirectPlan(DrillbitEndpoint endpoint, Iterator<T> iterator, Class<T> clazz) {
    PojoRecordReader<T> reader = new PojoRecordReader<T>(clazz, iterator);
    DirectGroupScan scan = new DirectGroupScan(reader);
    Screen screen = new Screen(scan, endpoint);
    PlanPropertiesBuilder propsBuilder = PlanProperties.builder();
    propsBuilder.type(PlanType.APACHE_DRILL_PHYSICAL);
    propsBuilder.version(1);
    propsBuilder.resultMode(ResultMode.EXEC);
    propsBuilder.generator(DirectPlan.class.getSimpleName(), "");
    return new PhysicalPlan(propsBuilder.build(), DefaultSqlHandler.getPops(screen));
}
Also used : PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) Screen(org.apache.drill.exec.physical.config.Screen) DirectGroupScan(org.apache.drill.exec.store.direct.DirectGroupScan) PlanPropertiesBuilder(org.apache.drill.common.logical.PlanProperties.PlanPropertiesBuilder) PojoRecordReader(org.apache.drill.exec.store.pojo.PojoRecordReader)

Example 4 with Screen

use of org.apache.drill.exec.physical.config.Screen in project drill by apache.

the class TestOpSerialization method testSerializedDeserialize.

@Test
public void testSerializedDeserialize() throws Throwable {
    DrillConfig c = DrillConfig.create();
    PhysicalPlanReader reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(c);
    MockSubScanPOP s = new MockSubScanPOP("abc", false, null);
    s.setOperatorId(3);
    Filter f = new Filter(s, new ValueExpressions.BooleanExpression("true", ExpressionPosition.UNKNOWN), 0.1f);
    f.setOperatorId(2);
    UnionExchange e = new UnionExchange(f);
    e.setOperatorId(1);
    Screen screen = new Screen(e, CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
    screen.setOperatorId(0);
    boolean reversed = false;
    while (true) {
        List<PhysicalOperator> pops = Lists.newArrayList();
        pops.add(s);
        pops.add(e);
        pops.add(f);
        pops.add(screen);
        if (reversed) {
            pops = Lists.reverse(pops);
        }
        PhysicalPlan plan1 = new PhysicalPlan(PlanProperties.builder().build(), pops);
        LogicalPlanPersistence logicalPlanPersistence = PhysicalPlanReaderTestFactory.defaultLogicalPlanPersistence(c);
        String json = plan1.unparse(logicalPlanPersistence.getMapper().writer());
        PhysicalPlan plan2 = reader.readPhysicalPlan(json);
        PhysicalOperator root = plan2.getSortedOperators(false).iterator().next();
        assertEquals(0, root.getOperatorId());
        PhysicalOperator o1 = root.iterator().next();
        assertEquals(1, o1.getOperatorId());
        PhysicalOperator o2 = o1.iterator().next();
        assertEquals(2, o2.getOperatorId());
        if (reversed) {
            break;
        }
        reversed = !reversed;
    }
}
Also used : PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) UnionExchange(org.apache.drill.exec.physical.config.UnionExchange) PhysicalPlanReader(org.apache.drill.exec.planner.PhysicalPlanReader) Screen(org.apache.drill.exec.physical.config.Screen) ValueExpressions(org.apache.drill.common.expression.ValueExpressions) MockSubScanPOP(org.apache.drill.exec.store.mock.MockSubScanPOP) LogicalPlanPersistence(org.apache.drill.common.config.LogicalPlanPersistence) DrillConfig(org.apache.drill.common.config.DrillConfig) Filter(org.apache.drill.exec.physical.config.Filter) PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) Test(org.junit.Test)

Aggregations

Screen (org.apache.drill.exec.physical.config.Screen)4 PhysicalPlan (org.apache.drill.exec.physical.PhysicalPlan)3 PhysicalOperator (org.apache.drill.exec.physical.base.PhysicalOperator)3 PhysicalPlanReader (org.apache.drill.exec.planner.PhysicalPlanReader)2 Test (org.junit.Test)2 DrillConfig (org.apache.drill.common.config.DrillConfig)1 LogicalPlanPersistence (org.apache.drill.common.config.LogicalPlanPersistence)1 ValueExpressions (org.apache.drill.common.expression.ValueExpressions)1 PlanPropertiesBuilder (org.apache.drill.common.logical.PlanProperties.PlanPropertiesBuilder)1 ExecTest (org.apache.drill.exec.ExecTest)1 Filter (org.apache.drill.exec.physical.config.Filter)1 UnionExchange (org.apache.drill.exec.physical.config.UnionExchange)1 DirectGroupScan (org.apache.drill.exec.store.direct.DirectGroupScan)1 MockSubScanPOP (org.apache.drill.exec.store.mock.MockSubScanPOP)1 PojoRecordReader (org.apache.drill.exec.store.pojo.PojoRecordReader)1