Search in sources :

Example 6 with MockScanEntry

use of org.apache.drill.exec.store.mock.MockTableDef.MockScanEntry in project drill by apache.

the class MockGroupScanPOP method applyAssignments.

@SuppressWarnings("unchecked")
@Override
public void applyAssignments(List<DrillbitEndpoint> endpoints) {
    Preconditions.checkArgument(endpoints.size() <= getReadEntries().size());
    mappings = new LinkedList[endpoints.size()];
    int i = 0;
    for (MockScanEntry e : this.getReadEntries()) {
        if (i == endpoints.size()) {
            i -= endpoints.size();
        }
        LinkedList<MockScanEntry> entries = mappings[i];
        if (entries == null) {
            entries = new LinkedList<MockScanEntry>();
            mappings[i] = entries;
        }
        entries.add(e);
        i++;
    }
}
Also used : MockScanEntry(org.apache.drill.exec.store.mock.MockTableDef.MockScanEntry) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)

Example 7 with MockScanEntry

use of org.apache.drill.exec.store.mock.MockTableDef.MockScanEntry in project drill by apache.

the class MockScanBatchCreator method getBatch.

@Override
public CloseableRecordBatch getBatch(ExecutorFragmentContext context, MockSubScanPOP config, List<RecordBatch> children) throws ExecutionSetupException {
    Preconditions.checkArgument(children.isEmpty());
    final List<MockScanEntry> entries = config.getReadEntries();
    MockScanEntry first = entries.get(0);
    if (first.isExtended()) {
        return extendedMockScan(context, config, entries);
    } else {
        return legacyMockScan(context, config, entries);
    }
}
Also used : MockScanEntry(org.apache.drill.exec.store.mock.MockTableDef.MockScanEntry)

Example 8 with MockScanEntry

use of org.apache.drill.exec.store.mock.MockTableDef.MockScanEntry 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);
}
Also used : ScanFrameworkBuilder(org.apache.drill.exec.physical.impl.scan.framework.ManagedScanFramework.ScanFrameworkBuilder) MockScanEntry(org.apache.drill.exec.store.mock.MockTableDef.MockScanEntry) ManagedReader(org.apache.drill.exec.physical.impl.scan.framework.ManagedReader) LinkedList(java.util.LinkedList) BasicScanFactory(org.apache.drill.exec.physical.impl.scan.framework.BasicScanFactory) ManagedScanFramework(org.apache.drill.exec.physical.impl.scan.framework.ManagedScanFramework) SchemaPath(org.apache.drill.common.expression.SchemaPath) ScanOperatorExec(org.apache.drill.exec.physical.impl.scan.ScanOperatorExec) OperatorRecordBatch(org.apache.drill.exec.physical.impl.protocol.OperatorRecordBatch)

Aggregations

MockScanEntry (org.apache.drill.exec.store.mock.MockTableDef.MockScanEntry)8 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)4 SchemaPath (org.apache.drill.common.expression.SchemaPath)3 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 MinorType (org.apache.drill.common.types.TypeProtos.MinorType)2 ScanBatch (org.apache.drill.exec.physical.impl.ScanBatch)2 RecordReader (org.apache.drill.exec.store.RecordReader)2 MockColumn (org.apache.drill.exec.store.mock.MockTableDef.MockColumn)2 OperatorRecordBatch (org.apache.drill.exec.physical.impl.protocol.OperatorRecordBatch)1 ScanOperatorExec (org.apache.drill.exec.physical.impl.scan.ScanOperatorExec)1 BasicScanFactory (org.apache.drill.exec.physical.impl.scan.framework.BasicScanFactory)1 ManagedReader (org.apache.drill.exec.physical.impl.scan.framework.ManagedReader)1 ManagedScanFramework (org.apache.drill.exec.physical.impl.scan.framework.ManagedScanFramework)1 ScanFrameworkBuilder (org.apache.drill.exec.physical.impl.scan.framework.ManagedScanFramework.ScanFrameworkBuilder)1