private Map<Integer, List<Reader>> matchBucketIdToBucketFiles(HiveConf conf, AcidDirectory dir,
                                                                       boolean includeBaseDir, boolean isMm) throws IOException {
    Map<Integer, List<Reader>> result = new HashMap<>();
    if (includeBaseDir && dir.getBaseDirectory() != null) {
      result.putAll(getBucketFiles(conf, dir.getBaseDirectory(), isMm));
    }
    for (AcidUtils.ParsedDelta deltaDir : dir.getCurrentDirectories()) {
      Path deltaDirPath = deltaDir.getPath();
      Map<Integer, List<Reader>> intermediateResult = getBucketFiles(conf, deltaDirPath, isMm);
      intermediateResult.forEach((k, v) -> result.merge(k, v, (v1, v2) -> {
        v1.addAll(v2);
        return v1;
      }));
    }
    return result;
  }
Collect the list of all bucket file paths, which belong to the same bucket Id. This method scans all the base
and delta dirs.
@param conf hive configuration, must be not null
@param dir the root directory of delta dirs
@param includeBaseDir true, if the base directory should be scanned
@param isMm true, if the table is an insert only table
@return map of bucket ID -> bucket files
@throws IOException an error happened during the reading of the directory/bucket file
ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/MergeCompactor.java