fhan688 commented on code in PR #3456: URL: https://github.com/apache/fluss/pull/3456#discussion_r3400717679
########## fluss-lake/fluss-lake-hudi/src/main/java/org/apache/fluss/lake/hudi/source/HudiSplit.java: ########## @@ -0,0 +1,91 @@ +/* + * 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 java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** 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) { Review Comment: > `FileSlice#equals/hashCode` only compare `HoodieFileGroupId + baseInstantTime` (log files are not considered). If Hudi changes that contract in a future release, the equality semantics of `HudiSplit` will 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. Agreed. I updated `HudiSplit#equals/hashCode` to avoid depending on Hudi's `FileSlice#equals/hashCode` contract. 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. -- 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]
