Davis-Zhang-Onehouse commented on code in PR #12826:
URL: https://github.com/apache/hudi/pull/12826#discussion_r1972271549
##########
hudi-common/src/main/java/org/apache/hudi/common/table/timeline/TimelineMetadataUtils.java:
##########
@@ -156,59 +158,77 @@ public static Option<byte[]>
serializeCommitMetadata(CommitMetadataSerDe commitM
public static <T extends SpecificRecordBase> Option<byte[]>
serializeAvroMetadata(T metadata, Class<T> clazz)
throws IOException {
DatumWriter<T> datumWriter = new SpecificDatumWriter<>(clazz);
- DataFileWriter<T> fileWriter = new DataFileWriter<>(datumWriter);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- fileWriter.create(metadata.getSchema(), baos);
- fileWriter.append(metadata);
- fileWriter.flush();
- return Option.of(baos.toByteArray());
+ try (DataFileWriter<T> fileWriter = new DataFileWriter<>(datumWriter)) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ fileWriter.create(metadata.getSchema(), baos);
+ fileWriter.append(metadata);
+ fileWriter.flush();
+ return Option.of(baos.toByteArray());
+ }
+ }
+
+ public static HoodieCleanerPlan deserializeCleanerPlan(Option<InputStream>
in) throws IOException {
+ return deserializeAvroMetadata(in, HoodieCleanerPlan.class);
+ }
+
+ public static HoodieCompactionPlan
deserializeCompactionPlan(Option<InputStream> in) throws IOException {
+ return deserializeAvroMetadata(in, HoodieCompactionPlan.class);
}
- public static HoodieCleanerPlan deserializeCleanerPlan(byte[] bytes) throws
IOException {
- return deserializeAvroMetadata(bytes, HoodieCleanerPlan.class);
+ public static HoodieCompactionPlan deserializeCompactionPlanLegacy(byte[]
bytes) throws IOException {
+ return deserializeAvroMetadataLegacy(bytes, HoodieCompactionPlan.class);
}
- public static HoodieCompactionPlan deserializeCompactionPlan(byte[] bytes)
throws IOException {
- return deserializeAvroMetadata(bytes, HoodieCompactionPlan.class);
+ public static HoodieCleanMetadata
deserializeHoodieCleanMetadata(Option<InputStream> inputStream) throws
IOException {
+ return deserializeAvroMetadata(inputStream, HoodieCleanMetadata.class);
}
public static HoodieCleanMetadata deserializeHoodieCleanMetadata(byte[]
bytes) throws IOException {
- return deserializeAvroMetadata(bytes, HoodieCleanMetadata.class);
+ return deserializeAvroMetadataLegacy(bytes, HoodieCleanMetadata.class);
Review Comment:
removed
--
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]