hudi-agent commented on code in PR #18987:
URL: https://github.com/apache/hudi/pull/18987#discussion_r3463405679


##########
hudi-common/src/main/java/org/apache/hudi/common/model/DeleteRecord.java:
##########
@@ -87,4 +104,34 @@ public String getRecordKey() {
   public String getPartitionPath() {
     return hoodieKey.getPartitionPath();
   }
+
+  public static byte[] encodeOrderingValue(Comparable<?> orderingValue) {
+    try {
+      DatumWriter<HoodieOrderingValue> writer = new 
SpecificDatumWriter<>(HoodieOrderingValue.class);
+      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+      BinaryEncoder encoder = EncoderFactory.get().binaryEncoder(baos, null);
+      writer.write(HoodieOrderingValue.newBuilder()
+          
.setOrderingVal(HoodieAvroWrapperUtils.wrapValueIntoAvro(orderingValue))
+          .build(), encoder);
+      encoder.flush();
+      return baos.toByteArray();
+    } catch (IOException e) {
+      throw new HoodieIOException("Failed to encode delete record ordering 
value", e);
+    }
+  }
+
+  public static Comparable<?> decodeOrderingValue(byte[] orderingValueBytes) {
+    if (orderingValueBytes == null) {
+      return OrderingValues.getDefault();
+    }
+    try {
+      DatumReader<GenericRecord> reader = new 
GenericDatumReader<>(HoodieOrderingValue.SCHEMA$);

Review Comment:
   🤖 Since `createNativeDeleteRecord` calls this for every record in a native 
delete log, each call allocates a fresh `GenericDatumReader` and a non-reused 
`BinaryDecoder`, and `convertToSpecificRecord` builds a new `SpecificData` 
internally. On delete-heavy logs that per-record overhead adds up — would it be 
worth reusing a static `SpecificDatumReader<HoodieOrderingValue>` plus a 
reusable decoder via `DecoderFactory.binaryDecoder(bytes, off, len, reused)`? 
That also lets you drop the `convertToSpecificRecord` step entirely.
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



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