From 5616830ae18ab3cbe1592d4e463a940342d25edc Mon Sep 17 00:00:00 2001 From: zhangyue19921010 <69956021+zhangyue19921010@users.noreply.github.com> Date: Sat, 4 Dec 2021 10:56:53 +0800 Subject: [PATCH] Revert "[HUDI-2489]Tuning HoodieROTablePathFilter by caching hoodieTableFileSystemView, aiming to reduce unnecessary list/get requests" Co-authored-by: yuezhang --- .../hudi/hadoop/HoodieROTablePathFilter.java | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/HoodieROTablePathFilter.java b/hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/HoodieROTablePathFilter.java index c797f59ef..d94018b88 100644 --- a/hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/HoodieROTablePathFilter.java +++ b/hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/HoodieROTablePathFilter.java @@ -78,11 +78,6 @@ public class HoodieROTablePathFilter implements Configurable, PathFilter, Serial */ Map metaClientCache; - /** - * HoodieTableFileSystemView Cache. - */ - private Map hoodieTableFileSystemViewCache; - /** * Hadoop configurations for the FileSystem. */ @@ -102,7 +97,6 @@ public class HoodieROTablePathFilter implements Configurable, PathFilter, Serial this.nonHoodiePathCache = new HashSet<>(); this.conf = new SerializableConfiguration(conf); this.metaClientCache = new HashMap<>(); - this.hoodieTableFileSystemViewCache = new HashMap<>(); } /** @@ -181,15 +175,8 @@ public class HoodieROTablePathFilter implements Configurable, PathFilter, Serial metaClientCache.put(baseDir.toString(), metaClient); } - HoodieTableMetaClient finalMetaClient = metaClient; - fsView = hoodieTableFileSystemViewCache.computeIfAbsent(baseDir.toString(), key -> - FileSystemViewManager.createInMemoryFileSystemView( - engineContext, - finalMetaClient, - HoodieInputFormatUtils.buildMetadataConfig(getConf()) - ) - ); - + fsView = FileSystemViewManager.createInMemoryFileSystemView(engineContext, + metaClient, HoodieInputFormatUtils.buildMetadataConfig(getConf())); String partition = FSUtils.getRelativePartitionPath(new Path(metaClient.getBasePath()), folder); List latestFiles = fsView.getLatestBaseFiles(partition).collect(Collectors.toList()); // populate the cache @@ -215,6 +202,10 @@ public class HoodieROTablePathFilter implements Configurable, PathFilter, Serial } nonHoodiePathCache.add(folder.toString()); return true; + } finally { + if (fsView != null) { + fsView.close(); + } } } else { // files is at < 3 level depth in FS tree, can't be hoodie dataset