You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2023/01/17 15:55:12 UTC

[GitHub] [inlong] featzhang commented on a diff in pull request #7228: [INLONG-7060][Sort] Support write redis in sort-connector-redis

featzhang commented on code in PR #7228:
URL: https://github.com/apache/inlong/pull/7228#discussion_r1072388172


##########
inlong-sort/sort-connectors/redis/src/main/java/org/apache/inlong/sort/redis/table/RedisDynamicTableFactory.java:
##########
@@ -107,6 +149,44 @@ public Set<ConfigOption<?>> requiredOptions() {
         return requiredOptions;
     }
 
+    private void validateConfigOptions(ReadableConfig config, Set<String> supportCommands) {
+        String redisMode = config.get(RedisOptions.REDIS_MODE);
+        List<String> matchRedisMode = SUPPORT_REDIS_MODE.stream().filter(e -> e.equals(redisMode.toLowerCase().trim()))
+                .collect(Collectors.toList());
+        checkState(!matchRedisMode.isEmpty(),
+                "Unsupported redis-mode " + redisMode + ". The supported redis-mode " + Arrays
+                        .deepToString(SUPPORT_REDIS_MODE.toArray()));
+        String command = config.get(RedisOptions.COMMAND);
+        Preconditions.checkState(!StringUtils.isNullOrWhitespaceOnly(command),
+                "Command can not be empty. The supported command are " + Arrays
+                        .deepToString(supportCommands.toArray()));
+        List<String> matchCommand = supportCommands
+                .stream().filter(e -> e.equals(command.toUpperCase().trim())).collect(Collectors.toList());
+        checkState(!matchCommand.isEmpty(), "Unsupported command " + command + ". The supported command " + Arrays
+                .deepToString(supportCommands.toArray()));
+    }
+
+    private void validateDataTypeAndSchemaMappingMode(
+            RedisDataType dataType,
+            SchemaMappingMode mappingMode) {
+        switch (dataType) {
+            case HASH:
+                break;
+            case PLAIN:
+                org.apache.flink.shaded.guava18.com.google.common.base.Preconditions.checkState(
+                        mappingMode == STATIC_PREFIX_MATCH,
+                        "Only support STATIC_PREFIX_MATCH mode in PLAIN dataType !");
+                break;
+            case BITMAP:
+                org.apache.flink.shaded.guava18.com.google.common.base.Preconditions.checkState(
+                        mappingMode == STATIC_KV_PAIR,
+                        "Only support STATIC_KV_PAIR mode in BITMAP dataType !");
+                break;
+            default:
+                throw new UnsupportedOperationException("The dataType '" + dataType + "' is not supported.");
+        }
+    }
+
     @Override
     public Set<ConfigOption<?>> optionalOptions() {
         final Set<ConfigOption<?>> options = new HashSet<>();

Review Comment:
   This PR is too big, there are 2k+ lines, I will start another PR to support it



-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org