Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private void assignInserts(WorkloadProfile profile, HoodieEngineContext context)
WorkloadStat pStat = profile.getWorkloadStat(partitionPath);
if (pStat.getNumInserts() > 0) {

List<SmallFile> smallFiles = partitionSmallFilesMap.get(partitionPath);
List<SmallFile> smallFiles = partitionSmallFilesMap.getOrDefault(partitionPath, new ArrayList<>());
this.smallFiles.addAll(smallFiles);

LOG.info("For partitionPath : " + partitionPath + " Small Files => " + smallFiles);
Expand Down Expand Up @@ -205,6 +205,11 @@ private void assignInserts(WorkloadProfile profile, HoodieEngineContext context)

private Map<String, List<SmallFile>> getSmallFilesForPartitions(List<String> partitionPaths, HoodieEngineContext context) {
Map<String, List<SmallFile>> partitionSmallFilesMap = new HashMap<>();

if (config.getParquetSmallFileLimit() == 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using <= 0 to indicate always writing to new file group? And maybe add a description of this behavior to the document of PARQUET_SMALL_FILE_LIMIT.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can PARQUET_SMALL_FILE_LIMIT be set to be negative? I'm not sure.

Yeah, I'll add the description to the PARQUET_SMALL_FILE_LIMIT

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible to be set it to negative, which is meaningless of course. So I guess we could cover it as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return partitionSmallFilesMap;
}

if (partitionPaths != null && partitionPaths.size() > 0) {
context.setJobStatus(this.getClass().getSimpleName(), "Getting small files from partitions");
partitionSmallFilesMap = context.mapToPair(partitionPaths,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private void assignInserts(WorkloadProfile profile, HoodieEngineContext context)

List<SmallFile> smallFiles =
filterSmallFilesInClustering(partitionPathToPendingClusteringFileGroupsId.getOrDefault(partitionPath, Collections.emptySet()),
partitionSmallFilesMap.get(partitionPath));
partitionSmallFilesMap.getOrDefault(partitionPath, new ArrayList<>()));

this.smallFiles.addAll(smallFiles);

Expand Down Expand Up @@ -241,6 +241,11 @@ private void assignInserts(WorkloadProfile profile, HoodieEngineContext context)
private Map<String, List<SmallFile>> getSmallFilesForPartitions(List<String> partitionPaths, HoodieEngineContext context) {
JavaSparkContext jsc = HoodieSparkEngineContext.getSparkContext(context);
Map<String, List<SmallFile>> partitionSmallFilesMap = new HashMap<>();

if (config.getParquetSmallFileLimit() == 0) {
return partitionSmallFilesMap;
}

if (partitionPaths != null && partitionPaths.size() > 0) {
context.setJobStatus(this.getClass().getSimpleName(), "Getting small files from partitions");
JavaRDD<String> partitionPathRdds = jsc.parallelize(partitionPaths, partitionPaths.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ private List<FileSlice> getSmallFileCandidates(String partitionPath, HoodieInsta
.collect(Collectors.toList());
}

if (config.getParquetSmallFileLimit() == 0) {
return Collections.emptyList();
}

// If we cannot index log files, then we choose the smallest parquet file in the partition and add inserts to
// it. Doing this overtime for a partition, we ensure that we handle small file issues
return table.getSliceView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,14 @@ public synchronized List<SmallFile> getSmallFiles(String partitionPath) {
if (smallFilesMap.containsKey(partitionPath)) {
return smallFilesMap.get(partitionPath);
}
List<SmallFile> smallFiles = smallFilesProfile(partitionPath);

List<SmallFile> smallFiles = new ArrayList<>();
if (config.getParquetSmallFileLimit() == 0) {
this.smallFilesMap.put(partitionPath, smallFiles);
return smallFiles;
}

smallFiles = smallFilesProfile(partitionPath);
this.smallFilesMap.put(partitionPath, smallFiles);
return smallFiles;
}
Expand Down