cshuo commented on code in PR #13686:
URL: https://github.com/apache/hudi/pull/13686#discussion_r2264589118
##########
hudi-common/src/main/java/org/apache/hudi/common/model/HoodieAvroIndexedRecord.java:
##########
@@ -122,43 +152,54 @@ public Object[] getColumnValues(Schema recordSchema,
String[] columns, boolean c
@Override
public Object getColumnValueAsJava(Schema recordSchema, String column,
Properties props) {
+ setSchema(recordSchema);
return AvroRecordContext.getFieldValueFromIndexedRecord(data, column);
}
@Override
public HoodieRecord joinWith(HoodieRecord other, Schema targetSchema) {
+ setSchema(targetSchema);
GenericRecord record = HoodieAvroUtils.stitchRecords((GenericRecord) data,
(GenericRecord) other.getData(), targetSchema);
return new HoodieAvroIndexedRecord(key, record, operation, metaData);
}
@Override
public HoodieRecord prependMetaFields(Schema recordSchema, Schema
targetSchema, MetadataValues metadataValues, Properties props) {
+ setSchema(recordSchema);
GenericRecord newAvroRecord =
HoodieAvroUtils.rewriteRecordWithNewSchema(data, targetSchema);
updateMetadataValuesInternal(newAvroRecord, metadataValues);
return new HoodieAvroIndexedRecord(key, newAvroRecord, operation,
metaData);
}
@Override
public HoodieRecord updateMetaField(Schema recordSchema, int ordinal, String
value) {
+ setSchema(recordSchema);
data.put(ordinal, value);
return new HoodieAvroIndexedRecord(key, data, operation, metaData);
}
@Override
public HoodieRecord rewriteRecordWithNewSchema(Schema recordSchema,
Properties props, Schema newSchema, Map<String, String> renameCols) {
+ setSchema(recordSchema);
GenericRecord record = HoodieAvroUtils.rewriteRecordWithNewSchema(data,
newSchema, renameCols);
return new HoodieAvroIndexedRecord(key, record, operation, metaData);
}
@Override
public HoodieRecord truncateRecordKey(Schema recordSchema, Properties props,
String keyFieldName) {
+ setSchema(recordSchema);
((GenericRecord) data).put(keyFieldName, StringUtils.EMPTY_STRING);
return this;
}
@Override
public boolean isDelete(Schema recordSchema, Properties props) {
- return false;
+ if (getData().equals(SENTINEL)) {
+ return false; // Sentinel record is not a delete
+ }
+ setSchema(recordSchema);
+ DeleteContext deleteContext = new DeleteContext(props, recordSchema);
Review Comment:
```
public DeleteContext(Properties props, Schema tableSchema) {
this.customDeleteMarkerKeyValue = getCustomDeleteMarkerKevValue(props);
this.hasBuiltInDeleteField = hasBuiltInDeleteField(tableSchema);
this.hoodieOperationPos = getHoodieOperationPos(tableSchema);
}
```
Seems it's not just a wrapper pojo, 3 fields in DeleteContext will be
calculated for every record, and they are same for different records because
their `recordSchema` are same.
Since the performance has met expectations, I'm okay with putting the
caching on hold to keep things less complex.
--
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]