yihua commented on code in PR #13208:
URL: https://github.com/apache/hudi/pull/13208#discussion_r2059123041
##########
hudi-common/src/main/java/org/apache/hudi/common/engine/HoodieReaderContext.java:
##########
@@ -244,8 +258,22 @@ public boolean castToBoolean(Object value) {
* @return The record key in String.
*/
public String getRecordKey(T record, Schema schema) {
- Object val = getValue(record, schema, RECORD_KEY_METADATA_FIELD);
- return val.toString();
+ if (metaFieldsPopulated) {
+ Object val = getValue(record, schema, RECORD_KEY_METADATA_FIELD);
+ return val.toString();
+ }
+ return constructRecordKey(record, schema);
Review Comment:
nit: if we find that the `if` branch here cause performance issue, we could
predetermine the function of generating record key in the constructor of the
reader context and call `recordKeyFunc.apply(record, schema)` here.
```
recordKeyFunc
metaFieldsPopulated=true: (record, schema) -> getValue(record, schema,
RECORD_KEY_METADATA_FIELD).toString()
metaFieldsPopulated=false: (record, schema) -> constructRecordKey(record,
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]