core/src/main/java/org/apache/carbondata/core/writer/CarbonIndexFileMergeWriter.java
/**
   * Merge all the carbonindex files of segment to a  merged file
   * @param segmentPath
   * @param indexFileNamesTobeAdded while merging it comsiders only these files.
   *                                If null then consider all
   * @param readFileFooterFromCarbonDataFile flag to read file footer information from carbondata
   *                                         file. This will used in case of upgrade from version
   *                                         which do not store the blocklet info to current version
   * @throws IOException
   */
Merge all the carbonindex files of segment to a  merged file
@param segmentPath
@param indexFileNamesTobeAdded while merging it comsiders only these files.
If null then consider all
@param readFileFooterFromCarbonDataFile flag to read file footer information from carbondata
file. This will used in case of upgrade from version
which do not store the blocklet info to current version
@throws IOException
Merge all the carbonindex files of segment to a merged file @param segmentPath @param indexFileNamesTobeAdded while merging it comsiders only these files . If null then consider all @param readFileFooterFromCarbonDataFile flag to read file footer information from carbondata file . This will used in case of upgrade from version which do not store the blocklet info to current version @throws IOException
private void mergeCarbonIndexFilesOfSegment(String segmentPath,
      List<String> indexFileNamesTobeAdded, boolean readFileFooterFromCarbonDataFile)
      throws IOException {
    CarbonFile[] indexFiles = SegmentIndexFileStore.getCarbonIndexFiles(segmentPath);
    if (isCarbonIndexFilePresent(indexFiles) || indexFileNamesTobeAdded != null) {
      SegmentIndexFileStore fileStore = new SegmentIndexFileStore();
      if (readFileFooterFromCarbonDataFile) {
        fileStore.readAllIndexAndFillBolckletInfo(segmentPath);
      } else {
        fileStore.readAllIIndexOfSegment(segmentPath);
      }
      Map<String, byte[]> indexMap = fileStore.getCarbonIndexMap();
      MergedBlockIndexHeader indexHeader = new MergedBlockIndexHeader();
      MergedBlockIndex mergedBlockIndex = new MergedBlockIndex();
      List<String> fileNames = new ArrayList<>(indexMap.size());
      List<ByteBuffer> data = new ArrayList<>(indexMap.size());
      for (Map.Entry<String, byte[]> entry : indexMap.entrySet()) {
        if (indexFileNamesTobeAdded == null ||
            indexFileNamesTobeAdded.contains(entry.getKey())) {
          fileNames.add(entry.getKey());
          data.add(ByteBuffer.wrap(entry.getValue()));
        }
      }
      if (fileNames.size() > 0) {
        openThriftWriter(
            segmentPath + "/" + System.currentTimeMillis() + CarbonTablePath.MERGE_INDEX_FILE_EXT);
        indexHeader.setFile_names(fileNames);
        mergedBlockIndex.setFileData(data);
        writeMergedBlockIndexHeader(indexHeader);
        writeMergedBlockIndex(mergedBlockIndex);
        close();
      }
      for (CarbonFile indexFile : indexFiles) {
        indexFile.delete();
      }
    }
  }
private void mergeCarbonIndexFilesOfSegment ( String segmentPath , List < String > indexFileNamesTobeAdded , boolean readFileFooterFromCarbonDataFile ) throws IOException { CarbonFile [ ] indexFiles = SegmentIndexFileStore . getCarbonIndexFiles ( segmentPath ) ; if ( isCarbonIndexFilePresent ( indexFiles ) || indexFileNamesTobeAdded != null ) { SegmentIndexFileStore fileStore = new SegmentIndexFileStore ( ) ; if ( readFileFooterFromCarbonDataFile ) { fileStore . readAllIndexAndFillBolckletInfo ( segmentPath ) ; } else { fileStore . readAllIIndexOfSegment ( segmentPath ) ; } Map < String , byte [ ] > indexMap = fileStore . getCarbonIndexMap ( ) ; MergedBlockIndexHeader indexHeader = new MergedBlockIndexHeader ( ) ; MergedBlockIndex mergedBlockIndex = new MergedBlockIndex ( ) ; List < String > fileNames = new ArrayList < > ( indexMap . size ( ) ) ; List < ByteBuffer > data = new ArrayList < > ( indexMap . size ( ) ) ; for ( Map . Entry < String , byte [ ] > entry : indexMap . entrySet ( ) ) { if ( indexFileNamesTobeAdded == null || indexFileNamesTobeAdded . contains ( entry . getKey ( ) ) ) { fileNames . add ( entry . getKey ( ) ) ; data . add ( ByteBuffer . wrap ( entry . getValue ( ) ) ) ; } } if ( fileNames . size ( ) > 0 ) { openThriftWriter ( segmentPath + "/" + System . currentTimeMillis ( ) + CarbonTablePath . MERGE_INDEX_FILE_EXT ) ; indexHeader . setFile_names ( fileNames ) ; mergedBlockIndex . setFileData ( data ) ; writeMergedBlockIndexHeader ( indexHeader ) ; writeMergedBlockIndex ( mergedBlockIndex ) ; close ( ) ; } for ( CarbonFile indexFile : indexFiles ) { indexFile . delete ( ) ; } } }
Merge all the carbonindex files of segment to a  merged file
 @param segmentPath
 @param indexFileNamesTobeAdded while merging it comsiders only these files.
Merge all the carbonindex files of segment to a merged file @param segmentPath @param indexFileNamesTobeAdded while merging it comsiders only these files .
// this case will be used in case of upgrade where old store will not have the blocklet // info in the index file and therefore blocklet info need to be read from the file footer // in the carbondata file