@@ -325,16 +325,13 @@ public static List<HoodieRecord> convertMetadataToFilesPartitionRecords(HoodieCo
325325 return map ;
326326 }
327327
328- int offset = partition .equals (NON_PARTITIONED_NAME )
329- ? (pathWithPartition .startsWith ("/" ) ? 1 : 0 )
330- : partition .length () + 1 ;
331- String filename = pathWithPartition .substring (offset );
328+ String fileName = FSUtils .getFileName (pathWithPartition , partitionStatName );
332329
333330 // Since write-stats are coming in no particular order, if the same
334331 // file have previously been appended to w/in the txn, we simply pick max
335332 // of the sizes as reported after every write, since file-sizes are
336333 // monotonically increasing (ie file-size never goes down, unless deleted)
337- map .merge (filename , stat .getFileSizeInBytes (), Math ::max );
334+ map .merge (fileName , stat .getFileSizeInBytes (), Math ::max );
338335
339336 return map ;
340337 },
@@ -410,12 +407,7 @@ public static HoodieData<HoodieRecord> convertMetadataToBloomFilterRecords(
410407 return Collections .emptyListIterator ();
411408 }
412409
413- // For partitioned table, "partition" contains the relative partition path;
414- // for non-partitioned table, "partition" is empty
415- int offset = StringUtils .isNullOrEmpty (partition )
416- ? (pathWithPartition .startsWith ("/" ) ? 1 : 0 ) : partition .length () + 1 ;
417-
418- final String fileName = pathWithPartition .substring (offset );
410+ String fileName = FSUtils .getFileName (pathWithPartition , partition );
419411 if (!FSUtils .isBaseFile (new Path (fileName ))) {
420412 return Collections .emptyListIterator ();
421413 }
@@ -1162,13 +1154,8 @@ private static Stream<HoodieRecord> getColumnStatsRecords(String partitionPath,
11621154 HoodieTableMetaClient datasetMetaClient ,
11631155 List <String > columnsToIndex ,
11641156 boolean isDeleted ) {
1165- String partitionName = getPartitionIdentifier (partitionPath );
1166- // NOTE: We have to chop leading "/" to make sure Hadoop does not treat it like
1167- // absolute path
11681157 String filePartitionPath = filePath .startsWith ("/" ) ? filePath .substring (1 ) : filePath ;
1169- String fileName = partitionName .equals (NON_PARTITIONED_NAME )
1170- ? filePartitionPath
1171- : filePartitionPath .substring (partitionName .length () + 1 );
1158+ String fileName = FSUtils .getFileName (filePath , partitionPath );
11721159
11731160 if (isDeleted ) {
11741161 // TODO we should delete records instead of stubbing them
0 commit comments