JeremyXin commented on code in PR #9869:
URL: https://github.com/apache/seatunnel/pull/9869#discussion_r2358904347
##########
seatunnel-connectors-v2/connector-redis/src/main/java/org/apache/seatunnel/connectors/seatunnel/redis/sink/RedisSinkWriter.java:
##########
@@ -101,28 +108,28 @@ private static String getNormalKey(SeaTunnelRow element,
List<String> fields, St
}
}
- private String getCustomKey(SeaTunnelRow element, List<String> fields,
String keyField) {
- String[] keyFieldSegments = keyField.split(REDIS_GROUP_DELIMITER);
- StringBuilder key = new StringBuilder();
- for (int i = 0; i < keyFieldSegments.length; i++) {
- String keyFieldSegment = keyFieldSegments[i];
- if (keyFieldSegment.startsWith(LEFT_PLACEHOLDER_MARKER)
- && keyFieldSegment.endsWith(RIGHT_PLACEHOLDER_MARKER)) {
- String realKeyField = keyFieldSegment.substring(1,
keyFieldSegment.length() - 1);
- if (fields.contains(realKeyField)) {
- Object realFieldValue =
element.getField(fields.indexOf(realKeyField));
- key.append(realFieldValue == null ? "" :
realFieldValue.toString());
- } else {
- key.append(keyFieldSegment);
- }
- } else {
- key.append(keyFieldSegment);
- }
- if (i != keyFieldSegments.length - 1) {
- key.append(REDIS_GROUP_DELIMITER);
- }
+ protected String getCustomKey(SeaTunnelRow element, List<String> fields,
String keyField) {
+ Matcher matcher = PLACEHOLDER_PATTERN.matcher(keyField);
+ StringBuffer result = new StringBuffer();
Review Comment:
done, also the placeholder representation in the original configuration
needs to be changed, from :{placeholder} to :${placeholder}
--
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]