use of org.apache.hudi.common.model.HoodieRecord in project rocketmq-externals by apache.
the class Updater method commit.
public void commit() {
List<SinkDataEntry> commitList;
if (inflightList.isEmpty()) {
return;
}
synchronized (this.inflightList) {
commitList = inflightList;
inflightList = new ArrayList<>();
}
List<HoodieRecord> hoodieRecordsList = new ArrayList<>();
for (SinkDataEntry record : commitList) {
GenericRecord genericRecord = sinkDataEntry2GenericRecord(record);
HoodieRecord<HoodieAvroPayload> hoodieRecord = new HoodieRecord(new HoodieKey(UUID.randomUUID().toString(), "shardingKey-" + record.getQueueName()), new HoodieAvroPayload(Option.of(genericRecord)));
hoodieRecordsList.add(hoodieRecord);
}
try {
List<WriteStatus> statuses = hudiWriteClient.upsert(hoodieRecordsList, hudiWriteClient.startCommit());
log.info("Upserted data to hudi");
long upserted = statuses.get(0).getStat().getNumInserts();
if (upserted != commitList.size()) {
log.warn("Upserted num not equals input");
}
} catch (Exception e) {
log.error("Exception when upserting to Hudi", e);
}
}
Aggregations