Search in sources :

Example 1 with MockSubScanPOP

use of org.apache.drill.exec.store.mock.MockSubScanPOP in project drill by axbaretto.

the class TestOpSerialization method testMockSubScan.

@Test
public void testMockSubScan() throws Exception {
    MockSubScanPOP scan = new MockSubScanPOP("abc", false, null);
    scan.setOperatorId(1);
    scan = (MockSubScanPOP) reader.readFragmentLeaf(writer.writeValueAsString(setupPhysicalOperator(scan)));
    assertOperator(scan);
    assertEquals("abc", scan.getUrl());
    assertNull(scan.getReadEntries());
    assertFalse(scan.isExtended());
}
Also used : MockSubScanPOP(org.apache.drill.exec.store.mock.MockSubScanPOP) Test(org.junit.Test)

Example 2 with MockSubScanPOP

use of org.apache.drill.exec.store.mock.MockSubScanPOP in project drill by axbaretto.

the class ExpressionInterpreterTest method doTest.

protected void doTest(String expressionStr, String[] colNames, TypeProtos.MajorType[] colTypes, String[] expectFirstTwoValues, BitControl.PlanFragment planFragment) throws Exception {
    @SuppressWarnings("resource") final RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
    final Drillbit bit1 = new Drillbit(CONFIG, serviceSet);
    bit1.run();
    // Create a mock scan batch as input for evaluation.
    assertEquals(colNames.length, colTypes.length);
    final MockTableDef.MockColumn[] columns = new MockTableDef.MockColumn[colNames.length];
    for (int i = 0; i < colNames.length; i++) {
        columns[i] = new MockTableDef.MockColumn(colNames[i], colTypes[i].getMinorType(), colTypes[i].getMode(), 0, 0, 0, null, null, null);
    }
    final MockTableDef.MockScanEntry entry = new MockTableDef.MockScanEntry(10, false, 0, 1, columns);
    final MockSubScanPOP scanPOP = new MockSubScanPOP("testTable", false, java.util.Collections.singletonList(entry));
    final ScanBatch batch = createMockScanBatch(bit1, scanPOP, planFragment);
    batch.next();
    @SuppressWarnings("resource") final ValueVector vv = evalExprWithInterpreter(expressionStr, batch, bit1);
    // Verify the first 2 values in the output of evaluation.
    assertEquals(2, expectFirstTwoValues.length);
    assertEquals(expectFirstTwoValues[0], getValueFromVector(vv, 0));
    assertEquals(expectFirstTwoValues[1], getValueFromVector(vv, 1));
    showValueVectorContent(vv);
    vv.clear();
    batch.close();
    batch.getContext().close();
    bit1.close();
}
Also used : MockSubScanPOP(org.apache.drill.exec.store.mock.MockSubScanPOP) ValueVector(org.apache.drill.exec.vector.ValueVector) Drillbit(org.apache.drill.exec.server.Drillbit) MockTableDef(org.apache.drill.exec.store.mock.MockTableDef) RemoteServiceSet(org.apache.drill.exec.server.RemoteServiceSet) ScanBatch(org.apache.drill.exec.physical.impl.ScanBatch)

Example 3 with MockSubScanPOP

use of org.apache.drill.exec.store.mock.MockSubScanPOP in project drill by apache.

the class TestOpSerialization method testMockSubScan.

@Test
public void testMockSubScan() throws Exception {
    MockSubScanPOP scan = new MockSubScanPOP("abc", false, null);
    scan.setOperatorId(1);
    scan = (MockSubScanPOP) reader.readFragmentLeaf(writer.writeValueAsString(setupPhysicalOperator(scan)));
    assertOperator(scan);
    assertEquals("abc", scan.getUrl());
    assertNull(scan.getReadEntries());
    assertFalse(scan.isExtended());
}
Also used : MockSubScanPOP(org.apache.drill.exec.store.mock.MockSubScanPOP) BaseTest(org.apache.drill.test.BaseTest) Test(org.junit.Test)

Example 4 with MockSubScanPOP

use of org.apache.drill.exec.store.mock.MockSubScanPOP in project drill by apache.

the class ExpressionInterpreterTest method doTest.

protected void doTest(String expressionStr, String[] colNames, TypeProtos.MajorType[] colTypes, String[] expectFirstTwoValues, BitControl.PlanFragment planFragment) throws Exception {
    final RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
    final Drillbit bit1 = new Drillbit(CONFIG, serviceSet);
    bit1.run();
    // Create a mock scan batch as input for evaluation.
    assertEquals(colNames.length, colTypes.length);
    final MockTableDef.MockColumn[] columns = new MockTableDef.MockColumn[colNames.length];
    for (int i = 0; i < colNames.length; i++) {
        columns[i] = new MockTableDef.MockColumn(colNames[i], colTypes[i].getMinorType(), colTypes[i].getMode(), 0, 0, 0, null, null, null);
    }
    final MockTableDef.MockScanEntry entry = new MockTableDef.MockScanEntry(10, false, 0, 1, columns);
    final MockSubScanPOP scanPOP = new MockSubScanPOP("testTable", false, java.util.Collections.singletonList(entry));
    final CloseableRecordBatch batch = createMockScanBatch(bit1, scanPOP, planFragment);
    batch.next();
    final ValueVector vv = evalExprWithInterpreter(expressionStr, batch, bit1);
    // Verify the first 2 values in the output of evaluation.
    assertEquals(2, expectFirstTwoValues.length);
    assertEquals(expectFirstTwoValues[0], getValueFromVector(vv, 0));
    assertEquals(expectFirstTwoValues[1], getValueFromVector(vv, 1));
    showValueVectorContent(vv);
    vv.clear();
    batch.close();
    batch.getContext().close();
    bit1.close();
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) Drillbit(org.apache.drill.exec.server.Drillbit) MockTableDef(org.apache.drill.exec.store.mock.MockTableDef) RemoteServiceSet(org.apache.drill.exec.server.RemoteServiceSet) CloseableRecordBatch(org.apache.drill.exec.record.CloseableRecordBatch) MockSubScanPOP(org.apache.drill.exec.store.mock.MockSubScanPOP)

Example 5 with MockSubScanPOP

use of org.apache.drill.exec.store.mock.MockSubScanPOP in project drill by axbaretto.

the class TestOpSerialization method testSerializedDeserialize.

@Test
public void testSerializedDeserialize() throws Throwable {
    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);
        String json = plan1.unparse(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) Filter(org.apache.drill.exec.physical.config.Filter) UnionExchange(org.apache.drill.exec.physical.config.UnionExchange) Screen(org.apache.drill.exec.physical.config.Screen) PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) ValueExpressions(org.apache.drill.common.expression.ValueExpressions) MockSubScanPOP(org.apache.drill.exec.store.mock.MockSubScanPOP) Test(org.junit.Test)

Aggregations

MockSubScanPOP (org.apache.drill.exec.store.mock.MockSubScanPOP)6 Test (org.junit.Test)4 ValueExpressions (org.apache.drill.common.expression.ValueExpressions)2 PhysicalPlan (org.apache.drill.exec.physical.PhysicalPlan)2 PhysicalOperator (org.apache.drill.exec.physical.base.PhysicalOperator)2 Filter (org.apache.drill.exec.physical.config.Filter)2 Screen (org.apache.drill.exec.physical.config.Screen)2 UnionExchange (org.apache.drill.exec.physical.config.UnionExchange)2 Drillbit (org.apache.drill.exec.server.Drillbit)2 RemoteServiceSet (org.apache.drill.exec.server.RemoteServiceSet)2 MockTableDef (org.apache.drill.exec.store.mock.MockTableDef)2 ValueVector (org.apache.drill.exec.vector.ValueVector)2 BaseTest (org.apache.drill.test.BaseTest)2 ScanBatch (org.apache.drill.exec.physical.impl.ScanBatch)1 CloseableRecordBatch (org.apache.drill.exec.record.CloseableRecordBatch)1