Search in sources :

Example 1 with CarbonVectorizedRecordReader

use of org.apache.carbondata.hadoop.util.CarbonVectorizedRecordReader in project carbondata by apache.

the class CarbonReaderBuilder method getRecordReader.

private <T> RecordReader getRecordReader(Job job, CarbonFileInputFormat format, List<RecordReader<Void, T>> readers, InputSplit split) throws IOException, InterruptedException {
    TaskAttemptContextImpl attempt = new TaskAttemptContextImpl(job.getConfiguration(), new TaskAttemptID());
    RecordReader reader;
    QueryModel queryModel = format.createQueryModel(split, attempt);
    boolean hasComplex = false;
    for (ProjectionDimension projectionDimension : queryModel.getProjectionDimensions()) {
        if (projectionDimension.getDimension().isComplex()) {
            hasComplex = true;
            break;
        }
    }
    if (useVectorReader && !hasComplex) {
        queryModel.setDirectVectorFill(filterExpression == null);
        reader = new CarbonVectorizedRecordReader(queryModel);
    } else {
        reader = format.createRecordReader(split, attempt);
    }
    try {
        reader.initialize(split, attempt);
    } catch (Exception e) {
        CarbonUtil.closeStreams(readers.toArray(new RecordReader[0]));
        throw e;
    }
    return reader;
}
Also used : TaskAttemptID(org.apache.hadoop.mapreduce.TaskAttemptID) TaskAttemptContextImpl(org.apache.hadoop.mapreduce.task.TaskAttemptContextImpl) CarbonVectorizedRecordReader(org.apache.carbondata.hadoop.util.CarbonVectorizedRecordReader) RecordReader(org.apache.hadoop.mapreduce.RecordReader) QueryModel(org.apache.carbondata.core.scan.model.QueryModel) ProjectionDimension(org.apache.carbondata.core.scan.model.ProjectionDimension) CarbonVectorizedRecordReader(org.apache.carbondata.hadoop.util.CarbonVectorizedRecordReader) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 ProjectionDimension (org.apache.carbondata.core.scan.model.ProjectionDimension)1 QueryModel (org.apache.carbondata.core.scan.model.QueryModel)1 CarbonVectorizedRecordReader (org.apache.carbondata.hadoop.util.CarbonVectorizedRecordReader)1 RecordReader (org.apache.hadoop.mapreduce.RecordReader)1 TaskAttemptID (org.apache.hadoop.mapreduce.TaskAttemptID)1 TaskAttemptContextImpl (org.apache.hadoop.mapreduce.task.TaskAttemptContextImpl)1