You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Chesnay Schepler (JIRA)" <ji...@apache.org> on 2017/05/13 11:32:04 UTC

[jira] [Updated] (FLINK-6577) Expand supported types for ConfigOptions

     [ https://issues.apache.org/jira/browse/FLINK-6577?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chesnay Schepler updated FLINK-6577:
------------------------------------
    Priority: Trivial  (was: Major)

> Expand supported types for ConfigOptions
> ----------------------------------------
>
>                 Key: FLINK-6577
>                 URL: https://issues.apache.org/jira/browse/FLINK-6577
>             Project: Flink
>          Issue Type: Wish
>          Components: Configuration
>            Reporter: Chesnay Schepler
>            Priority: Trivial
>
> The type of a {{ConfigOption}} is currently limited to the types the that {{Configuration}} supports, which boils down to basic types and byte arrays.
> It would be useful if they could also return things like enums, or the recently added {{MemorySize}}.
> I propose adding a {{fromConfiguration(Configuration}} method to the {{ConfigOption}} class.
> {code}
> // ConfigOption definition
> ConfigOption<MemorySize> MEMORY =
>     key("memory")
>         .defaultValue(new MemorySize(12345))
>         .from(new ExtractorFunction<MemorySize>() {
>             MemorySize extract(Configuration config) {
>                 // add check for unconfigured option
>                 return MemorySize.parse(config.getString("memory");}
>         });
> // usage
> MemorySize memory = MEMORY.fromConfiguration(config);
> // with default
> MemorySize memory = MEMORY.fromConfiguration(config, new MemorySize(12345);
> // internals of ConfigOption#fromConfiguration
> <T> fromConfiguration(Configuration config) {
>     if (this.extractor == null) { // throw error or something }
>     T value = this.extractor.extract(config);
>     return value == null ? defaultValue : value;
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)