yihua commented on code in PR #20078:
URL: https://github.com/apache/hudi/pull/20078#discussion_r4189340346


##########
hudi-common/src/main/java/org/apache/hudi/common/table/read/FileGroupReaderTableState.java:
##########
@@ -0,0 +1,247 @@
+/*
+ * 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;
+
+import org.apache.hudi.common.function.SerializableSupplier;
+import org.apache.hudi.common.schema.internal.InternalSchema;
+import org.apache.hudi.common.schema.internal.utils.InternalSchemaUtils;
+import org.apache.hudi.common.schema.internal.utils.SerDeHelper;
+import org.apache.hudi.common.table.HoodieTableConfig;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.HoodieTableVersion;
+import org.apache.hudi.common.util.InternalSchemaCache;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.common.util.StringUtils;
+import org.apache.hudi.storage.StorageConfiguration;
+import org.apache.hudi.storage.StoragePath;
+
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+import java.io.Serializable;
+import java.util.TreeMap;
+
+/**
+ * The table-level state a file group reader needs, in place of a {@link 
HoodieTableMetaClient}.
+ *
+ * <p>A reader needs the table config and base path for every read. Only two 
cases need more: log blocks of tables
+ * before version 8 are checked against the committed instants, and 
schema-on-read resolves the schema a log block
+ * or file was written with. A state built with {@link #snapshotOf} answers 
the first from instants captured where the
+ * timeline is already loaded, so every reader of one query sees the same 
snapshot, and resolves schema versions
+ * where the reader runs. {@link #fromMetaClient} keeps the older behavior of 
loading both lazily from a meta client.
+ */
+@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
+public final class FileGroupReaderTableState implements Serializable {
+
+  private static final long serialVersionUID = 1L;
+
+  @Getter
+  private final StoragePath basePath;
+  @Getter
+  private final HoodieTableConfig tableConfig;
+  private final SerializableSupplier<CommittedInstants> 
committedInstantsSupplier;
+  private final InternalSchemaResolver internalSchemaResolver;
+  private transient volatile CommittedInstants committedInstants;
+
+  /**
+   * Captures the state from a meta client whose timeline is loaded. Schema 
versions are not captured: a reader that
+   * resolves one builds its own meta client on first use and searches the 
schema history through
+   * {@link InternalSchemaCache}.
+   *
+   * @param readsLogFiles whether the readers read log files; committed 
instants are captured only then, and only for
+   *                      tables before version 8
+   */
+  public static FileGroupReaderTableState snapshotOf(HoodieTableMetaClient 
metaClient, boolean readsLogFiles) {
+    HoodieTableConfig tableConfig = metaClient.getTableConfig();
+    Option<CommittedInstants> committed = readsLogFiles && 
tableConfig.getTableVersion().lesserThan(HoodieTableVersion.EIGHT)
+        ? 
Option.of(CommittedInstants.fromCommitsTimeline(metaClient.getCommitsTimeline()))
+        : Option.empty();
+    String basePath = String.valueOf(metaClient.getBasePath());

Review Comment:
   Use `toString()` as the base path is never null?



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