Sugamber commented on issue #2637: URL: https://github.com/apache/hudi/issues/2637#issuecomment-804639531
public class PartialColumnUpdate implements HoodieRecordPayload<PartialColumnUpdate> { private static final Logger logger = Logger.getLogger(PartialColumnUpdate.class); private byte[] recordBytes; private Schema schema; private Comparable orderingVal; public PartialColumnUpdate(GenericRecord genericRecord, Comparable orderingVal) { logger.info("Inside two parameter cons"); try { if (genericRecord != null) { this.recordBytes = HoodieAvroUtils.avroToBytes(genericRecord); this.schema = genericRecord.getSchema(); this.orderingVal = orderingVal; } else { this.recordBytes = new byte[0]; } } catch (Exception io) { throw new RuntimeException("Cannot convert record to bytes ", io); } } public PartialColumnUpdate(Option<GenericRecord> record) { this(record.isPresent() ? record.get() : null, 0); } @Override public PartialColumnUpdate preCombine(PartialColumnUpdate anotherRecord) { logger.info("Inside PreCombine"); logger.info("preCombine => " + anotherRecord); logger.info("another_ordering value" + anotherRecord.orderingVal); logger.info("another_ schema value" + anotherRecord.schema); logger.info("another_ record bytes value" + anotherRecord.recordBytes); if (anotherRecord.orderingVal.compareTo(orderingVal) > 0) { return anotherRecord; } else { return this; } } @Override public Option<IndexedRecord> combineAndGetUpdateValue(IndexedRecord indexedRecord, Schema currentSchema) throws IOException { logger.info("Inside combineAndGetUpdateValue"); logger.info("current schema" + currentSchema); logger.info("combineUpdate - >" + Option.of(indexedRecord)); getInsertValue(currentSchema); return Option.empty(); } @Override public Option<IndexedRecord> getInsertValue(Schema schema) throws IOException { logger.info("Inside getInsertValue"); if (recordBytes.length == 0) { return Option.empty(); } IndexedRecord indexedRecord = HoodieAvroUtils.bytesToAvro(recordBytes, schema); if (isDeleteRecord((GenericRecord) indexedRecord)) { return Option.empty(); } else { return Option.of(indexedRecord); } } protected boolean isDeleteRecord(GenericRecord genericRecord) { final String isDeleteKey = "_hoodie_is_deleted"; if (genericRecord.getSchema().getField(isDeleteKey) == null) { return false; } Object deleteMarker = genericRecord.get(isDeleteKey); return (deleteMarker instanceof Boolean && (boolean) deleteMarker); } } -- 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: us...@infra.apache.org