nsivabalan commented on code in PR #11562:
URL: https://github.com/apache/hudi/pull/11562#discussion_r1664603071
##########
hudi-common/src/main/java/org/apache/hudi/common/model/HoodieCommitMetadata.java:
##########
@@ -511,12 +515,32 @@ public int hashCode() {
return result;
}
- public static <T> T fromBytes(byte[] bytes, Class<T> clazz) throws
IOException {
+ /*public static <T> T fromBytes(byte[] bytes, Class<T> clazz) throws
IOException {
try {
return fromJsonString(fromUTF8Bytes(bytes), clazz);
} catch (Exception e) {
throw new IOException("unable to read commit metadata", e);
}
+ }*/
+
+ public static <T> T fromBytes(byte[] bytes, Class<T> clazz) throws
IOException {
+ try {
+ if (bytes.length == 0) {
+ return clazz.newInstance();
+ }
+ return fromJsonString(
+ fromUTF8Bytes(
+
convertCommitMetadataToJsonBytes(deserializeCommitMetadata(bytes),
org.apache.hudi.avro.model.HoodieCommitMetadata.class)),
+ clazz);
+ } catch (Exception e) {
+ LOG.info("Failed to deserialize commit metadata as avro, trying json ");
Review Comment:
NTR(note to reviewer): deser as avro. on exception we read it as json. We
can optimize this further by using magic bytes. but for now, this works.
--
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]