Search in sources :

Example 1 with CarbonLocalInputSplit

use of org.apache.carbondata.presto.impl.CarbonLocalInputSplit in project carbondata by apache.

the class CarbondataRecordSet method cursor.

/**
 * get data blocks via Carbondata QueryModel API.
 */
@Override
public RecordCursor cursor() {
    CarbonLocalInputSplit carbonLocalInputSplit = split.getLocalInputSplit();
    List<CarbonInputSplit> splitList = new ArrayList<>(1);
    splitList.add(CarbonLocalInputSplit.convertSplit(carbonLocalInputSplit));
    List<TableBlockInfo> tableBlockInfoList = CarbonInputSplit.createBlocks(splitList);
    queryModel.setTableBlockInfos(tableBlockInfoList);
    queryExecutor = QueryExecutorFactory.getQueryExecutor(queryModel);
    try {
        readSupport.initialize(queryModel.getProjectionColumns(), queryModel.getTable());
        CarbonIterator iterator = queryExecutor.execute(queryModel);
        PrestoCarbonVectorizedRecordReader vectorReader = new PrestoCarbonVectorizedRecordReader(queryExecutor, queryModel, (AbstractDetailQueryResultIterator) iterator);
        return new CarbondataRecordCursor(readSupport, vectorReader, columns, split);
    } catch (QueryExecutionException e) {
        throw new RuntimeException(e.getMessage(), e);
    } catch (Exception ex) {
        throw new RuntimeException(ex.getMessage(), ex);
    }
}
Also used : TableBlockInfo(org.apache.carbondata.core.datastore.block.TableBlockInfo) QueryExecutionException(org.apache.carbondata.core.scan.executor.exception.QueryExecutionException) CarbonIterator(org.apache.carbondata.common.CarbonIterator) CarbonLocalInputSplit(org.apache.carbondata.presto.impl.CarbonLocalInputSplit) ArrayList(java.util.ArrayList) CarbonInputSplit(org.apache.carbondata.hadoop.CarbonInputSplit) QueryExecutionException(org.apache.carbondata.core.scan.executor.exception.QueryExecutionException)

Example 2 with CarbonLocalInputSplit

use of org.apache.carbondata.presto.impl.CarbonLocalInputSplit in project carbondata by apache.

the class CarbondataSplitManager method getSplits.

public ConnectorSplitSource getSplits(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorTableLayoutHandle layout) {
    CarbondataTableLayoutHandle layoutHandle = (CarbondataTableLayoutHandle) layout;
    CarbondataTableHandle tableHandle = layoutHandle.getTable();
    SchemaTableName key = tableHandle.getSchemaTableName();
    // Packaging presto-TupleDomain into CarbondataColumnConstraint, to decouple from presto-spi Module
    List<CarbondataColumnConstraint> rebuildConstraints = getColumnConstraints(layoutHandle.getConstraint());
    CarbonTableCacheModel cache = carbonTableReader.getCarbonCache(key);
    Expression filters = PrestoFilterUtil.parseFilterExpression(layoutHandle.getConstraint());
    try {
        List<CarbonLocalInputSplit> splits = carbonTableReader.getInputSplits2(cache, filters);
        ImmutableList.Builder<ConnectorSplit> cSplits = ImmutableList.builder();
        for (CarbonLocalInputSplit split : splits) {
            cSplits.add(new CarbondataSplit(connectorId, tableHandle.getSchemaTableName(), layoutHandle.getConstraint(), split, rebuildConstraints));
        }
        return new FixedSplitSource(cSplits.build());
    } catch (Exception ex) {
        throw new RuntimeException(ex.getMessage(), ex);
    }
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) SchemaTableName(com.facebook.presto.spi.SchemaTableName) Expression(org.apache.carbondata.core.scan.expression.Expression) FixedSplitSource(com.facebook.presto.spi.FixedSplitSource) CarbonLocalInputSplit(org.apache.carbondata.presto.impl.CarbonLocalInputSplit) CarbonTableCacheModel(org.apache.carbondata.presto.impl.CarbonTableCacheModel) ConnectorSplit(com.facebook.presto.spi.ConnectorSplit)

Aggregations

CarbonLocalInputSplit (org.apache.carbondata.presto.impl.CarbonLocalInputSplit)2 ConnectorSplit (com.facebook.presto.spi.ConnectorSplit)1 FixedSplitSource (com.facebook.presto.spi.FixedSplitSource)1 SchemaTableName (com.facebook.presto.spi.SchemaTableName)1 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 CarbonIterator (org.apache.carbondata.common.CarbonIterator)1 TableBlockInfo (org.apache.carbondata.core.datastore.block.TableBlockInfo)1 QueryExecutionException (org.apache.carbondata.core.scan.executor.exception.QueryExecutionException)1 Expression (org.apache.carbondata.core.scan.expression.Expression)1 CarbonInputSplit (org.apache.carbondata.hadoop.CarbonInputSplit)1 CarbonTableCacheModel (org.apache.carbondata.presto.impl.CarbonTableCacheModel)1