nsivabalan commented on code in PR #7841:
URL: https://github.com/apache/hudi/pull/7841#discussion_r1096257382


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadataWriter.java:
##########
@@ -1086,39 +1086,44 @@ private void initialCommit(String createInstantTime, 
List<MetadataPartitionType>
 
     Map<MetadataPartitionType, HoodieData<HoodieRecord>> partitionToRecordsMap 
= new HashMap<>();
 
-    List<DirectoryInfo> partitionInfoList = listAllPartitions(dataMetaClient);
-    Map<String, Map<String, Long>> partitionToFilesMap = 
partitionInfoList.stream()
-        .map(p -> {
-          String partitionName = 
HoodieTableMetadataUtil.getPartitionIdentifier(p.getRelativePath());
-          return Pair.of(partitionName, p.getFileNameToSizeMap());
-        })
-        .collect(Collectors.toMap(Pair::getKey, Pair::getValue));
-
-    int totalDataFilesCount = 
partitionToFilesMap.values().stream().mapToInt(Map::size).sum();
-    List<String> partitions = new ArrayList<>(partitionToFilesMap.keySet());
-
-    if (partitionTypes.contains(MetadataPartitionType.FILES)) {
-      // Record which saves the list of all partitions
-      HoodieRecord allPartitionRecord = 
HoodieMetadataPayload.createPartitionListRecord(partitions);
-      HoodieData<HoodieRecord> filesPartitionRecords = 
getFilesPartitionRecords(createInstantTime, partitionInfoList, 
allPartitionRecord);
-      ValidationUtils.checkState(filesPartitionRecords.count() == 
(partitions.size() + 1));
-      partitionToRecordsMap.put(MetadataPartitionType.FILES, 
filesPartitionRecords);
-    }
+    // skip parsing file system for metadata records if its first commit for 
the table.
+    if (dataMetaClient.getActiveTimeline().getWriteTimeline().countInstants() 
> 1
+        || 
dataMetaClient.getActiveTimeline().getWriteTimeline().filterCompletedInstants().countInstants()
 != 0) {
+      List<DirectoryInfo> partitionInfoList = 
listAllPartitions(dataMetaClient);

Review Comment:
   I have changed the way we deduce the first commit. essentially piggy backing 
on the initial commit instant time. If its 
SOLO_COMMIT_TIMESTAMP("00000000000000"), then we know its a fresh table. If 
not, its an already existing table. 



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