use of org.apache.drill.exec.physical.impl.scan.RowBatchReader in project drill by apache.
the class TestScanLifecycleBasics method testEarlySchemaTwoBatches.
@Test
public void testEarlySchemaTwoBatches() {
ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
builder.readerFactory(new SingleReaderFactory() {
@Override
public ManagedReader next(SchemaNegotiator negotiator) {
return new MockEarlySchemaReader(negotiator, 2);
}
});
ScanLifecycle scan = buildScan(builder);
assertSame(ProjectionType.ALL, scan.schemaTracker().projectionType());
RowBatchReader reader = scan.nextReader();
assertTrue(reader.open());
assertEquals(SCHEMA, scan.outputSchema());
assertTrue(reader.next());
RowSetUtilities.verify(simpleExpected(0), fixture.wrap(reader.output()));
assertTrue(reader.next());
RowSetUtilities.verify(simpleExpected(1), fixture.wrap(reader.output()));
assertFalse(reader.next());
reader.close();
scan.close();
}
use of org.apache.drill.exec.physical.impl.scan.RowBatchReader in project drill by apache.
the class TestScanLifecycleBasics method testEarlyEOF.
/**
* Single reader, late schema, early EOF.
* The scan never has a valid schema in this case.
*/
@Test
public void testEarlyEOF() {
ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
builder.readerFactory(new SingleReaderFactory() {
@Override
public ManagedReader next(SchemaNegotiator negotiator) throws EarlyEofException {
return new NoDataReader(negotiator);
}
});
ScanLifecycle scan = buildScan(builder);
RowBatchReader reader = scan.nextReader();
assertFalse(reader.open());
reader.close();
assertFalse(scan.hasOutputSchema());
scan.close();
}
use of org.apache.drill.exec.physical.impl.scan.RowBatchReader in project drill by apache.
the class TestScanLifecycleBasics method testEarlySchemaWithProjectNone.
@Test
public void testEarlySchemaWithProjectNone() {
ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
builder.projection(RowSetTestUtils.projectNone());
builder.readerFactory(new SingleReaderFactory() {
@Override
public ManagedReader next(SchemaNegotiator negotiator) {
return new MockEarlySchemaReader(negotiator, 1);
}
});
ScanLifecycle scan = buildScan(builder);
assertSame(ProjectionType.NONE, scan.schemaTracker().projectionType());
RowBatchReader reader = scan.nextReader();
assertTrue(reader.open());
// Early schema: so output schema is available after open
TupleMetadata expectedSchema = new SchemaBuilder().build();
assertEquals(expectedSchema, scan.outputSchema());
assertTrue(reader.next());
RowSet expected = fixture.rowSetBuilder(expectedSchema).addRow().addRow().build();
RowSetUtilities.verify(expected, fixture.wrap(reader.output()));
assertFalse(reader.next());
reader.close();
scan.close();
}
use of org.apache.drill.exec.physical.impl.scan.RowBatchReader in project drill by apache.
the class TestScanLifecycleBasics method testNullReaderWithSchema.
/**
* Single reader early schema, EOF on first next().
* Since this is an early-schema reader, there is an output
* schema even without any rows.
*/
@Test
public void testNullReaderWithSchema() {
ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
builder.readerFactory(new SingleReaderFactory() {
@Override
public ManagedReader next(SchemaNegotiator negotiator) {
return new MockEarlySchemaReader(negotiator, 0);
}
});
ScanLifecycle scan = buildScan(builder);
assertSame(ProjectionType.ALL, scan.schemaTracker().projectionType());
RowBatchReader reader = scan.nextReader();
assertTrue(reader.open());
// Early schema: so output schema is available after open
assertTrue(scan.hasOutputSchema());
assertEquals(SCHEMA, scan.outputSchema());
assertTrue(reader.next());
VectorContainer result = reader.output();
assertEquals(0, result.getRecordCount());
result.zeroVectors();
// Early schema with no additional columns discovered
assertEquals(SCHEMA, scan.outputSchema());
// But, no second batch.
assertFalse(reader.next());
reader.close();
scan.close();
}
use of org.apache.drill.exec.physical.impl.scan.RowBatchReader in project drill by apache.
the class TestFileScanLifecycle method testWildcard.
@Test
public void testWildcard() {
FileScanLifecycleBuilder builder = new FileScanLifecycleBuilder();
builder.rootDir(MOCK_ROOT_PATH);
builder.maxPartitionDepth(3);
builder.fileSplits(Collections.singletonList(new DummyFileWork(MOCK_FILE_PATH)));
builder.useLegacyWildcardExpansion(true);
builder.readerFactory(new FileReaderFactory() {
@Override
public ManagedReader newReader(FileSchemaNegotiator negotiator) {
return new MockEarlySchemaReader(negotiator, 1);
}
});
ScanLifecycle scan = buildScan(builder);
assertSame(ProjectionType.ALL, scan.schemaTracker().projectionType());
RowBatchReader reader = scan.nextReader();
assertTrue(reader.open());
assertTrue(reader.next());
TupleMetadata expectedSchema = new SchemaBuilder().addAll(SCHEMA).add(FileScanUtils.partitionColName(0), PARTITION_COL_TYPE).add(FileScanUtils.partitionColName(1), PARTITION_COL_TYPE).add(FileScanUtils.partitionColName(2), PARTITION_COL_TYPE).build();
RowSet expected = fixture.rowSetBuilder(expectedSchema).addRow(10, "fred", MOCK_DIR0, MOCK_DIR1, null).addRow(20, "wilma", MOCK_DIR0, MOCK_DIR1, null).build();
RowSetUtilities.verify(expected, fixture.wrap(reader.output()));
assertFalse(reader.next());
reader.close();
scan.close();
}
Aggregations