deniskuzZ commented on code in PR #4520: URL: https://github.com/apache/hive/pull/4520#discussion_r1305482603
########## ql/src/java/org/apache/hadoop/hive/ql/plan/ConditionalResolverMergeFiles.java: ########## @@ -419,17 +471,90 @@ private AverageSize getAverageSize(FileSystem inpFs, Path dirPath) { */ private long getMergeSize(FileSystem inpFs, Path dirPath, long avgSize) { AverageSize averageSize = getAverageSize(inpFs, dirPath); - if (averageSize.getTotalSize() < 0) { + return getMergeSize(averageSize, avgSize); + } + + private List<FileStatus> getManifestFilePaths(HiveConf conf, Path dirPath) throws IOException { + FileSystem manifestFs = dirPath.getFileSystem(conf); + List<String> filesKept; + List<FileStatus> pathsKept = new ArrayList<>(); + try (FSDataInputStream inStream = manifestFs.open(new Path(dirPath, Utilities.BLOB_MANIFEST_FILE))) { + String paths = IOUtils.toString(inStream, Charset.defaultCharset()); + filesKept = new ArrayList(Arrays.asList(paths.split(System.lineSeparator()))); + } + // The first string contains the directory information. Not useful. + filesKept.remove(0); + + for (String file : filesKept) { + pathsKept.add(manifestFs.getFileStatus(new Path(file))); + } + return pathsKept; + } + + private long getMergeSize(List<FileStatus> fileStatuses, long avgSize) { + AverageSize averageSize = getAverageSize(fileStatuses); + return getMergeSize(averageSize, avgSize); + } + + private long getMergeSize(AverageSize averageSize, long avgSize) { Review Comment: that is confusing input, could we rename AverageSize class to FilesSummary or something? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org