Github user fhueske commented on a diff in the pull request:
https://github.com/apache/incubator-flink/pull/195#discussion_r20208486
--- Diff: docs/local_execution.md ---
@@ -56,26 +59,40 @@ public static void main(String[] args) throws Exception
{
~~~
-## Local Executor
-
-The *LocalExecutor* is similar to the local environment, but it takes a
*Plan* object, which describes the program as a single executable unit. The
*LocalExecutor* is typically used with the Scala API.
+## Local Execution on Java Collections
-The following code shows how you would use the `LocalExecutor` with the
Wordcount example for Scala Programs:
+The execution on Java Collections is a low-overhead approach for executing
Flink programs. Typical use-cases for this mode are automated tests, debugging
and code re-use.
-~~~scala
-public static void main(String[] args) throws Exception {
- val input = TextFile("hdfs://path/to/file")
+Users can use algorithms implemented for batch processing with Flink for
also for cases that are more interactive. A slightly changed variant of a Flink
program could be used in a Java Application Server for processing incoming
requests.
- val words = input flatMap { _.toLowerCase().split("""\W+""") filter {
_ != "" } }
- val counts = words groupBy { x => x } count()
+**Skeleton for Collection-based execution**
- val output = counts.write(wordsOutput, CsvOutputFormat())
-
- val plan = new ScalaPlan(Seq(output), "Word Count")
- LocalExecutor.executePlan(p);
+~~~java
+public static void main(String[] args) throws Exception {
+ // initialize a new Collection-based execution environment
+ final ExecutionEnvironment env = new CollectionEnvironment();
+
+ DataSet<User> users = env.fromCollection( /* get elements from a Java
Collection */);
+
+ /* Data Set transformations ... */
+
+ // retrieve the resulting Tuple2 elements into a ArrayList.
+ Collection<...> result = new ArrayList<...>();
+ resultDataSet.output(new LocalCollectionOutputFormat<...>(result));
+
+ // kick off execution.
+ env.execute();
+
+ // Do some work with the resulting ArrayList (=Collection).
+ for(... t : result) {
+ System.err.println("Result = "+t);
+ }
--- End diff --
Maybe a link to the example program?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---