This is an automated email from the ASF dual-hosted git repository. melap pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push: new 5e161bb Merge pull request #8670: [BEAM-7408] Make custom options example consistent across languages 5e161bb is described below commit 5e161bbe79bb36aa41a11374037cb807bcfa2700 Author: David Yan <david...@apache.org> AuthorDate: Fri May 24 09:53:03 2019 -0700 Merge pull request #8670: [BEAM-7408] Make custom options example consistent across languages --- website/src/documentation/programming-guide.md | 37 ++++++++++++++++---------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/website/src/documentation/programming-guide.md b/website/src/documentation/programming-guide.md index 49c7d11..6887130 100644 --- a/website/src/documentation/programming-guide.md +++ b/website/src/documentation/programming-guide.md @@ -188,13 +188,17 @@ a command-line argument. You can add your own custom options in addition to the standard `PipelineOptions`. To add your own options, define an interface with getter and -setter methods for each option, as in the following example: +setter methods for each option, as in the following example for +adding `input` and `output` custom options: ```java public interface MyOptions extends PipelineOptions { - String getMyCustomOption(); - void setMyCustomOption(String myCustomOption); - } + String getInput(); + void setInput(String input); + + String getOutput(); + void setOutput(String output); +} ``` ```py {% github_sample /apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/snippets.py tag:pipeline_options_define_custom @@ -214,11 +218,16 @@ You set the description and default value using annotations, as follows: ```java public interface MyOptions extends PipelineOptions { - @Description("My custom command line argument.") - @Default.String("DEFAULT") - String getMyCustomOption(); - void setMyCustomOption(String myCustomOption); - } + @Description("Input for the pipeline") + @Default.String("gs://my-bucket/input") + String getInput(); + void setInput(String input); + + @Description("Output for the pipeline") + @Default.String("gs://my-bucket/input") + String getOutput(); + void setOutput(String output); +} ``` ```py {% github_sample /apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/snippets.py tag:pipeline_options_define_custom_with_help_and_default @@ -226,8 +235,8 @@ public interface MyOptions extends PipelineOptions { ``` ```go var ( - input = flag.String("input", "gs://my-bucket/input", "File(s) to read.") - output = flag.String("output", "gs://my-bucket/output", "Output file.") + input = flag.String("input", "gs://my-bucket/input", "Input for the pipeline") + output = flag.String("output", "gs://my-bucket/output", "Output for the pipeline") ) ``` @@ -251,7 +260,7 @@ MyOptions options = PipelineOptionsFactory.fromArgs(args) .as(MyOptions.class); ``` -Now your pipeline can accept `--myCustomOption=value` as a command-line argument. +Now your pipeline can accept `--input=value` and `--output=value` as command-line arguments. ## 3. PCollections {#pcollections} @@ -302,7 +311,7 @@ public static void main(String[] args) { // Create the PCollection 'lines' by applying a 'Read' transform. PCollection<String> lines = p.apply( - "ReadMyFile", TextIO.read().from("protocol://path/to/some/inputData.txt")); + "ReadMyFile", TextIO.read().from("gs://some/inputData.txt")); } ``` ```py @@ -310,7 +319,7 @@ public static void main(String[] args) { %} ``` ```go -lines := textio.Read(s, "protocol://path/to/some/inputData.txt") +lines := textio.Read(s, "gs://some/inputData.txt") ``` See the [section on I/O](#pipeline-io) to learn more about how to read from the