This is an automated email from the ASF dual-hosted git repository.
codope pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git
The following commit(s) were added to refs/heads/master by this push:
new 78d7ee7cba5 Closing fsview in HoodieTableFileIndex (#11497)
78d7ee7cba5 is described below
commit 78d7ee7cba593995fe05cd551e341409f2b3a353
Author: Sivabalan Narayanan <[email protected]>
AuthorDate: Sat Jun 29 05:06:50 2024 -0700
Closing fsview in HoodieTableFileIndex (#11497)
---
.../org/apache/hudi/BaseHoodieTableFileIndex.java | 45 +++++++++++-----------
.../common/table/view/SyncableFileSystemView.java | 2 +-
2 files changed, 23 insertions(+), 24 deletions(-)
diff --git
a/hudi-common/src/main/java/org/apache/hudi/BaseHoodieTableFileIndex.java
b/hudi-common/src/main/java/org/apache/hudi/BaseHoodieTableFileIndex.java
index bfa7cec717a..83ba64734a1 100644
--- a/hudi-common/src/main/java/org/apache/hudi/BaseHoodieTableFileIndex.java
+++ b/hudi-common/src/main/java/org/apache/hudi/BaseHoodieTableFileIndex.java
@@ -266,29 +266,28 @@ public abstract class BaseHoodieTableFileIndex implements
AutoCloseable {
HoodieTimeline activeTimeline = getActiveTimeline();
Option<HoodieInstant> latestInstant = activeTimeline.lastInstant();
- HoodieTableFileSystemView fileSystemView =
- new HoodieTableFileSystemView(metaClient, activeTimeline, allFiles);
-
- Option<String> queryInstant = specifiedQueryInstant.or(() ->
latestInstant.map(HoodieInstant::getTimestamp));
-
- validate(activeTimeline, queryInstant);
-
- // NOTE: For MOR table, when the compaction is inflight, we need to not
only fetch the
- // latest slices, but also include the base and log files of the
second-last version of
- // the file slice in the same file group as the latest file slice that is
under compaction.
- // This logic is realized by
`AbstractTableFileSystemView::getLatestMergedFileSlicesBeforeOrOn`
- // API. Note that for COW table, the merging logic of two slices does not
happen as there
- // is no compaction, thus there is no performance impact.
- return partitions.stream().collect(
- Collectors.toMap(
- Function.identity(),
- partitionPath ->
- queryInstant.map(instant ->
-
fileSystemView.getLatestMergedFileSlicesBeforeOrOn(partitionPath.path,
queryInstant.get())
- )
- .orElseGet(() ->
fileSystemView.getLatestFileSlices(partitionPath.path))
- .collect(Collectors.toList())
- ));
+ try (HoodieTableFileSystemView fileSystemView = new
HoodieTableFileSystemView(metaClient, activeTimeline, allFiles)) {
+ Option<String> queryInstant = specifiedQueryInstant.or(() ->
latestInstant.map(HoodieInstant::getTimestamp));
+ validate(activeTimeline, queryInstant);
+
+ // NOTE: For MOR table, when the compaction is inflight, we need to not
only fetch the
+ // latest slices, but also include the base and log files of the
second-last version of
+ // the file slice in the same file group as the latest file slice that
is under compaction.
+ // This logic is realized by
`AbstractTableFileSystemView::getLatestMergedFileSlicesBeforeOrOn`
+ // API. Note that for COW table, the merging logic of two slices does
not happen as there
+ // is no compaction, thus there is no performance impact.
+ HoodieTableFileSystemView finalFileSystemView = fileSystemView;
+ return partitions.stream().collect(
+ Collectors.toMap(
+ Function.identity(),
+ partitionPath ->
+ queryInstant.map(instant ->
+
finalFileSystemView.getLatestMergedFileSlicesBeforeOrOn(partitionPath.path,
queryInstant.get())
+ )
+ .orElseGet(() ->
finalFileSystemView.getLatestFileSlices(partitionPath.path))
+ .collect(Collectors.toList())
+ ));
+ }
}
protected List<PartitionPath> listPartitionPaths(List<String>
relativePartitionPaths,
diff --git
a/hudi-common/src/main/java/org/apache/hudi/common/table/view/SyncableFileSystemView.java
b/hudi-common/src/main/java/org/apache/hudi/common/table/view/SyncableFileSystemView.java
index dc6afaa0bec..ea76c69db0d 100644
---
a/hudi-common/src/main/java/org/apache/hudi/common/table/view/SyncableFileSystemView.java
+++
b/hudi-common/src/main/java/org/apache/hudi/common/table/view/SyncableFileSystemView.java
@@ -26,7 +26,7 @@ import
org.apache.hudi.common.table.view.TableFileSystemView.SliceView;
* update operations.
*/
public interface SyncableFileSystemView
- extends TableFileSystemView, BaseFileOnlyView, SliceView {
+ extends TableFileSystemView, BaseFileOnlyView, SliceView, AutoCloseable {