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


##########
hudi-common/src/main/java/org/apache/hudi/common/table/timeline/TimelineMetadataUtils.java:
##########
@@ -63,6 +58,19 @@
 public class TimelineMetadataUtils {
 
   private static final Integer DEFAULT_VERSION = 1;
+  private static final Map<Class<?>, DatumWriter<?>> DATUM_WRITERS = new 
ConcurrentHashMap<>();
+
+  // Legacy method to handle cases where byte [] is still used as opposed to 
leveraging HoodieInstantWriter.
+  @Deprecated
+  public static <T> byte[] convertMetadataToBytArray(T metadata, 
CommitMetadataSerDe serDe) {

Review Comment:
   ```suggestion
     public static <T> byte[] convertMetadataToByteArray(T metadata, 
CommitMetadataSerDe serDe) {
   ```



##########
hudi-common/src/main/java/org/apache/hudi/common/table/timeline/TimelineMetadataUtils.java:
##########
@@ -181,4 +140,17 @@ public static <T extends SpecificRecordBase> T 
deserializeAvroMetadata(InputStre
       return fileReader.next();
     }
   }
+
+  public static <T extends SpecificRecordBase> Option<HoodieInstantWriter> 
getInstantWriter(Option<T> metadata) {
+    if (metadata.isEmpty()) {
+      return Option.empty();
+    }
+    return Option.of(outputStream -> {
+      DatumWriter<T> datumWriter = (DatumWriter<T>) 
DATUM_WRITERS.computeIfAbsent(metadata.get().getClass(), 
SpecificDatumWriter::new);

Review Comment:
   Is `SpecificDatumWriter` thread-safe, i.e., using the same 
`SpecificDatumWriter` instance to serialize metadata concurrently does not 
incur any correctness issue?



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