Search in sources :

Example 1 with PullResultSetReader

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

the class TestResultSetReader method testBasics.

@Test
public void testBasics() {
    PullResultSetReader rsReader = new PullResultSetReaderImpl(new BatchGenerator(10, 2, 1));
    // Start state
    try {
        rsReader.reader();
        fail();
    } catch (IllegalStateException e) {
    // Expected
    }
    // Ask for schema. Does an implicit next.
    assertEquals(SCHEMA1, rsReader.schema());
    assertEquals(1, rsReader.schemaVersion());
    // Move to the first batch.
    // (Don't need to do a full reader test, that is already done
    // elsewhere.)
    assertTrue(rsReader.next());
    assertEquals(1, rsReader.schemaVersion());
    RowSetReader reader1;
    {
        RowSetReader reader = rsReader.reader();
        reader1 = reader;
        assertTrue(reader.next());
        assertEquals(1, reader.scalar("id").getInt());
        assertEquals("Row1", reader.scalar("name").getString());
    }
    // Second batch, same schema.
    assertTrue(rsReader.next());
    assertEquals(1, rsReader.schemaVersion());
    {
        RowSetReader reader = rsReader.reader();
        assertSame(reader1, reader);
        reader1 = reader;
        assertTrue(reader.next());
        assertEquals(11, reader.scalar("id").getInt());
        assertEquals("Row11", reader.scalar("name").getString());
    }
    // Batch with new schema
    assertTrue(rsReader.next());
    assertEquals(2, rsReader.schemaVersion());
    {
        RowSetReader reader = rsReader.reader();
        assertNotSame(reader1, reader);
        reader1 = reader;
        assertTrue(reader.next());
        assertEquals(21, reader.scalar("id").getInt());
        assertEquals("Row21", reader.scalar("name").getString());
        assertEquals(210, reader.scalar("amount").getInt());
    }
    assertFalse(rsReader.next());
    rsReader.close();
}
Also used : PullResultSetReader(org.apache.drill.exec.physical.resultSet.PullResultSetReader) RowSetReader(org.apache.drill.exec.physical.rowSet.RowSetReader) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 2 with PullResultSetReader

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

the class TestResultSetReader method testCloseAtStart.

@Test
public void testCloseAtStart() {
    PullResultSetReader rsReader = new PullResultSetReaderImpl(new BatchGenerator(10, 2, 1));
    // Close OK in start state
    rsReader.close();
    // Second close OK
    rsReader.close();
}
Also used : PullResultSetReader(org.apache.drill.exec.physical.resultSet.PullResultSetReader) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 3 with PullResultSetReader

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

the class TestResultSetReader method testCloseAfterNext.

@Test
public void testCloseAfterNext() {
    PullResultSetReader rsReader = new PullResultSetReaderImpl(new BatchGenerator(10, 2, 1));
    // Move to first batch
    assertTrue(rsReader.next());
    // Close OK in start state
    rsReader.close();
    // Second close OK
    rsReader.close();
}
Also used : PullResultSetReader(org.apache.drill.exec.physical.resultSet.PullResultSetReader) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 4 with PullResultSetReader

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

the class TestResultSetReader method testCloseDuringRead.

@Test
public void testCloseDuringRead() {
    PullResultSetReader rsReader = new PullResultSetReaderImpl(new BatchGenerator(10, 2, 1));
    // Move to first batch
    assertTrue(rsReader.next());
    // Close OK in start state
    rsReader.close();
    // Second close OK
    rsReader.close();
}
Also used : PullResultSetReader(org.apache.drill.exec.physical.resultSet.PullResultSetReader) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Aggregations

PullResultSetReader (org.apache.drill.exec.physical.resultSet.PullResultSetReader)4 SubOperatorTest (org.apache.drill.test.SubOperatorTest)4 Test (org.junit.Test)4 RowSetReader (org.apache.drill.exec.physical.rowSet.RowSetReader)1