Search in sources :

Example 1 with ResultSetCopier

use of org.apache.drill.exec.physical.resultSet.ResultSetCopier in project drill by apache.

the class TestResultSetCopier method testArrays.

@Test
public void testArrays() {
    ResultSetCopier copier = newCopier(new ArrayGen());
    copier.startOutputBatch();
    copier.nextInputBatch();
    copier.copyAllRows();
    RowSet result = fixture.wrap(copier.harvest());
    ArrayGen verifierGen = new ArrayGen();
    verifierGen.next();
    RowSet expected = RowSets.wrap(verifierGen.batch());
    RowSetUtilities.verify(expected, result);
    copier.close();
}
Also used : ResultSetCopier(org.apache.drill.exec.physical.resultSet.ResultSetCopier) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 2 with ResultSetCopier

use of org.apache.drill.exec.physical.resultSet.ResultSetCopier in project drill by apache.

the class TestResultSetCopier method testMaps.

@Test
public void testMaps() {
    ResultSetCopier copier = newCopier(new MapGen());
    copier.startOutputBatch();
    copier.nextInputBatch();
    copier.copyAllRows();
    RowSet result = fixture.wrap(copier.harvest());
    MapGen verifierGen = new MapGen();
    verifierGen.next();
    RowSet expected = RowSets.wrap(verifierGen.batch());
    RowSetUtilities.verify(expected, result);
    copier.close();
}
Also used : ResultSetCopier(org.apache.drill.exec.physical.resultSet.ResultSetCopier) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 3 with ResultSetCopier

use of org.apache.drill.exec.physical.resultSet.ResultSetCopier in project drill by apache.

the class TestResultSetCopier method testCloseBeforeSchema.

@Test
public void testCloseBeforeSchema() {
    ResultSetCopier copier = newCopier(new DataGen());
    // Start batch, no data yet.
    copier.startOutputBatch();
    // Close OK before things data arrives
    copier.close();
    // Second close is benign
    copier.close();
}
Also used : ResultSetCopier(org.apache.drill.exec.physical.resultSet.ResultSetCopier) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 4 with ResultSetCopier

use of org.apache.drill.exec.physical.resultSet.ResultSetCopier in project drill by apache.

the class TestResultSetCopier method testMultiOutput.

@Test
public void testMultiOutput() {
    // Equivalent of operator start() method.
    DataGen dataGen = new DataGen(15, 2);
    ResultSetOptionBuilder options = new ResultSetOptionBuilder().rowCountLimit(12);
    ResultSetCopier copier = newCopier(dataGen, options);
    // Equivalent of an entire operator run
    DataGen validatorGen = new DataGen(12, 2);
    int outputCount = 0;
    while (true) {
        // Equivalent of operator next() method
        copier.startOutputBatch();
        while (!copier.isOutputFull()) {
            if (!copier.nextInputBatch()) {
                break;
            }
            copier.copyAllRows();
        }
        if (!copier.hasOutputRows()) {
            break;
        }
        // Equivalent of sending downstream
        RowSet result = fixture.wrap(copier.harvest());
        validatorGen.next();
        RowSet expected = RowSets.wrap(validatorGen.batch());
        RowSetUtilities.verify(expected, result, result.rowCount());
        outputCount++;
    }
    // Ensure more than one output batch.
    assertTrue(outputCount > 1);
    // Ensure all rows generated.
    assertEquals(30, dataGen.rowCount);
    // Simulate operator close();
    copier.close();
}
Also used : ResultSetCopier(org.apache.drill.exec.physical.resultSet.ResultSetCopier) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 5 with ResultSetCopier

use of org.apache.drill.exec.physical.resultSet.ResultSetCopier in project drill by apache.

the class TestResultSetCopier method testSchemaChange.

@Test
public void testSchemaChange() {
    ResultSetCopier copier = newCopier(new SchemaChangeGen(3, 4, 2));
    // Copy first batch with first schema
    copier.startOutputBatch();
    assertTrue(copier.nextInputBatch());
    copier.copyAllRows();
    assertFalse(copier.isOutputFull());
    // Second, same schema
    assertTrue(copier.nextInputBatch());
    copier.copyAllRows();
    assertFalse(copier.isOutputFull());
    // Plenty of room. But, change the schema.
    assertTrue(copier.nextInputBatch());
    assertTrue(copier.isOutputFull());
    // Must harvest partial output
    RowSet result = fixture.wrap(copier.harvest());
    SchemaChangeGen verifierGen = new SchemaChangeGen(6, 2, 1);
    verifierGen.next();
    RowSet expected = RowSets.wrap(verifierGen.batch());
    RowSetUtilities.verify(expected, result);
    // Start a new batch, implicitly complete pending copy
    copier.startOutputBatch();
    copier.copyAllRows();
    // Add one more of second schema
    assertTrue(copier.nextInputBatch());
    copier.copyAllRows();
    assertFalse(copier.isOutputFull());
    result = fixture.wrap(copier.harvest());
    verifierGen.next();
    expected = RowSets.wrap(verifierGen.batch());
    RowSetUtilities.verify(expected, result);
    assertFalse(copier.isCopyPending());
    copier.close();
}
Also used : ResultSetCopier(org.apache.drill.exec.physical.resultSet.ResultSetCopier) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Aggregations

ResultSetCopier (org.apache.drill.exec.physical.resultSet.ResultSetCopier)12 SubOperatorTest (org.apache.drill.test.SubOperatorTest)12 Test (org.junit.Test)12 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)9 RowSetBuilder (org.apache.drill.exec.physical.rowSet.RowSetBuilder)2 RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)1