Search in sources :

Example 51 with ResultSetLoader

use of org.apache.drill.exec.physical.resultSet.ResultSetLoader in project drill by apache.

the class SasBatchReader method open.

@Override
public boolean open(FileScanFramework.FileSchemaNegotiator negotiator) {
    split = negotiator.split();
    errorContext = negotiator.parentErrorContext();
    openFile(negotiator);
    TupleMetadata schema;
    if (negotiator.hasProvidedSchema()) {
        schema = negotiator.providedSchema();
    } else {
        schema = buildSchema();
    }
    schema = addImplicitColumnsToSchema(schema);
    negotiator.tableSchema(schema, true);
    ResultSetLoader loader = negotiator.build();
    rowWriter = loader.writer();
    buildWriterList(schema);
    return true;
}
Also used : ResultSetLoader(org.apache.drill.exec.physical.resultSet.ResultSetLoader) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata)

Example 52 with ResultSetLoader

use of org.apache.drill.exec.physical.resultSet.ResultSetLoader in project drill by apache.

the class SpssBatchReader method open.

@Override
public boolean open(FileSchemaNegotiator negotiator) {
    split = negotiator.split();
    openFile(negotiator);
    negotiator.tableSchema(buildSchema(), true);
    errorContext = negotiator.parentErrorContext();
    ResultSetLoader loader = negotiator.build();
    rowWriter = loader.writer();
    buildReaderList();
    return true;
}
Also used : ResultSetLoader(org.apache.drill.exec.physical.resultSet.ResultSetLoader)

Example 53 with ResultSetLoader

use of org.apache.drill.exec.physical.resultSet.ResultSetLoader in project drill by apache.

the class SyslogBatchReader method open.

@Override
public boolean open(FileSchemaNegotiator negotiator) {
    split = negotiator.split();
    openFile(negotiator);
    negotiator.tableSchema(buildSchema(), false);
    errorContext = negotiator.parentErrorContext();
    ResultSetLoader loader = negotiator.build();
    rowWriter = loader.writer();
    writerArray = populateRowWriters();
    rawColumnWriter = rowWriter.scalar(RAW_COLUMN_NAME);
    messageWriter = rowWriter.scalar("message");
    return true;
}
Also used : ResultSetLoader(org.apache.drill.exec.physical.resultSet.ResultSetLoader)

Example 54 with ResultSetLoader

use of org.apache.drill.exec.physical.resultSet.ResultSetLoader in project drill by apache.

the class HttpdLogBatchReader method open.

@Override
public boolean open(FileSchemaNegotiator negotiator) {
    // Open the input stream to the log file
    openFile(negotiator);
    errorContext = negotiator.parentErrorContext();
    try {
        parser = new HttpdParser(formatConfig.getLogFormat(), formatConfig.getTimestampFormat(), formatConfig.getFlattenWildcards(), formatConfig.getParseUserAgent(), formatConfig.getLogParserRemapping(), scan);
        negotiator.tableSchema(parser.setupParser(), false);
    } catch (Exception e) {
        throw UserException.dataReadError(e).message("Error opening HTTPD file: " + e.getMessage()).addContext(errorContext).build(logger);
    }
    ResultSetLoader loader = negotiator.build();
    rowWriter = loader.writer();
    parser.addFieldsToParser(rowWriter);
    rawLineWriter = addImplicitColumn(RAW_LINE_COL_NAME, MinorType.VARCHAR);
    matchedWriter = addImplicitColumn(MATCHED_COL_NAME, MinorType.BIT);
    return true;
}
Also used : ResultSetLoader(org.apache.drill.exec.physical.resultSet.ResultSetLoader) UserException(org.apache.drill.common.exceptions.UserException) IOException(java.io.IOException)

Example 55 with ResultSetLoader

use of org.apache.drill.exec.physical.resultSet.ResultSetLoader in project drill by apache.

the class ImageBatchReader method open.

@Override
public boolean open(FileSchemaNegotiator negotiator) {
    try {
        errorContext = negotiator.parentErrorContext();
        DrillFileSystem dfs = negotiator.fileSystem();
        path = dfs.makeQualified(negotiator.split().getPath());
        fileStatus = dfs.getFileStatus(path);
        metaInputStream = new BufferedInputStream(dfs.openPossiblyCompressedStream(path));
        logger.debug("The config is {}, root is {}, columns has {}", config, scan.getSelectionRoot(), scan.getColumns());
    } catch (IOException e) {
        throw UserException.dataReadError(e).message("Failure in initial image inputstream. " + e.getMessage()).addContext(errorContext).build(logger);
    }
    // define the schema
    negotiator.tableSchema(defineMetadata(), false);
    ResultSetLoader resultSetLoader = negotiator.build();
    loader = resultSetLoader.writer();
    // bind the writer for generic columns
    bindColumns(loader);
    return true;
}
Also used : ResultSetLoader(org.apache.drill.exec.physical.resultSet.ResultSetLoader) DrillFileSystem(org.apache.drill.exec.store.dfs.DrillFileSystem) BufferedInputStream(java.io.BufferedInputStream) IOException(java.io.IOException)

Aggregations

ResultSetLoader (org.apache.drill.exec.physical.resultSet.ResultSetLoader)129 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)110 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)110 Test (org.junit.Test)110 SubOperatorTest (org.apache.drill.test.SubOperatorTest)109 RowSetLoader (org.apache.drill.exec.physical.resultSet.RowSetLoader)90 SingleRowSet (org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet)81 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)61 ResultSetOptions (org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions)29 TupleWriter (org.apache.drill.exec.vector.accessor.TupleWriter)25 ScalarWriter (org.apache.drill.exec.vector.accessor.ScalarWriter)24 SchemaPath (org.apache.drill.common.expression.SchemaPath)23 MockScanBuilder (org.apache.drill.exec.physical.impl.scan.ScanTestUtils.MockScanBuilder)18 ReaderSchemaOrchestrator (org.apache.drill.exec.physical.impl.scan.project.ReaderSchemaOrchestrator)18 ScanSchemaOrchestrator (org.apache.drill.exec.physical.impl.scan.project.ScanSchemaOrchestrator)18 ScanOrchestratorBuilder (org.apache.drill.exec.physical.impl.scan.project.ScanSchemaOrchestrator.ScanOrchestratorBuilder)18 VectorContainer (org.apache.drill.exec.record.VectorContainer)18 RowSetReader (org.apache.drill.exec.physical.rowSet.RowSetReader)17 ArrayWriter (org.apache.drill.exec.vector.accessor.ArrayWriter)15 BatchSchemaBuilder (org.apache.drill.exec.record.BatchSchemaBuilder)13