diff --git a/hudi-common/src/main/java/org/apache/hudi/common/util/InternalSchemaCache.java b/hudi-common/src/main/java/org/apache/hudi/common/util/InternalSchemaCache.java
index 4ac5b65a96f8c..b62f7742b5a46 100644
--- a/hudi-common/src/main/java/org/apache/hudi/common/util/InternalSchemaCache.java
+++ b/hudi-common/src/main/java/org/apache/hudi/common/util/InternalSchemaCache.java
@@ -79,18 +79,15 @@ public class InternalSchemaCache {
/**
* Search internalSchema based on versionID.
- * first step: try to get internalSchema from hoodie commit files, we no need to add lock.
- * if we cannot get internalSchema by first step, then we try to get internalSchema from cache.
+ *
+ *
The internalSchema is fetched from cache or history schema file directly, and should not
+ * be fetched from commit meta file since the overhead of scanning timeline is higher.
*
* @param versionID schema version_id need to search
* @param metaClient current hoodie metaClient
* @return internalSchema
*/
public static InternalSchema searchSchemaAndCache(long versionID, HoodieTableMetaClient metaClient) {
- Option candidateSchema = getSchemaByReadingCommitFile(versionID, metaClient);
- if (candidateSchema.isPresent()) {
- return candidateSchema.get();
- }
String tablePath = metaClient.getBasePath().toString();
// use segment lock to reduce competition.
synchronized (LOCK_LIST[tablePath.hashCode() & (LOCK_LIST.length - 1)]) {
@@ -119,21 +116,6 @@ private static TreeMap getHistoricalSchemas(HoodieTableMet
return result;
}
- private static Option getSchemaByReadingCommitFile(long versionID, HoodieTableMetaClient metaClient) {
- try {
- HoodieTimeline timeline = metaClient.getActiveTimeline().getCommitsTimeline().filterCompletedInstants();
- List instants = timeline.getInstantsAsStream().filter(f -> f.requestedTime().equals(String.valueOf(versionID))).collect(Collectors.toList());
- if (instants.isEmpty()) {
- return Option.empty();
- }
- HoodieCommitMetadata metadata = timeline.readCommitMetadata(instants.get(0));
- String latestInternalSchemaStr = metadata.getMetadata(SerDeHelper.LATEST_SCHEMA);
- return SerDeHelper.fromJson(latestInternalSchemaStr);
- } catch (Exception e) {
- throw new HoodieException("Failed to read schema from commit metadata", e);
- }
- }
-
/**
* Get internalSchema and avroSchema for compaction/cluster operation.
*