flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-827) Add Java example program with KeySelectors
Date Wed, 25 Jun 2014 17:42:29 GMT

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

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

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

    https://github.com/apache/incubator-flink/pull/45#discussion_r14200697
  
    --- Diff: stratosphere-examples/stratosphere-java-examples/src/main/java/eu/stratosphere/example/java/wordcount/WordCountPLOJO.java
---
    @@ -0,0 +1,183 @@
    +/***********************************************************************************************************************
    + *
    + * Copyright (C) 2010-2013 by the Stratosphere project (http://stratosphere.eu)
    + *
    + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
file except in compliance with
    + * the License. You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on
    + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied. See the License for the
    + * specific language governing permissions and limitations under the License.
    + *
    + **********************************************************************************************************************/
    +package eu.stratosphere.example.java.wordcount;
    +
    +import eu.stratosphere.api.java.DataSet;
    +import eu.stratosphere.api.java.ExecutionEnvironment;
    +import eu.stratosphere.api.java.functions.FlatMapFunction;
    +import eu.stratosphere.api.java.functions.KeySelector;
    +import eu.stratosphere.api.java.functions.ReduceFunction;
    +import eu.stratosphere.util.Collector;
    +
    +
    +
    +/**
    + * Implements a "WordCount" program that computes a simple word occurrence histogram
    + * over hard coded examples or text files. This example demonstrates how to use KeySelectors,
ReduceFunction and FlatMapFunction.
    + */
    +@SuppressWarnings("serial")
    +public class WordCountPLOJO {
    +	
    +	/**
    +	 * Runs the WordCount program.
    +	 * 
    +	 * @param args Input and output file.
    +	 */
    +	public static void main(String[] args) throws Exception {
    +		// Check whether arguments are given and tell user how to use this example with files.
    +		if (args.length < 2) {
    +			System.out.println("You can specify: WordCountPLOJO <input path> <result
path>, in order to work with files.");
    +		}
    +		
    +		// Input and output path [optional]
    +		String inputPath = null;
    +		String outputPath = null;
    +		
    +		// Get the environment as starting point
    +		final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    +		
    +		// Read the text file from given input path or hard coded
    +		DataSet<String> text = null;
    +		try {
    +			inputPath = args[0];
    +			env.readTextFile(inputPath);
    +		}
    +		catch(Exception e) {
    --- End diff --
    
    In general, exceptions should be used for error handling, not for application logic (in
my understanding).
    Have a look at the WordCount example: https://github.com/apache/incubator-flink/blob/master/stratosphere-examples/stratosphere-java-examples/src/main/java/eu/stratosphere/example/java/wordcount/WordCount.java
    it solves this issue differently.


> Add Java example program with KeySelectors
> ------------------------------------------
>
>                 Key: FLINK-827
>                 URL: https://issues.apache.org/jira/browse/FLINK-827
>             Project: Flink
>          Issue Type: Bug
>            Reporter: GitHub Import
>            Assignee: Tobias
>              Labels: github-import
>             Fix For: pre-apache
>
>
> We need a Java example program that shows the use of `KeySelector` functions.
> Alternatively we could modify an existing program to do this.
> The new example program should follow the general layout of the other example programs,
i.e., run without parameters on default data, have the same code structure, etc.
> ---------------- Imported from GitHub ----------------
> Url: https://github.com/stratosphere/stratosphere/issues/827
> Created by: [fhueske|https://github.com/fhueske]
> Labels: documentation, java api, 
> Milestone: Release 0.6 (unplanned)
> Created at: Sat May 17 12:45:24 CEST 2014
> State: open



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message