[Feature][Connector-V2] Support TableSourceFactory/TableSinkFactory on redis #5901
[Feature][Connector-V2] Support TableSourceFactory/TableSinkFactory on redis #5901hailin0 merged 9 commits intoapache:devfrom
Conversation
|
|
||
| @Override | ||
| public void prepare(Config pluginConfig) throws PrepareFailException { | ||
| public RedisSource(Config pluginConfig) { |
There was a problem hiding this comment.
Please use ReadOnlyConfig, do not convert ReadOnlyConfig to Config. This is a bad example, we want connectors to be able to use ReadOnlyConfig instead of Config
| this.hashKeyParseMode = | ||
| RedisConfig.HashKeyParseMode.valueOf( | ||
| config.getString(RedisConfig.HASH_KEY_PARSE_MODE.key()).toUpperCase()); | ||
| config.get(RedisConfig.HASH_KEY_PARSE_MODE).name().toUpperCase()); |
There was a problem hiding this comment.
After config.get(RedisConfig.HASH_KEY_PARSE_MODE). The value already are enum of HashKeyParseMode. So we don't need use valueOf to parse it again.
| this.mode = | ||
| RedisConfig.RedisMode.valueOf( | ||
| config.getString(RedisConfig.MODE.key()).toUpperCase()); | ||
| config.get(RedisConfig.MODE).name().toUpperCase()); |
| if (config.getOptional(RedisConfig.DB_NUM).isPresent()) { | ||
| this.dbNum = config.get(RedisConfig.DB_NUM); | ||
| } |
There was a problem hiding this comment.
| if (config.getOptional(RedisConfig.DB_NUM).isPresent()) { | |
| this.dbNum = config.get(RedisConfig.DB_NUM); | |
| } | |
| this.dbNum = config.get(RedisConfig.DB_NUM); |
There was a problem hiding this comment.
Thank you for your review. I have made the necessary modifications PTAL @Hisoka-X
| if (config.getOptional(RedisConfig.AUTH).isPresent()) { | ||
| this.auth = config.get(RedisConfig.AUTH); | ||
| } | ||
| // set user | ||
| if (config.hasPath(RedisConfig.USER.key())) { | ||
| this.user = config.getString(RedisConfig.USER.key()); | ||
| if (config.getOptional(RedisConfig.USER).isPresent()) { | ||
| this.user = config.get(RedisConfig.USER); | ||
| } | ||
| // set mode | ||
| if (config.hasPath(RedisConfig.MODE.key())) { | ||
| this.mode = | ||
| RedisConfig.RedisMode.valueOf( | ||
| config.getString(RedisConfig.MODE.key()).toUpperCase()); | ||
| if (config.getOptional(RedisConfig.MODE).isPresent()) { | ||
| this.mode = config.get(RedisConfig.MODE); | ||
| } else { | ||
| this.mode = RedisConfig.MODE.defaultValue(); | ||
| } |
There was a problem hiding this comment.
This part also should be changed like #5901 (comment).
Because it default value already be defined in OptionRule.
| if (config.getOptional(RedisConfig.HASH_KEY_PARSE_MODE).isPresent()) { | ||
| this.hashKeyParseMode = config.get(RedisConfig.HASH_KEY_PARSE_MODE); | ||
| } else { | ||
| this.hashKeyParseMode = RedisConfig.HASH_KEY_PARSE_MODE.defaultValue(); | ||
| } | ||
| // set redis nodes information | ||
| if (config.hasPath(RedisConfig.NODES.key())) { | ||
| this.redisNodes = config.getStringList(RedisConfig.NODES.key()); | ||
| if (config.getOptional(RedisConfig.NODES).isPresent()) { | ||
| this.redisNodes = config.get(RedisConfig.NODES); | ||
| } | ||
| // set key | ||
| if (config.hasPath(RedisConfig.KEY.key())) { | ||
| this.keyField = config.getString(RedisConfig.KEY.key()); | ||
| if (config.getOptional(RedisConfig.KEY).isPresent()) { | ||
| this.keyField = config.get(RedisConfig.KEY); | ||
| } | ||
| // set keysPattern | ||
| if (config.hasPath(RedisConfig.KEY_PATTERN.key())) { | ||
| this.keysPattern = config.getString(RedisConfig.KEY_PATTERN.key()); | ||
| if (config.getOptional(RedisConfig.KEY_PATTERN).isPresent()) { | ||
| this.keysPattern = config.get(RedisConfig.KEY_PATTERN); | ||
| } | ||
| if (config.hasPath(RedisConfig.EXPIRE.key())) { | ||
| this.expire = config.getLong(RedisConfig.EXPIRE.key()); | ||
| if (config.getOptional(RedisConfig.EXPIRE).isPresent()) { | ||
| this.expire = config.get(RedisConfig.EXPIRE); | ||
| } |
There was a problem hiding this comment.
thanks i know
Purpose of this pull request
[Feature][Connector-V2] Support TableSourceFactory/TableSinkFactory on redis #5651 #5897
Does this PR introduce any user-facing change?
How was this patch tested?
current e2e test
Check list
New License Guide
release-note.