-
Notifications
You must be signed in to change notification settings - Fork 561
[lake/hudi] Introduce Hudi source split planner #3456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
luoyuxia
merged 5 commits into
apache:main
from
fhan688:Introduce-Hudi-source-split-planner
Jun 15, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6d22612
[lake/hudi] Introduce Hudi source split planner
fhan688 b1e782d
[lake/hudi] refine code impl according to copilot code review
fhan688 acd8943
Merge branch 'apache:main' into Introduce-Hudi-source-split-planner
fhan688 01c2c97
[lake/hudi] refine whole impl according to code review comments
fhan688 8947cc5
[lake/hudi] optimize HudiSplitPlanner
fhan688 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...-lake/fluss-lake-hudi/src/main/java/org/apache/fluss/lake/hudi/source/HudiLakeSource.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.fluss.lake.hudi.source; | ||
|
|
||
| import org.apache.fluss.config.Configuration; | ||
| import org.apache.fluss.lake.serializer.SimpleVersionedSerializer; | ||
| import org.apache.fluss.lake.source.LakeSource; | ||
| import org.apache.fluss.lake.source.Planner; | ||
| import org.apache.fluss.lake.source.RecordReader; | ||
| import org.apache.fluss.metadata.TablePath; | ||
| import org.apache.fluss.predicate.Predicate; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| /** Hudi implementation of {@link LakeSource}. */ | ||
| public class HudiLakeSource implements LakeSource<HudiSplit> { | ||
|
|
||
| private static final long serialVersionUID = 1L; | ||
|
|
||
| private final Configuration hudiConfig; | ||
| private final TablePath tablePath; | ||
|
|
||
| public HudiLakeSource(Configuration hudiConfig, TablePath tablePath) { | ||
| this.hudiConfig = hudiConfig; | ||
| this.tablePath = tablePath; | ||
| } | ||
|
|
||
| @Override | ||
| public void withProject(int[][] project) { | ||
| // Projection is applied by the Hudi record reader, which is not implemented yet. | ||
| } | ||
|
|
||
| @Override | ||
| public void withLimit(int limit) { | ||
| throw new UnsupportedOperationException("Hudi lake source does not support limit yet."); | ||
| } | ||
|
|
||
| @Override | ||
| public FilterPushDownResult withFilters(List<Predicate> predicates) { | ||
| return FilterPushDownResult.of(Collections.emptyList(), new ArrayList<>(predicates)); | ||
| } | ||
|
|
||
| @Override | ||
| public Planner<HudiSplit> createPlanner(PlannerContext context) throws IOException { | ||
| return new HudiSplitPlanner(hudiConfig, tablePath, context.snapshotId()); | ||
| } | ||
|
|
||
| @Override | ||
| public RecordReader createRecordReader(ReaderContext<HudiSplit> context) throws IOException { | ||
| throw new UnsupportedOperationException( | ||
| "Hudi lake source does not support record reading yet."); | ||
| } | ||
|
|
||
| @Override | ||
| public SimpleVersionedSerializer<HudiSplit> getSplitSerializer() { | ||
| return new HudiSplitSerializer(); | ||
| } | ||
| } |
122 changes: 122 additions & 0 deletions
122
fluss-lake/fluss-lake-hudi/src/main/java/org/apache/fluss/lake/hudi/source/HudiSplit.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.fluss.lake.hudi.source; | ||
|
|
||
| import org.apache.fluss.lake.source.LakeSplit; | ||
|
|
||
| import org.apache.hudi.common.model.FileSlice; | ||
| import org.apache.hudi.common.model.HoodieBaseFile; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Objects; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| /** A readable split of a Hudi table. */ | ||
| public class HudiSplit implements LakeSplit { | ||
|
|
||
| private static final long serialVersionUID = 1L; | ||
|
|
||
| private final FileSlice fileSlice; | ||
| private final int bucket; | ||
| private final List<String> partition; | ||
|
|
||
| public HudiSplit(FileSlice fileSlice, int bucket, List<String> partition) { | ||
| this.fileSlice = Objects.requireNonNull(fileSlice, "fileSlice cannot be null"); | ||
| this.bucket = bucket; | ||
| this.partition = | ||
| Collections.unmodifiableList( | ||
| new ArrayList<>( | ||
| Objects.requireNonNull(partition, "partition cannot be null"))); | ||
| } | ||
|
|
||
| @Override | ||
| public int bucket() { | ||
| return bucket; | ||
| } | ||
|
|
||
| @Override | ||
| public List<String> partition() { | ||
| return partition; | ||
| } | ||
|
|
||
| public FileSlice getFileSlice() { | ||
| return fileSlice; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (this == o) { | ||
| return true; | ||
| } | ||
| if (!(o instanceof HudiSplit)) { | ||
| return false; | ||
| } | ||
| HudiSplit hudiSplit = (HudiSplit) o; | ||
| return bucket == hudiSplit.bucket | ||
| && equalsFileSlice(fileSlice, hudiSplit.fileSlice) | ||
| && Objects.equals(partition, hudiSplit.partition); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash( | ||
| fileSlice.getFileGroupId(), | ||
| fileSlice.getBaseInstantTime(), | ||
| baseFilePath(fileSlice), | ||
| logFilePaths(fileSlice), | ||
| bucket, | ||
| partition); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "HudiSplit{" | ||
| + "fileSlice=" | ||
| + fileSlice | ||
| + ", bucket=" | ||
| + bucket | ||
| + ", partition=" | ||
| + partition | ||
| + '}'; | ||
| } | ||
|
|
||
| private static boolean equalsFileSlice(FileSlice first, FileSlice second) { | ||
| return Objects.equals(first.getFileGroupId(), second.getFileGroupId()) | ||
| && Objects.equals(first.getBaseInstantTime(), second.getBaseInstantTime()) | ||
| && Objects.equals(baseFilePath(first), baseFilePath(second)) | ||
| && Objects.equals(logFilePaths(first), logFilePaths(second)); | ||
| } | ||
|
|
||
| private static String baseFilePath(FileSlice fileSlice) { | ||
| if (!fileSlice.getBaseFile().isPresent()) { | ||
| return null; | ||
| } | ||
| HoodieBaseFile baseFile = fileSlice.getBaseFile().get(); | ||
| return baseFile.getPath(); | ||
| } | ||
|
|
||
| private static List<String> logFilePaths(FileSlice fileSlice) { | ||
| return fileSlice | ||
| .getLogFiles() | ||
| .map(logFile -> logFile.getPath().toString()) | ||
| .sorted() | ||
| .collect(Collectors.toList()); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FileSlice#equals/hashCodeonly compareHoodieFileGroupId + baseInstantTime(log files are not considered). If Hudi changes that contract in a future release, the equality semantics ofHudiSplitwill silently shift.Suggestion: either document this dependency in the class javadoc, or implement equality explicitly using
fileGroupId + baseInstantTime + baseFile.path + logFiles.paths. OK to defer to a follow-up PR if you prefer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I updated
HudiSplit#equals/hashCodeto avoid depending on Hudi'sFileSlice#equals/hashCodecontract. The split now compares stable slice identity fields explicitly: fileGroupId, baseInstantTime, base file path, log file paths, bucket, and partition. I also added a unit test to cover base/log file differences.