TheR1sing3un commented on code in PR #11958:
URL: https://github.com/apache/hudi/pull/11958#discussion_r1766053548
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/compact/plan/generators/BaseHoodieCompactionPlanGenerator.java:
##########
@@ -82,18 +83,35 @@ public HoodieCompactionPlan generateCompactionPlan(String
compactionInstant) thr
// TODO - rollback any compactions in flight
HoodieTableMetaClient metaClient = hoodieTable.getMetaClient();
CompletionTimeQueryView completionTimeQueryView = new
CompletionTimeQueryView(metaClient);
- List<String> partitionPaths = FSUtils.getAllPartitionPaths(
+ List<String> allPartitionPaths = FSUtils.getAllPartitionPaths(
engineContext, metaClient.getStorage(),
writeConfig.getMetadataConfig(), metaClient.getBasePath());
+ List<String> regexFilterPartitionPaths;
+ if (!hoodieTable.isMetadataTable()) {
+ // match the partition path with regex pattern
+ String regexStr = writeConfig.getCompactionSpecifyPartitionPathRegex();
+ Pattern regexPattern = Pattern.compile(regexStr);
+ regexFilterPartitionPaths =
allPartitionPaths.stream().filter(regexPattern.asPredicate()).collect(toList());
+ LOG.info("Regex: {} matched {} partition paths from all {} partitions",
regexStr, regexFilterPartitionPaths.size(), allPartitionPaths.size());
+ } else {
+ regexFilterPartitionPaths = allPartitionPaths;
+ }
+ if (regexFilterPartitionPaths.isEmpty()) {
+ // In case no partitions could be picked, return no compaction plan
+ return null;
+ }
+
// filter the partition paths if needed to reduce list status
- partitionPaths = filterPartitionPathsByStrategy(writeConfig,
partitionPaths);
- if (partitionPaths.isEmpty()) {
+ List<String> strategyFilterPartitionPaths =
filterPartitionPathsByStrategy(writeConfig, regexFilterPartitionPaths);
+ LOG.info("Strategy: {} matched {} partition paths from all {} partitions",
+ writeConfig.getCompactionStrategy().getClass().getSimpleName(),
strategyFilterPartitionPaths.size(), regexFilterPartitionPaths.size());
+ if (strategyFilterPartitionPaths.isEmpty()) {
// In case no partitions could be picked, return no compaction plan
return null;
}
// avoid logging all partitions in table by default
- LOG.info("Looking for files to compact in {} partitions",
partitionPaths.size());
- LOG.debug("Partitions scanned for compaction: {}", partitionPaths);
+ LOG.info("Looking for files to compact in {} partitions",
strategyFilterPartitionPaths.size());
Review Comment:
> Isn't adding a new regex based `CompactionStrategy` also solves the
problem?
Yes, it is also a good way!But I think this separate model allows us to use
both capabilities simultaneously, for example, I filter some partitions by
regex and then filter and order log files by
`LogFileSizeBasedCompactionStrategy`.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]