[ 
https://issues.apache.org/jira/browse/BEAM-4368?focusedWorklogId=108157&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-108157
 ]

ASF GitHub Bot logged work on BEAM-4368:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 01/Jun/18 18:14
            Start Date: 01/Jun/18 18:14
    Worklog Time Spent: 10m 
      Work Description: asfgit closed pull request #453: [BEAM-4368] add 
euphoria java 8 dsl documentation section
URL: https://github.com/apache/beam-site/pull/453
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/contribute/index.md b/src/contribute/index.md
index d80bec80d..de269f1d3 100644
--- a/src/contribute/index.md
+++ b/src/contribute/index.md
@@ -206,6 +206,16 @@ See the 
[documentation](https://beam.apache.org/documentation/io/testing/#i-o-tr
 
 If you're willing to help in this area, tag the following people in PRs: 
[@chamikaramj](https://github.com/chamikaramj), 
[@DariuszAniszewski](https://github.com/dariuszaniszewski), 
[@lgajowy](https://github.com/lgajowy), [@szewi](https://github.com/szewi), 
[@kkucharc](https://github.com/kkucharc) 
 
+### Euphoria Java 8 DSL
+
+Easy to use Java 8 DSL for the Beam Java SDK. Provides a high-level 
abstraction of Beam transformations, which is both easy to read and write. Can 
be used as a complement to existing Beam pipelines (convertible back and 
forth). You can have a glimpse of the API at [WordCount example]({{ site.baseurl
+}}/documentation/sdks/java/euphoria/#wordcount-example).
+
+- Feature branch: 
[dsl-euphoria](https://github.com/apache/beam/tree/dsl-euphoria)
+- JIRA: 
[dsl-euphoria](https://issues.apache.org/jira/browse/BEAM-4366?jql=project%20%3D%20BEAM%20AND%20component%20%3D%20dsl-euphoria)
 / [BEAM-3900](https://issues.apache.org/jira/browse/BEAM-3900) 
+- Contact: [David Moravek](mailto:[email protected])
+
+
 ## Stale pull requests
 
 The community will close stale pull requests in order to keep the project
diff --git a/src/documentation/sdks/euphoria.md 
b/src/documentation/sdks/euphoria.md
new file mode 100644
index 000000000..e1434b804
--- /dev/null
+++ b/src/documentation/sdks/euphoria.md
@@ -0,0 +1,76 @@
+---
+layout: section
+title: "Euphoria Java 8 DSL"
+section_menu: section-menu/sdks.html
+permalink: /documentation/sdks/java/euphoria/
+---
+# Euphoria Java 8 DSL
+
+## What is Euphoria
+
+Easy to use Java 8 DSL for the Beam Java SDK. Provides a high-level 
abstraction of Beam transformations, which is both easy to read and write. Can 
be used as a complement to existing Beam pipelines (convertible back and forth).
+
+Integration of Euphoria API to Beam is in **progress** 
([BEAM-3900](https://issues.apache.org/jira/browse/BEAM-3900)).
+
+## How to build
+
+Euphoria is located in `dsl-euphoria` branch. To build `euphoria` subprojects 
use command:
+
+```
+./gradlew :beam-sdks-java-extensions-euphoria-beam:build 
+```
+
+## WordCount example
+
+```java
+Pipeline pipeline = Pipeline.create(options);
+
+// Transform to euphoria's flow.
+BeamFlow flow = BeamFlow.create(pipeline);
+
+// Source of data loaded from Beam IO.
+PCollection<String> input =
+    
pipeline.apply(Create.of(inputs)).setTypeDescriptor(TypeDescriptor.of(String.class));
+// Transform PCollection to euphoria's Dataset.
+Dataset<String> lines = flow.wrapped(input);
+
+// FlatMap processes one input element at a time and allows user code to emit
+// zero, one, or more output elements. From input lines we will get data set 
of words.
+Dataset<String> words = FlatMap.named("TOKENIZER")
+    .of(lines)
+    .using((String line, Collector<String> context) -> {
+      for (String word : line.split("\\s+")) {
+        context.collect(word);
+      }
+    })
+    .output();
+
+// From each input element we extract a key (word) and value, which is the 
constant `1`.
+// Then, we reduce by the key - the operator ensures that all values for the 
same
+// key end up being processed together. It applies user defined function 
(summing word counts for each
+// unique word) and its emitted to output. 
+Dataset<Pair<String, Long>> counted = ReduceByKey.named("COUNT")
+    .of(words)
+    .keyBy(w -> w)
+    .valueBy(w -> 1L)
+    .combineBy(Sums.ofLongs())
+    .output();
+
+// Format output.
+Dataset<String> output = MapElements.named("FORMAT")
+    .of(counted)
+    .using(p -> p.getFirst() + ": " + p.getSecond())
+    .output();
+
+// Transform Dataset back to PCollection. It can be done in any step of this 
flow.
+PCollection<String> outputCollection = flow.unwrapped(output);
+
+// Now we can again use Beam transformation. In this case we save words and 
their count
+// into the text file.
+outputCollection.apply(TextIO.write().to(options.getOutput()));
+
+pipeline.run();
+```
+
+
+
diff --git a/src/documentation/sdks/java.md b/src/documentation/sdks/java.md
index f5be0fd88..397ed268d 100644
--- a/src/documentation/sdks/java.md
+++ b/src/documentation/sdks/java.md
@@ -33,5 +33,6 @@ The Java SDK has the following extensions:
 - 
[join-library]({{site.baseurl}}/documentation/sdks/java-extensions/#join-library)
 provides inner join, outer left join, and outer right join functions.
 - [sorter]({{site.baseurl}}/documentation/sdks/java-extensions/#sorter) is an 
efficient and scalable sorter for large iterables.
 - [Nexmark]({{site.baseurl}}/documentation/sdks/java/nexmark) is a benchmark 
suite that runs in batch and streaming modes.
+- [euphoria]({{site.baseurl}}/documentation/sdks/java/euphoria) is easy to use 
Java 8 DSL for BEAM.
 
 In addition several [3rd party Java 
libraries]({{site.baseurl}}/documentation/sdks/java-thirdparty/) exist.
\ No newline at end of file


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 108157)
    Time Spent: 1h 40m  (was: 1.5h)

> Add Euphoria Java 8 DSL to "Conbribute > Technical References > Ongoing 
> Projects"
> ---------------------------------------------------------------------------------
>
>                 Key: BEAM-4368
>                 URL: https://issues.apache.org/jira/browse/BEAM-4368
>             Project: Beam
>          Issue Type: Sub-task
>          Components: dsl-euphoria, website
>            Reporter: Marek Simunek
>            Assignee: Marek Simunek
>            Priority: Minor
>          Time Spent: 1h 40m
>  Remaining Estimate: 0h
>
> We should have this effort listed here: 
> [https://beam.apache.org/contribute/work-in-progress/]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to