core/src/main/java/org/apache/carbondata/core/scan/executor/impl/AbstractQueryExecutor.java
/**
   * Below method will be used to fill the executor properties based on query
   * model it will parse the query model and get the detail and fill it in
   * query properties
   *
   * @param queryModel
   */
Below method will be used to fill the executor properties based on query
model it will parse the query model and get the detail and fill it in
query properties

@param queryModel
Below method will be used to fill the executor properties based on query model it will parse the query model and get the detail and fill it in query properties @param queryModel
protected void initQuery(QueryModel queryModel) throws IOException {
    StandardLogService.setThreadName(StandardLogService.getPartitionID(
        queryModel.getAbsoluteTableIdentifier().getCarbonTableIdentifier().getTableName()),
        queryModel.getQueryId());
    LOGGER.info("Query will be executed on table: " + queryModel.getAbsoluteTableIdentifier()
        .getCarbonTableIdentifier().getTableName());
    queryProperties.executorService = Executors.newCachedThreadPool();
    queryProperties.queryStatisticsRecorder =
        CarbonTimeStatisticsFactory.createExecutorRecorder(queryModel.getQueryId());
    queryModel.setStatisticsRecorder(queryProperties.queryStatisticsRecorder);
    QueryUtil.resolveQueryModel(queryModel);
    QueryStatistic queryStatistic = new QueryStatistic();
    Collections.sort(queryModel.getTableBlockInfos());
    if (queryModel.getTableBlockInfos().get(0).getDetailInfo() != null) {
      List<AbstractIndex> indexList = new ArrayList<>();
      Map<String, List<TableBlockInfo>> listMap = new LinkedHashMap<>();
      for (TableBlockInfo blockInfo: queryModel.getTableBlockInfos()) {
        List<TableBlockInfo> tableBlockInfos = listMap.get(blockInfo.getFilePath());
        if (tableBlockInfos == null) {
          tableBlockInfos = new ArrayList<>();
          listMap.put(blockInfo.getFilePath(), tableBlockInfos);
        }
        BlockletDetailInfo blockletDetailInfo = blockInfo.getDetailInfo();
        if (blockletDetailInfo.getBlockletInfo() == null) {
          readAndFillBlockletInfo(blockInfo, tableBlockInfos, blockletDetailInfo);
        } else {
          tableBlockInfos.add(blockInfo);
        }
      }
      for (List<TableBlockInfo> tableBlockInfos: listMap.values()) {
        indexList.add(new IndexWrapper(tableBlockInfos));
      }
      queryProperties.dataBlocks = indexList;
    } else {
      CacheProvider cacheProvider = CacheProvider.getInstance();
      BlockIndexStore<TableBlockUniqueIdentifier, AbstractIndex> cache =
          (BlockIndexStore) cacheProvider.createCache(CacheType.EXECUTOR_BTREE);
      cache.removeTableBlocks(queryModel.getInvalidSegmentIds(),
          queryModel.getAbsoluteTableIdentifier());
      List<TableBlockUniqueIdentifier> tableBlockUniqueIdentifiers =
          prepareTableBlockUniqueIdentifier(queryModel.getTableBlockInfos(),
              queryModel.getAbsoluteTableIdentifier());
      cache.removeTableBlocksIfHorizontalCompactionDone(queryModel);
      queryProperties.dataBlocks = cache.getAll(tableBlockUniqueIdentifiers);
    }
    queryStatistic
        .addStatistics(QueryStatisticsConstants.LOAD_BLOCKS_EXECUTOR, System.currentTimeMillis());
    queryProperties.queryStatisticsRecorder.recordStatistics(queryStatistic);
    int measureCount = queryModel.getQueryMeasures().size();
    int currentIndex = 0;
    DataType[] dataTypes = new DataType[measureCount];
    for (QueryMeasure carbonMeasure : queryModel.getQueryMeasures()) {
      dataTypes[currentIndex] = carbonMeasure.getMeasure().getDataType();
      currentIndex++;
    }
    queryProperties.measureDataTypes = dataTypes;
    queryProperties.filterMeasures = new HashSet<>();
    queryProperties.complexFilterDimension = new HashSet<>();
    QueryUtil.getAllFilterDimensions(queryModel.getFilterExpressionResolverTree(),
        queryProperties.complexFilterDimension, queryProperties.filterMeasures);
    CarbonTable carbonTable = queryModel.getTable();
    TableProvider tableProvider = new SingleTableProvider(carbonTable);
    queryStatistic = new QueryStatistic();
    queryProperties.columnToDictionayMapping = QueryUtil
        .getDimensionDictionaryDetail(queryModel.getQueryDimension(),
            queryProperties.complexFilterDimension, queryModel.getAbsoluteTableIdentifier(),
            tableProvider);
    queryStatistic
        .addStatistics(QueryStatisticsConstants.LOAD_DICTIONARY, System.currentTimeMillis());
    queryProperties.queryStatisticsRecorder.recordStatistics(queryStatistic);
    queryModel.setColumnToDictionaryMapping(queryProperties.columnToDictionayMapping);
  }
protected void initQuery ( QueryModel queryModel ) throws IOException { StandardLogService . setThreadName ( StandardLogService . getPartitionID ( queryModel . getAbsoluteTableIdentifier ( ) . getCarbonTableIdentifier ( ) . getTableName ( ) ) , queryModel . getQueryId ( ) ) ; LOGGER . info ( "Query will be executed on table: " + queryModel . getAbsoluteTableIdentifier ( ) . getCarbonTableIdentifier ( ) . getTableName ( ) ) ; queryProperties . executorService = Executors . newCachedThreadPool ( ) ; queryProperties . queryStatisticsRecorder = CarbonTimeStatisticsFactory . createExecutorRecorder ( queryModel . getQueryId ( ) ) ; queryModel . setStatisticsRecorder ( queryProperties . queryStatisticsRecorder ) ; QueryUtil . resolveQueryModel ( queryModel ) ; QueryStatistic queryStatistic = new QueryStatistic ( ) ; Collections . sort ( queryModel . getTableBlockInfos ( ) ) ; if ( queryModel . getTableBlockInfos ( ) . get ( 0 ) . getDetailInfo ( ) != null ) { List < AbstractIndex > indexList = new ArrayList < > ( ) ; Map < String , List < TableBlockInfo > > listMap = new LinkedHashMap < > ( ) ; for ( TableBlockInfo blockInfo : queryModel . getTableBlockInfos ( ) ) { List < TableBlockInfo > tableBlockInfos = listMap . get ( blockInfo . getFilePath ( ) ) ; if ( tableBlockInfos == null ) { tableBlockInfos = new ArrayList < > ( ) ; listMap . put ( blockInfo . getFilePath ( ) , tableBlockInfos ) ; } BlockletDetailInfo blockletDetailInfo = blockInfo . getDetailInfo ( ) ; if ( blockletDetailInfo . getBlockletInfo ( ) == null ) { readAndFillBlockletInfo ( blockInfo , tableBlockInfos , blockletDetailInfo ) ; } else { tableBlockInfos . add ( blockInfo ) ; } } for ( List < TableBlockInfo > tableBlockInfos : listMap . values ( ) ) { indexList . add ( new IndexWrapper ( tableBlockInfos ) ) ; } queryProperties . dataBlocks = indexList ; } else { CacheProvider cacheProvider = CacheProvider . getInstance ( ) ; BlockIndexStore < TableBlockUniqueIdentifier , AbstractIndex > cache = ( BlockIndexStore ) cacheProvider . createCache ( CacheType . EXECUTOR_BTREE ) ; cache . removeTableBlocks ( queryModel . getInvalidSegmentIds ( ) , queryModel . getAbsoluteTableIdentifier ( ) ) ; List < TableBlockUniqueIdentifier > tableBlockUniqueIdentifiers = prepareTableBlockUniqueIdentifier ( queryModel . getTableBlockInfos ( ) , queryModel . getAbsoluteTableIdentifier ( ) ) ; cache . removeTableBlocksIfHorizontalCompactionDone ( queryModel ) ; queryProperties . dataBlocks = cache . getAll ( tableBlockUniqueIdentifiers ) ; } queryStatistic . addStatistics ( QueryStatisticsConstants . LOAD_BLOCKS_EXECUTOR , System . currentTimeMillis ( ) ) ; queryProperties . queryStatisticsRecorder . recordStatistics ( queryStatistic ) ; int measureCount = queryModel . getQueryMeasures ( ) . size ( ) ; int currentIndex = 0 ; DataType [ ] dataTypes = new DataType [ measureCount ] ; for ( QueryMeasure carbonMeasure : queryModel . getQueryMeasures ( ) ) { dataTypes [ currentIndex ] = carbonMeasure . getMeasure ( ) . getDataType ( ) ; currentIndex ++ ; } queryProperties . measureDataTypes = dataTypes ; queryProperties . filterMeasures = new HashSet < > ( ) ; queryProperties . complexFilterDimension = new HashSet < > ( ) ; QueryUtil . getAllFilterDimensions ( queryModel . getFilterExpressionResolverTree ( ) , queryProperties . complexFilterDimension , queryProperties . filterMeasures ) ; CarbonTable carbonTable = queryModel . getTable ( ) ; TableProvider tableProvider = new SingleTableProvider ( carbonTable ) ; queryStatistic = new QueryStatistic ( ) ; queryProperties . columnToDictionayMapping = QueryUtil . getDimensionDictionaryDetail ( queryModel . getQueryDimension ( ) , queryProperties . complexFilterDimension , queryModel . getAbsoluteTableIdentifier ( ) , tableProvider ) ; queryStatistic . addStatistics ( QueryStatisticsConstants . LOAD_DICTIONARY , System . currentTimeMillis ( ) ) ; queryProperties . queryStatisticsRecorder . recordStatistics ( queryStatistic ) ; queryModel . setColumnToDictionaryMapping ( queryProperties . columnToDictionayMapping ) ; }
Below method will be used to fill the executor properties based on query
 model it will parse the query model and get the detail and fill it in
 query properties
Below method will be used to fill the executor properties based on query model it will parse the query model and get the detail and fill it in query properties
// add executor service for query execution // Initializing statistics list to record the query statistics // creating copy on write to handle concurrent scenario // sort the block info // so block will be loaded in sorted order this will be required for // query execution // This is the case of old stores where blocklet information is not available so read // the blocklet information from block file // get the table blocks // remove the invalid table blocks, block which is deleted or compacted // calculating the total number of aggeragted columns // adding the data type and aggregation type of all the measure this // can be used // to select the aggregator // as aggregation will be executed in following order // 1.aggregate dimension expression // 2. expression // 3. query measure // so calculating the index of the expression start index // and measure column start index // dictionary column unique column id to dictionary mapping // which will be used to get column actual data