[
https://issues.apache.org/jira/browse/DRILL-5723?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16160143#comment-16160143
]
ASF GitHub Bot commented on DRILL-5723:
---------------------------------------
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/923#discussion_r137937100
--- Diff:
exec/java-exec/src/main/java/org/apache/drill/exec/server/options/BaseOptionManager.java
---
@@ -17,44 +17,84 @@
*/
package org.apache.drill.exec.server.options;
-import
org.apache.drill.exec.server.options.TypeValidators.BooleanValidator;
-import org.apache.drill.exec.server.options.TypeValidators.DoubleValidator;
-import org.apache.drill.exec.server.options.TypeValidators.LongValidator;
-import org.apache.drill.exec.server.options.TypeValidators.StringValidator;
-
-public abstract class BaseOptionManager implements OptionSet {
-// private static final org.slf4j.Logger logger =
org.slf4j.LoggerFactory.getLogger(BaseOptionManager.class);
-
- /**
- * Gets the current option value given a validator.
- *
- * @param validator the validator
- * @return option value
- * @throws IllegalArgumentException - if the validator is not found
- */
- private OptionValue getOptionSafe(OptionValidator validator) {
- OptionValue value = getOption(validator.getOptionName());
- return value == null ? validator.getDefault() : value;
+import org.apache.drill.common.exceptions.UserException;
+
+import java.util.Iterator;
+
+/**
+ * This {@link OptionManager} implements some the basic methods and should
be extended by concrete implementations.
+ */
+public abstract class BaseOptionManager extends BaseOptionSet implements
OptionManager {
+ private static final org.slf4j.Logger logger =
org.slf4j.LoggerFactory.getLogger(BaseOptionManager.class);
+
+ @Override
+ public OptionList getInternalOptionList() {
+ return getAllOptionList(true);
}
@Override
- public boolean getOption(BooleanValidator validator) {
- return getOptionSafe(validator).bool_val;
+ public OptionList getPublicOptionList() {
+ return getAllOptionList(false);
}
@Override
- public double getOption(DoubleValidator validator) {
- return getOptionSafe(validator).float_val;
+ public void setLocalOption(String name, boolean value) {
+ setLocalOption(OptionValue.Kind.BOOLEAN, name,
Boolean.toString(value));
--- End diff --
Very nice improvement to the API! I wonder, however, if we should pass the
value as an `Object` rather than as a `String`? Seems more natural to do it
that way. Or, maybe here just create the option value since we know the type?
```
setLocalOption(String name, OptionValue.fromBoolean(value));
```
This means that the other fields would be filled in later, so they couldn't
be final.
Hence, the alternative, use an `Object`
```
setLocalOption(String name, value);
...
private void setLocalOption(String name, Object value) {
```
Then, when creating an option, validate that the type of the `Object`
matches the type of the option. (In fact, the `Object` for would be handy for
testing...)
> Support System/Session Internal Options And Additional Option System Fixes
> --------------------------------------------------------------------------
>
> Key: DRILL-5723
> URL: https://issues.apache.org/jira/browse/DRILL-5723
> Project: Apache Drill
> Issue Type: New Feature
> Reporter: Timothy Farkas
> Assignee: Timothy Farkas
>
> This is a feature proposed by [~ben-zvi].
> Currently all the options are accessible by the user in sys.options. We would
> like to add internal options which can be altered, but are not visible in the
> sys.options table. These internal options could be seen by another alias
> select * from internal.options. The intention would be to put new options we
> weren't comfortable with exposing to the end user in this table.
> After the options and their corresponding features are considered stable they
> could be changed to appear in the sys.option table.
> A bunch of other fixes to the Option system have been clubbed into this:
> * OptionValidators no longer hold default values. Default values are
> contained in the SystemOptionManager
> * Options have an OptionDefinition. The option definition includes:
> * A validator
> * Metadata about the options visibility, required permissions, and the
> scope in which it can be set.
> * The Option Manager interface has been cleaned up so that a Type is not
> required to be passed in in order to set and delete options
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)