tandonraghavs commented on issue #2131:
URL: https://github.com/apache/hudi/issues/2131#issuecomment-703137335
@bvaradar Thanks for the PR.
I tried the way you suggested and it is working as desired.
Let me know if you see any issue in below code.
````
public class MergeHudiPayload implements
HoodieRecordPayload<MergeHudiPayload> {
private byte[] recordBytes;
private Schema schema;
private Comparable orderingVal;
public MergeHudiPayload(GenericRecord genericRecord, Comparable
orderingVal) {
try {
if (genericRecord!=null) {
this.recordBytes =
HoodieAvroUtils.avroToBytes(genericRecord);
this.schema=genericRecord.getSchema();
this.orderingVal=orderingVal;
} else {
this.recordBytes = new byte[0];
}
} catch (IOException io) {
throw new HoodieIOException("Cannot convert record to bytes",
io);
}
}
//Constructor called during Compaction
public MergeHudiPayload(Option<GenericRecord> record) {
this(record.isPresent() ? record.get() : null, (record1) -> 0); //
natural order
}
}
````
Then I use it like this in **preCombine**
````
GenericRecord
currentRecord=HoodieAvroUtils.bytesToAvro(currentObj.recordBytes,currentObj.schema);
GenericRecord
anotherRecord=HoodieAvroUtils.bytesToAvro(anotherObj.recordBytes,anotherObj.schema);
````
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]