-
Notifications
You must be signed in to change notification settings - Fork 597
[#1221] improvement(common): Add the method checkValue
for the ConfigEntry
#1233
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
Conversation
Probably be better to add the |
OK, I will try to add more checks. |
4d3182c
to
11ea369
Compare
Added. |
StringUtils.isNotBlank(icebergConfig.get(IcebergConfig.CATALOG_URI)), | ||
"Catalog uri can't be blank"); | ||
// The method `get` will call the method `checkValue`, just check the values of the config | ||
// options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not proper to add the comment here. It explains the behavior of config::get
, unrelated to iceberg here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I will remove 'The method get
will call the method checkValue
'. But it's also confusing if we only call the method get
, but we don't use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got your point. I will change the comment
The method `get` will check the values of config options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
package com.datastrato.gravitino.config; | ||
|
||
public interface ConfigConstants { | ||
String NOT_BLANK_ERROR_MSG = "The value can't be the blank"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The value can't be blank"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
if (validator == null) { | ||
return; | ||
} | ||
optionValue.ifPresent(value -> validator.accept(value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please optimize the logic here? It is a bit confusing to have both null and optional check here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if optionValue is empty, we will skip the check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add some comments here.
// If optionValue is empty, the config entry will skip the check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can change like this:
Stream.of(Optional.ofNullable(validator), optionValue).allMatch(Optional::isPresent) {
validator.accept(value)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
package com.datastrato.gravitino.config; | ||
|
||
public interface ConfigConstants { | ||
String NOT_BLANK_ERROR_MSG = "The value can't be blank"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using 'Missing config' can more clearly indicate the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you configure " ", the validator will report error, too.
@@ -42,8 +42,7 @@ public class IcebergTableOps implements AutoCloseable { | |||
public IcebergTableOps(IcebergConfig icebergConfig) { | |||
String catalogType = icebergConfig.get(IcebergConfig.CATALOG_BACKEND); | |||
if (!IcebergCatalogBackend.MEMORY.name().equalsIgnoreCase(catalogType)) { | |||
// The method `get` will call the method `checkValue`, just check the values of the config | |||
// options | |||
// The method `get` will check the values of config options. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to add the comments here, it's not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
@@ -45,8 +45,7 @@ private static JdbcCatalog loadJdbcCatalog(Map<String, String> properties) { | |||
IcebergConfig icebergConfig = new IcebergConfig(properties); | |||
String driverClassName = icebergConfig.getJdbcDriver(); | |||
|
|||
// The method `get` will call the method `checkValue`, just check the values of the config | |||
// options | |||
// The method `get` will check the values of config options. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neither here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
What changes were proposed in this pull request?
Now, ConfigEntry lacks the ability of check config options. So we add the support of this feature referring to Spark.
Why are the changes needed?
Fix: #1221
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Add new ut.