use of org.apache.drill.exec.physical.impl.scan.framework.ManagedScanFramework in project drill by apache.
the class MockScanBatchCreator method extendedMockScan.
private CloseableRecordBatch extendedMockScan(FragmentContext context, MockSubScanPOP config, List<MockScanEntry> entries) {
List<SchemaPath> projList = new LinkedList<>();
projList.add(SchemaPath.STAR_COLUMN);
// Create batch readers up front. Handy when we know there are
// only one or two; else use an iterator and create them on the fly.
final List<ManagedReader<SchemaNegotiator>> readers = new LinkedList<>();
for (final MockTableDef.MockScanEntry e : entries) {
readers.add(new ExtendedMockBatchReader(e));
}
// Limit the batch size to 10 MB, or whatever the operator definition
// specified.
int batchSizeBytes = 10 * 1024 * 1024;
MockTableDef.MockScanEntry first = entries.get(0);
if (first.getBatchSize() > 0) {
batchSizeBytes = first.getBatchSize();
}
// Set the scan to allow the maximum row count, allowing
// each reader to adjust the batch size smaller if desired.
ScanFrameworkBuilder builder = new ScanFrameworkBuilder();
builder.batchByteLimit(batchSizeBytes);
builder.projection(projList);
builder.setReaderFactory(new BasicScanFactory(readers.iterator()));
ManagedScanFramework framework = new ManagedScanFramework(builder);
return new OperatorRecordBatch(context, config, new ScanOperatorExec(framework, false), false);
}
Aggregations