public AbstractDetailQueryResultIterator(
     List<BlockExecutionInfo> infos,
     QueryExecutorProperties executerProperties,
     QueryModel queryModel,
     InternalQueryExecutor queryExecutor) {
   int recordSize = 0;
   String defaultInMemoryRecordsSize =
       CarbonProperties.getInstance().getProperty(CarbonCommonConstants.INMEMORY_REOCRD_SIZE);
   if (null != defaultInMemoryRecordsSize) {
     try {
       recordSize = Integer.parseInt(defaultInMemoryRecordsSize);
     } catch (NumberFormatException ne) {
       LOGGER.error("Invalid inmemory records size. Using default value");
       recordSize = CarbonCommonConstants.INMEMORY_REOCRD_SIZE_DEFAULT;
     }
   }
   this.numberOfCores =
       recordSize
           / Integer.parseInt(
               CarbonProperties.getInstance()
                   .getProperty(
                       CarbonCommonConstants.BLOCKLET_SIZE,
                       CarbonCommonConstants.BLOCKLET_SIZE_DEFAULT_VAL));
   if (numberOfCores == 0) {
     numberOfCores++;
   }
   executor = queryExecutor;
   this.blockExecutionInfos = infos;
   this.blockIndexToBeExecuted = new int[(int) numberOfCores];
   intialiseInfos();
 }
  @Override
  public void readFields(DataInput in) throws IOException {

    int sizeLoc = in.readInt();
    for (int i = 0; i < sizeLoc; i++) {
      byte[] b = new byte[in.readInt()];
      in.readFully(b);
      locations.add(new String(b, Charset.defaultCharset()));
    }

    byte[] buf = new byte[in.readInt()];
    in.readFully(buf);
    ByteArrayInputStream bis = new ByteArrayInputStream(buf);
    ObjectInputStream ois = new ObjectInputStream(bis);
    try {
      partition = (Partition) ois.readObject();
    } catch (ClassNotFoundException e) {
      LOGGER.error(e, e.getMessage());
    }
    ois.close();
  }
  @Override
  public BatchResult prepareQueryResult(
      Result<List<ListBasedResultWrapper>, Object> scannedResult) {
    if ((null == scannedResult || scannedResult.size() < 1)) {
      return new BatchRawResult();
    }
    QueryDimension[] queryDimensions = querySchemaInfo.getQueryDimensions();
    int msrSize = queryExecuterProperties.measureDataTypes.length;
    int dimSize = queryDimensions.length;
    int[] order = querySchemaInfo.getQueryReverseOrder();
    Object[][] resultData = new Object[scannedResult.size()][];
    Object[] value;
    Object[] row;
    int counter = 0;
    if (queryModel.isRawBytesDetailQuery()) {
      while (scannedResult.hasNext()) {
        value = scannedResult.getValue();
        row = new Object[msrSize + 1];
        row[0] = scannedResult.getKey();
        if (value != null) {
          assert (value.length == msrSize);
          System.arraycopy(value, 0, row, 1, msrSize);
        }
        resultData[counter] = row;
        counter++;
      }
    } else {
      while (scannedResult.hasNext()) {
        value = scannedResult.getValue();
        row = new Object[msrSize + dimSize];
        ByteArrayWrapper key = scannedResult.getKey();
        if (key != null) {
          long[] surrogateResult =
              querySchemaInfo
                  .getKeyGenerator()
                  .getKeyArray(key.getDictionaryKey(), querySchemaInfo.getMaskedByteIndexes());
          int noDictionaryColumnIndex = 0;
          for (int i = 0; i < dimSize; i++) {
            if (!queryDimensions[i].getDimension().hasEncoding(Encoding.DICTIONARY)) {
              row[order[i]] =
                  DataTypeUtil.getDataBasedOnDataType(
                      new String(key.getNoDictionaryKeyByIndex(noDictionaryColumnIndex++)),
                      queryDimensions[i].getDimension().getDataType());
            } else if (queryDimensions[i].getDimension().hasEncoding(Encoding.DIRECT_DICTIONARY)) {
              DirectDictionaryGenerator directDictionaryGenerator =
                  DirectDictionaryKeyGeneratorFactory.getDirectDictionaryGenerator(
                      queryDimensions[i].getDimension().getDataType());
              if (directDictionaryGenerator != null) {
                row[order[i]] =
                    directDictionaryGenerator.getValueFromSurrogate(
                        (int) surrogateResult[queryDimensions[i].getDimension().getKeyOrdinal()]);
              }
            } else {
              row[order[i]] =
                  (int) surrogateResult[queryDimensions[i].getDimension().getKeyOrdinal()];
            }
          }
        }
        for (int i = 0; i < msrSize; i++) {
          row[order[i + queryDimensions.length]] = value[i];
        }
        resultData[counter] = row;
        counter++;
      }
    }

    LOGGER.info("###########################---- Total Number of records" + scannedResult.size());
    BatchRawResult result = new BatchRawResult();
    result.setRows(resultData);
    return result;
  }