[ 
https://issues.apache.org/jira/browse/FLINK-2021?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15141306#comment-15141306
 ] 

ASF GitHub Bot commented on FLINK-2021:
---------------------------------------

Github user fhueske commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1581#discussion_r52496326
  
    --- Diff: 
flink-examples/flink-examples-batch/src/main/java/org/apache/flink/examples/java/clustering/KMeans.java
 ---
    @@ -105,119 +110,127 @@ public static void main(String[] args) throws 
Exception {
                        .groupBy(0).reduce(new CentroidAccumulator())
                        // compute new centroids from point counts and 
coordinate sums
                        .map(new CentroidAverager());
    -           
    +
                // feed new centroids back into next iteration
                DataSet<Centroid> finalCentroids = loop.closeWith(newCentroids);
    -           
    +
                DataSet<Tuple2<Integer, Point>> clusteredPoints = points
    -                           // assign points to final clusters
    -                           .map(new 
SelectNearestCenter()).withBroadcastSet(finalCentroids, "centroids");
    -           
    +                   // assign points to final clusters
    +                   .map(new 
SelectNearestCenter()).withBroadcastSet(finalCentroids, "centroids");
    +
                // emit result
    -           if (fileOutput) {
    -                   clusteredPoints.writeAsCsv(outputPath, "\n", " ");
    +           if (params.has("output")) {
    +                   clusteredPoints.writeAsCsv(params.get("output"), "\n", 
" ");
     
                        // since file sinks are lazy, we trigger the execution 
explicitly
                        env.execute("KMeans Example");
    -           }
    -           else {
    +           } else {
                        clusteredPoints.print();
    --- End diff --
    
    Add a message saying something like "Printing result to std-out. Use 
--output to specify output path."


> Rework examples to use ParameterTool
> ------------------------------------
>
>                 Key: FLINK-2021
>                 URL: https://issues.apache.org/jira/browse/FLINK-2021
>             Project: Flink
>          Issue Type: Improvement
>          Components: Examples
>    Affects Versions: 0.9
>            Reporter: Robert Metzger
>            Assignee: Stefano Baghino
>            Priority: Minor
>              Labels: starter
>
> In FLINK-1525, we introduced the {{ParameterTool}}.
> We should port the examples to use the tool.
> The examples could look like this (we should maybe discuss it first on the 
> mailing lists):
> {code}
> public static void main(String[] args) throws Exception {
>     ParameterTool pt = ParameterTool.fromArgs(args);
>     boolean fileOutput = pt.getNumberOfParameters() == 2;
>     String textPath = null;
>     String outputPath = null;
>     if(fileOutput) {
>         textPath = pt.getRequired("input");
>         outputPath = pt.getRequired("output");
>     }
>     // set up the execution environment
>     final ExecutionEnvironment env = 
> ExecutionEnvironment.getExecutionEnvironment();
>     env.getConfig().setUserConfig(pt);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to