yihua commented on code in PR #13208:
URL: https://github.com/apache/hudi/pull/13208#discussion_r2059344714


##########
hudi-common/src/main/java/org/apache/hudi/keygen/KeyGenerator.java:
##########
@@ -56,4 +62,42 @@ public List<String> getRecordKeyFieldNames() {
     throw new UnsupportedOperationException("Bootstrap not supported for key 
generator. "
         + "Please override this method in your custom key generator.");
   }
+
+  /**
+   * Constructs the record key from the given record key fields and the 
function to get the value of each field.
+   * @param recordKeyFields the record key field names
+   * @param recordValueFunction takes the record key field name and the index 
of the field in the record key fields and outputs a value
+   * @return the record key
+   */
+  public static String constructRecordKey(String[] recordKeyFields, 
BiFunction<String, Integer, String> recordValueFunction) {
+    if (recordKeyFields.length == 1) {
+      Object recordKeyValue = recordValueFunction.apply(recordKeyFields[0], 0);

Review Comment:
   This can be `String` typed now.



##########
hudi-common/src/main/java/org/apache/hudi/keygen/KeyGenerator.java:
##########
@@ -56,4 +62,42 @@ public List<String> getRecordKeyFieldNames() {
     throw new UnsupportedOperationException("Bootstrap not supported for key 
generator. "
         + "Please override this method in your custom key generator.");
   }
+
+  /**
+   * Constructs the record key from the given record key fields and the 
function to get the value of each field.
+   * @param recordKeyFields the record key field names
+   * @param recordValueFunction takes the record key field name and the index 
of the field in the record key fields and outputs a value
+   * @return the record key
+   */
+  public static String constructRecordKey(String[] recordKeyFields, 
BiFunction<String, Integer, String> recordValueFunction) {
+    if (recordKeyFields.length == 1) {
+      Object recordKeyValue = recordValueFunction.apply(recordKeyFields[0], 0);
+      if (recordKeyValue == null) {
+        throw new HoodieKeyException("recordKey cannot be null");
+      }
+      return recordKeyValue.toString();

Review Comment:
   Similar here



-- 
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]

Reply via email to