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);
}
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);
}
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());
}
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());
}
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());
}
Aggregations