Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature][Connector-V2] Support TableSourceFactory/TableSinkFactory on redis #5901

Merged
merged 9 commits into from
Nov 24, 2023

Conversation

jackyyyyyssss
Copy link
Contributor

@jackyyyyyssss jackyyyyyssss commented Nov 22, 2023

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

}

@Override
public void prepare(Config pluginConfig) throws PrepareFailException {
public RedisSource(Config pluginConfig) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Comment on lines 62 to 64
if (config.getOptional(RedisConfig.DB_NUM).isPresent()) {
this.dbNum = config.get(RedisConfig.DB_NUM);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (config.getOptional(RedisConfig.DB_NUM).isPresent()) {
this.dbNum = config.get(RedisConfig.DB_NUM);
}
this.dbNum = config.get(RedisConfig.DB_NUM);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review. I have made the necessary modifications PTAL @Hisoka-X

Comment on lines 60 to 72
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();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part also should be changed like #5901 (comment).
Because it default value already be defined in OptionRule.

Comment on lines 74 to 93
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);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks i know

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done PTAL

Copy link
Member

@Hisoka-X Hisoka-X left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @jackyyyyyssss

@hailin0 hailin0 merged commit e84dcb8 into apache:dev Nov 24, 2023
5 checks passed
alextinng pushed a commit to alextinng/seatunnel that referenced this pull request Dec 19, 2023
@jackyyyyyssss jackyyyyyssss deleted the redis-new branch July 23, 2024 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants