Search in sources :

Example 1 with BatchAccessor

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

the class TestScanOperExecLimit method testLimitOnEOF.

/**
 * LIMIT 100, at EOF of the first reader.
 */
@Test
public void testLimitOnEOF() {
    Mock50RowReader reader1 = new Mock50RowReader();
    Mock50RowReader reader2 = new Mock50RowReader();
    BaseScanFixtureBuilder builder = simpleBuilder(reader1, reader2);
    builder.builder.limit(100);
    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();
    // No 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 2 with BatchAccessor

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

the class TestScanOperExecLimit method testLimitOnScondBatch.

/**
 * LIMIT 75, halfway through second batch.
 */
@Test
public void testLimitOnScondBatch() {
    Mock50RowReader reader1 = new Mock50RowReader();
    Mock50RowReader reader2 = new Mock50RowReader();
    BaseScanFixtureBuilder builder = simpleBuilder(reader1, reader2);
    builder.builder.limit(75);
    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(25, batch.rowCount());
    batch.release();
    // No 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 3 with BatchAccessor

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

the class TestScanLimit method testLimitOnSecondReader.

/**
 * LIMIT 125: full first reader, limit on second
 */
@Test
public void testLimitOnSecondReader() {
    TestFixture fixture = new TestFixture(125);
    ScanOperatorExec scan = fixture.scan;
    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());
    fixture.close();
    // Both readers were created.
    assertEquals(2, fixture.createCount());
}
Also used : ScanOperatorExec(org.apache.drill.exec.physical.impl.scan.ScanOperatorExec) BatchAccessor(org.apache.drill.exec.physical.impl.protocol.BatchAccessor) Test(org.junit.Test)

Example 4 with BatchAccessor

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

the class TestScanLimit method testLimit0.

/**
 * LIMIT 0, to obtain only the schema.
 */
@Test
public void testLimit0() {
    TestFixture fixture = new TestFixture(0);
    ScanOperatorExec scan = fixture.scan;
    assertTrue(scan.buildSchema());
    BatchAccessor batch = scan.batchAccessor();
    assertEquals(0, batch.rowCount());
    assertEquals(1, batch.schema().getFieldCount());
    batch.release();
    // No second batch or second reader
    assertFalse(scan.next());
    fixture.close();
    // Only the first of the two readers were created.
    assertEquals(1, fixture.createCount());
}
Also used : ScanOperatorExec(org.apache.drill.exec.physical.impl.scan.ScanOperatorExec) BatchAccessor(org.apache.drill.exec.physical.impl.protocol.BatchAccessor) Test(org.junit.Test)

Example 5 with BatchAccessor

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

the class TestScanLimit method testLimitOnEOF.

/**
 * LIMIT 100, at EOF of the first reader.
 */
@Test
public void testLimitOnEOF() {
    TestFixture fixture = new TestFixture(100);
    ScanOperatorExec scan = fixture.scan;
    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();
    // No second reader
    assertFalse(scan.next());
    fixture.close();
    scan.close();
    // Only the first of the two readers were created.
    assertEquals(1, fixture.createCount());
}
Also used : ScanOperatorExec(org.apache.drill.exec.physical.impl.scan.ScanOperatorExec) 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