Github user gvramana commented on a diff in the pull request: https://github.com/apache/carbondata/pull/2131#discussion_r178714736 --- Diff: core/src/main/java/org/apache/carbondata/core/indexstore/blockletindex/SegmentIndexFileStore.java --- @@ -200,6 +216,90 @@ public void readAllIIndexOfSegment(CarbonFile[] carbonFiles) throws IOException return indexFiles; } + /** + * Read all index file names of the carbon File Path. + * + * @return + * @throws IOException + */ + public Map<String, String> getReadCommittedIndexFilesFromPath(String carbonFilePath) + throws IOException { + // Get only those index files which are mentioned in the + CarbonFile[] carbonIndexFiles = getCarbonIndexFiles(carbonFilePath, carbonIndexMap); + Map<String, String> indexFiles = new HashMap<>(); + for (int i = 0; i < carbonIndexFiles.length; i++) { + if (carbonIndexFiles[i].getName().endsWith(CarbonTablePath.MERGE_INDEX_FILE_EXT)) { + List<String> indexFilesFromMergeFile = + getIndexFilesFromMergeFile(carbonIndexFiles[i].getCanonicalPath()); + for (String file : indexFilesFromMergeFile) { + indexFiles.put(carbonIndexFiles[i].getParentFile().getAbsolutePath() + + CarbonCommonConstants.FILE_SEPARATOR + file, carbonIndexFiles[i].getName()); + } + } else if (carbonIndexFiles[i].getName().endsWith(CarbonTablePath.INDEX_FILE_EXT)) { + indexFiles.put(carbonIndexFiles[i].getAbsolutePath(), null); + } + } + return indexFiles; + } + + /** + * Read all index file names of the segment + * + * @return + * @throws IOException + */ + public Map<String, String> getReadCommittedIndexFilesFromPath(String path, List<Segment> segments) + throws IOException { + // Only returns indexes matching the segment. + Map<String, String> indexFiles = new HashMap<>(); + for (Segment seg : segments) { + CarbonFile[] carbonIndexFiles = getCarbonIndexFiles(path, carbonIndexMap); + for (int i = 0; i < carbonIndexFiles.length; i++) { --- End diff -- Duplicate logic across functions
---