Search in sources :

Example 11 with BatchAccessor

use of org.apache.drill.exec.physical.impl.protocol.BatchAccessor in project drill by apache.

the class TestScanOperExecLimit method testLimitOnBatchEnd.

/**
 * LIMIT 50, same as batch size, to check boundary conditions.
 */
@Test
public void testLimitOnBatchEnd() {
    Mock50RowReader reader1 = new Mock50RowReader();
    Mock50RowReader reader2 = new Mock50RowReader();
    BaseScanFixtureBuilder builder = simpleBuilder(reader1, reader2);
    builder.builder.limit(50);
    ScanFixture scanFixture = builder.build();
    ScanOperatorExec scan = scanFixture.scanOp;
    assertTrue(scan.buildSchema());
    assertTrue(scan.next());
    BatchAccessor batch = scan.batchAccessor();
    assertEquals(50, batch.rowCount());
    batch.release();
    // No second batch or second reader
    assertFalse(scan.next());
    scanFixture.close();
    assertTrue(reader1.openCalled);
    assertFalse(reader2.openCalled);
}
Also used : ScanFixture(org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture) BatchAccessor(org.apache.drill.exec.physical.impl.protocol.BatchAccessor) Test(org.junit.Test)

Example 12 with BatchAccessor

use of org.apache.drill.exec.physical.impl.protocol.BatchAccessor in project drill by apache.

the class TestScanOperExecLimit method testLimitOnSecondReader.

/**
 * LIMIT 125: full first reader, limit on second
 */
@Test
public void testLimitOnSecondReader() {
    Mock50RowReader reader1 = new Mock50RowReader();
    Mock50RowReader reader2 = new Mock50RowReader();
    BaseScanFixtureBuilder builder = simpleBuilder(reader1, reader2);
    builder.builder.limit(125);
    ScanFixture scanFixture = builder.build();
    ScanOperatorExec scan = scanFixture.scanOp;
    assertTrue(scan.buildSchema());
    assertTrue(scan.next());
    BatchAccessor batch = scan.batchAccessor();
    assertEquals(50, batch.rowCount());
    batch.release();
    assertTrue(scan.next());
    batch = scan.batchAccessor();
    assertEquals(50, batch.rowCount());
    batch.release();
    // First batch, second reader
    assertTrue(scan.next());
    batch = scan.batchAccessor();
    assertEquals(25, batch.rowCount());
    batch.release();
    // No second batch
    assertFalse(scan.next());
    scanFixture.close();
    assertTrue(reader1.openCalled);
    assertTrue(reader2.openCalled);
}
Also used : ScanFixture(org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture) BatchAccessor(org.apache.drill.exec.physical.impl.protocol.BatchAccessor) Test(org.junit.Test)

Example 13 with BatchAccessor

use of org.apache.drill.exec.physical.impl.protocol.BatchAccessor in project drill by apache.

the class TestScanOperExecLimit method testLimit1.

/**
 * LIMIT 1, simplest case
 */
@Test
public void testLimit1() {
    Mock50RowReader reader1 = new Mock50RowReader();
    Mock50RowReader reader2 = new Mock50RowReader();
    BaseScanFixtureBuilder builder = simpleBuilder(reader1, reader2);
    builder.builder.limit(1);
    ScanFixture scanFixture = builder.build();
    ScanOperatorExec scan = scanFixture.scanOp;
    assertTrue(scan.buildSchema());
    assertTrue(scan.next());
    BatchAccessor batch = scan.batchAccessor();
    assertEquals(1, batch.rowCount());
    batch.release();
    // No second batch or second reader
    assertFalse(scan.next());
    scanFixture.close();
    assertTrue(reader1.openCalled);
    assertFalse(reader2.openCalled);
}
Also used : ScanFixture(org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture) BatchAccessor(org.apache.drill.exec.physical.impl.protocol.BatchAccessor) Test(org.junit.Test)

Aggregations

BatchAccessor (org.apache.drill.exec.physical.impl.protocol.BatchAccessor)13 Test (org.junit.Test)13 ScanOperatorExec (org.apache.drill.exec.physical.impl.scan.ScanOperatorExec)7 ScanFixture (org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture)7 UnlikelyTest (org.apache.drill.categories.UnlikelyTest)1 ManagedReader (org.apache.drill.exec.physical.impl.scan.framework.ManagedReader)1 SchemaNegotiator (org.apache.drill.exec.physical.impl.scan.framework.SchemaNegotiator)1 SubOperatorTest (org.apache.drill.test.SubOperatorTest)1