cshuo commented on code in PR #19502:
URL: https://github.com/apache/hudi/pull/19502#discussion_r3732967037


##########
hudi-common/src/main/java/org/apache/hudi/common/table/read/lsm/LsmReaderUtils.java:
##########
@@ -0,0 +1,47 @@
+/*
+ * 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.hudi.common.table.read.lsm;
+
+import org.apache.hudi.common.config.HoodieReaderConfig;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.model.HoodieLogFile;
+import org.apache.hudi.common.table.HoodieTableConfig;
+
+import java.util.stream.Stream;
+
+/**
+ * Utilities for selecting the LSM file group reader.
+ */
+public final class LsmReaderUtils {
+
+  private LsmReaderUtils() {
+  }
+
+  /**
+   * Returns whether the file group can be read with the LSM reader for the 
configured merge type.
+   */
+  public static boolean shouldUseLsmReader(
+      HoodieTableConfig tableConfig, Stream<HoodieLogFile> logFiles, String 
mergeType) {
+    // The LSM reader collapses all sorted versions of a key. Skip-merge 
queries intentionally
+    // expose those versions independently, so retain the classic unmerged 
reader for that mode.
+    return !HoodieReaderConfig.REALTIME_SKIP_MERGE.equalsIgnoreCase(mergeType)
+        && tableConfig.isLSMTreeStorageLayout()
+        && logFiles.allMatch(logFile -> 
FSUtils.isNativeLogFile(logFile.getFileName()));

Review Comment:
   Some call sites, such as HoodieMergeOnReadRDDV2, obtain log files directly 
from the partition split and do not have a FileSlice. Adding a FileSlice-based 
API would require retaining another overload or constructing a synthetic 
FileSlice, so it would not simplify the common API. I’d prefer to keep the 
native-log eligibility check centralized in LsmReaderUtils using 
Stream<HoodieLogFile>. Does that sound reasonable?



-- 
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]

Reply via email to