Search in sources :

Example 1 with MockStorePOP

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

the class TestSortEmitOutcome method testSpillWithNoEmitOutcome.

/**
 * Verifies successful spilling in absence of EMIT outcome
 * @throws Exception
 */
@Test
public void testSpillWithNoEmitOutcome() throws Exception {
    final OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
    // Configuration that forces Sort to spill after buffering 2 incoming batches with data
    builder.configBuilder().put(ExecConstants.EXTERNAL_SORT_BATCH_LIMIT, 2);
    final OperatorFixture fixture_local = builder.build();
    final RowSet.SingleRowSet local_nonEmptyInputRowSet1 = fixture_local.rowSetBuilder(inputSchema).addRow(3, 30, "item3").addRow(2, 20, "item2").build();
    final RowSet.SingleRowSet local_nonEmptyInputRowSet2 = fixture_local.rowSetBuilder(inputSchema).addRow(1, 10, "item1").build();
    final RowSet.SingleRowSet local_nonEmptyInputRowSet3 = fixture_local.rowSetBuilder(inputSchema).addRow(4, 40, "item4").build();
    inputContainer.add(local_nonEmptyInputRowSet1.container());
    inputContainer.add(local_nonEmptyInputRowSet2.container());
    inputContainer.add(local_nonEmptyInputRowSet3.container());
    inputOutcomes.add(OK_NEW_SCHEMA);
    inputOutcomes.add(OK);
    inputOutcomes.add(OK);
    final PhysicalOperator mockPopConfig_local = new MockStorePOP(null);
    final OperatorContext opContext_local = fixture_local.getFragmentContext().newOperatorContext(mockPopConfig_local);
    final MockRecordBatch mockInputBatch = new MockRecordBatch(fixture_local.getFragmentContext(), opContext_local, inputContainer, inputOutcomes, local_nonEmptyInputRowSet1.container().getSchema());
    final ExternalSortBatch sortBatch_local = new ExternalSortBatch(sortPopConfig, fixture_local.getFragmentContext(), mockInputBatch);
    assertTrue(sortBatch_local.next() == OK_NEW_SCHEMA);
    assertTrue(sortBatch_local.next() == OK_NEW_SCHEMA);
    assertTrue(sortBatch_local.getRecordCount() == 4);
    assertTrue(sortBatch_local.getSchema().getSelectionVectorMode() == BatchSchema.SelectionVectorMode.NONE);
    assertTrue(sortBatch_local.next() == NONE);
    // Release memory for row sets
    local_nonEmptyInputRowSet1.clear();
    local_nonEmptyInputRowSet2.clear();
    local_nonEmptyInputRowSet3.clear();
    sortBatch_local.close();
    fixture_local.close();
}
Also used : PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) MockStorePOP(org.apache.drill.exec.store.mock.MockStorePOP) OperatorContext(org.apache.drill.exec.ops.OperatorContext) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) OperatorFixture(org.apache.drill.test.OperatorFixture) MockRecordBatch(org.apache.drill.exec.physical.impl.MockRecordBatch) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test)

Example 2 with MockStorePOP

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

the class TestLateralJoinCorrectness method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    PhysicalOperator mockPopConfig = new MockStorePOP(null);
    operatorContext = fixture.newOperatorContext(mockPopConfig);
    ljPopConfig = new LateralJoinPOP(null, null, JoinRelType.INNER, DrillLateralJoinRelBase.IMPLICIT_COLUMN, Lists.newArrayList());
    leftSchema = new SchemaBuilder().add("id_left", TypeProtos.MinorType.INT).add("cost_left", TypeProtos.MinorType.INT).add("name_left", TypeProtos.MinorType.VARCHAR).buildSchema();
    emptyLeftRowSet = fixture.rowSetBuilder(leftSchema).build();
    rightSchema = new SchemaBuilder().add(ljPopConfig.getImplicitRIDColumn(), TypeProtos.MinorType.INT).add("id_right", TypeProtos.MinorType.INT).add("cost_right", TypeProtos.MinorType.INT).add("name_right", TypeProtos.MinorType.VARCHAR).buildSchema();
    emptyRightRowSet = fixture.rowSetBuilder(rightSchema).build();
}
Also used : PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) MockStorePOP(org.apache.drill.exec.store.mock.MockStorePOP) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) LateralJoinPOP(org.apache.drill.exec.physical.config.LateralJoinPOP) BeforeClass(org.junit.BeforeClass)

Example 3 with MockStorePOP

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

the class BaseTestOpBatchEmitOutcome method beforeTest.

@Before
public void beforeTest() throws Exception {
    emptyInputRowSet = operatorFixture.rowSetBuilder(inputSchema).build();
    nonEmptyInputRowSet = operatorFixture.rowSetBuilder(inputSchema).addRow(1, 10, "item1").build();
    final PhysicalOperator mockPopConfig = new MockStorePOP(null);
    mockOpContext(mockPopConfig, 0, 0);
}
Also used : PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) MockStorePOP(org.apache.drill.exec.store.mock.MockStorePOP) Before(org.junit.Before)

Example 4 with MockStorePOP

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

the class TestUnnestCorrectness method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    mockPopConfig = new MockStorePOP(null);
    operatorContext = fixture.newOperatorContext(mockPopConfig);
}
Also used : MockStorePOP(org.apache.drill.exec.store.mock.MockStorePOP) BeforeClass(org.junit.BeforeClass)

Example 5 with MockStorePOP

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

the class TestLateralJoinCorrectnessBatchProcessing method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    PhysicalOperator mockPopConfig = new MockStorePOP(null);
    operatorContext = fixture.newOperatorContext(mockPopConfig);
    ljPopConfig = new LateralJoinPOP(null, null, JoinRelType.INNER, DrillLateralJoinRelBase.IMPLICIT_COLUMN, Lists.newArrayList());
    leftSchema = new SchemaBuilder().add("id_left", TypeProtos.MinorType.INT).add("cost_left", TypeProtos.MinorType.INT).add("name_left", TypeProtos.MinorType.VARCHAR).buildSchema();
    emptyLeftRowSet = fixture.rowSetBuilder(leftSchema).build();
    rightSchema = new SchemaBuilder().add(ljPopConfig.getImplicitRIDColumn(), TypeProtos.MinorType.INT).add("id_right", TypeProtos.MinorType.INT).add("cost_right", TypeProtos.MinorType.INT).add("name_right", TypeProtos.MinorType.VARCHAR).buildSchema();
    emptyRightRowSet = fixture.rowSetBuilder(rightSchema).build();
    expectedSchema = new SchemaBuilder().add("id_left", TypeProtos.MinorType.INT).add("cost_left", TypeProtos.MinorType.INT).add("name_left", TypeProtos.MinorType.VARCHAR).add("id_right", TypeProtos.MinorType.INT).add("cost_right", TypeProtos.MinorType.INT).add("name_right", TypeProtos.MinorType.VARCHAR).buildSchema();
    expectedSchemaLeftJoin = new SchemaBuilder().add("id_left", TypeProtos.MinorType.INT).add("cost_left", TypeProtos.MinorType.INT).add("name_left", TypeProtos.MinorType.VARCHAR).add("id_right", TypeProtos.MinorType.INT, TypeProtos.DataMode.OPTIONAL).add("cost_right", TypeProtos.MinorType.INT, TypeProtos.DataMode.OPTIONAL).add("name_right", TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL).buildSchema();
}
Also used : PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) MockStorePOP(org.apache.drill.exec.store.mock.MockStorePOP) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) LateralJoinPOP(org.apache.drill.exec.physical.config.LateralJoinPOP) BeforeClass(org.junit.BeforeClass)

Aggregations

MockStorePOP (org.apache.drill.exec.store.mock.MockStorePOP)8 PhysicalOperator (org.apache.drill.exec.physical.base.PhysicalOperator)6 BeforeClass (org.junit.BeforeClass)4 LateralJoinPOP (org.apache.drill.exec.physical.config.LateralJoinPOP)3 OperatorTest (org.apache.drill.categories.OperatorTest)2 OperatorContext (org.apache.drill.exec.ops.OperatorContext)2 MockRecordBatch (org.apache.drill.exec.physical.impl.MockRecordBatch)2 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)2 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)2 OperatorFixture (org.apache.drill.test.OperatorFixture)2 Before (org.junit.Before)2 Test (org.junit.Test)2