Search in sources :

Example 1 with BatchResult

use of org.apache.carbondata.core.scan.result.BatchResult in project carbondata by apache.

the class CarbondataRecordSet method cursor.

/**
   * get data blocks via Carbondata QueryModel API
   */
@Override
public RecordCursor cursor() {
    List<TableBlockInfo> tableBlockInfoList = new ArrayList<TableBlockInfo>();
    tableBlockInfoList.add(new TableBlockInfo(split.getLocalInputSplit().getPath().toString(), split.getLocalInputSplit().getStart(), split.getLocalInputSplit().getSegmentId(), split.getLocalInputSplit().getLocations().toArray(new String[0]), split.getLocalInputSplit().getLength(), //blockletInfos,
    ColumnarFormatVersion.valueOf(split.getLocalInputSplit().getVersion())));
    queryModel.setTableBlockInfos(tableBlockInfoList);
    queryExecutor = QueryExecutorFactory.getQueryExecutor(queryModel);
    //queryModel.setQueryId(queryModel.getQueryId() + "_" + split.getLocalInputSplit().getSegmentId());
    try {
        readSupport.initialize(queryModel.getProjectionColumns(), queryModel.getAbsoluteTableIdentifier());
        CarbonIterator<Object[]> carbonIterator = new ChunkRowIterator((CarbonIterator<BatchResult>) queryExecutor.execute(queryModel));
        RecordCursor rc = new CarbondataRecordCursor(readSupport, carbonIterator, columns, split);
        return rc;
    } 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) ChunkRowIterator(org.apache.carbondata.core.scan.result.iterator.ChunkRowIterator) QueryExecutionException(org.apache.carbondata.core.scan.executor.exception.QueryExecutionException) ArrayList(java.util.ArrayList) BatchResult(org.apache.carbondata.core.scan.result.BatchResult) QueryExecutionException(org.apache.carbondata.core.scan.executor.exception.QueryExecutionException)

Aggregations

ArrayList (java.util.ArrayList)1 TableBlockInfo (org.apache.carbondata.core.datastore.block.TableBlockInfo)1 QueryExecutionException (org.apache.carbondata.core.scan.executor.exception.QueryExecutionException)1 BatchResult (org.apache.carbondata.core.scan.result.BatchResult)1 ChunkRowIterator (org.apache.carbondata.core.scan.result.iterator.ChunkRowIterator)1