beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luke Cwik (JIRA)" <>
Subject [jira] [Created] (BEAM-2261) Add the ability to override values set with @Default.YYY on PipelineOptions
Date Thu, 11 May 2017 16:31:04 GMT
Luke Cwik created BEAM-2261:

             Summary: Add the ability to override values set with @Default.YYY on PipelineOptions
                 Key: BEAM-2261
             Project: Beam
          Issue Type: Improvement
          Components: sdk-java-core
            Reporter: Luke Cwik
            Priority: Minor

Users may want to set a value only if the value isn't the default.

When a user calls *PipelineOptionsFactory.fromArgs(args).as(Options.class)* they cannot tell
if a user set the value from the command-line or whether the value is a default that was generated
through the usage of the *@Default.YYY* annotations.

There is currently no method to introspect whether a default is set and we could:
* add a *isOptionSet()* method, but this adds many methods to the interfaces
* ask whether something is the default or set by name or by method reference, *options.isSet("options"
/ method)*, but is brittle to any name changes in options.
* allowing users to override with another interface defining a new *@Default.YYY* is difficult
** multiple inheritance makes choosing a default difficult:
MyPipelineOptions extends OptionsA, OptionsB { }
OptionsA {
  String getString();
OptionsB {
  String getString();
** even if the was little ambiguity initially with MyPipelineOptions defined as:
MyPipelineOptions extends OptionsA, OptionsB {
  String getString();
 defaults are resolved lazily on first access and it would be strange if the default resolved
depending on the order of "as" calls.
would all provide different answers.

Finally that leaves us with an option to add support for merging PipelineOptions (as long
as they are compatible).
PipelineOptions PipelineOptionsFactory.merge(PipelineOptions ... options)
where all subsequent options overwrite any prior set options and the empty array returning
the default *PipelineOptionsFactory.create()*

This message was sent by Atlassian JIRA

View raw message