Skip to content

Commit

Permalink
renamed examples to applications
Browse files Browse the repository at this point in the history
  • Loading branch information
kamir committed Aug 27, 2024
1 parent 26fc5de commit a7afeee
Show file tree
Hide file tree
Showing 24 changed files with 602 additions and 38 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Apache Wayang (incubating) can be used via the following APIs:

## Quick Guide for Running Wayang

For a quick guide on how to run WordCount see [here](guides/tutorial.md).
For a quick guide on how to run org.apache.wayang.examples.WordCount see [here](guides/tutorial.md).

## Quick Guide for Developing with Wayang

Expand Down
7 changes: 6 additions & 1 deletion bin/wayang-submit
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

CLASS=$1


if [ -z "${CLASS}" ]; then
echo "Target Class for execution was not provided"
exit 1
Expand Down Expand Up @@ -120,5 +119,11 @@ do
ARGS="$ARGS \"${arg}\""
done

WAYANG_CLASSPATH="${WAYANG_CLASSPATH}:${WAYANG_APP_HOME}"

echo $WAYANG_CLASSPATH
echo
echo "[EXECUTE] :: $RUNNER $FLAGS -cp "${WAYANG_CLASSPATH}" $CLASS ${ARGS}"
echo
eval "$RUNNER $FLAGS -cp "${WAYANG_CLASSPATH}" $CLASS ${ARGS}"

8 changes: 4 additions & 4 deletions guides/develop-with-Wayang.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ This tutorial shows users how to import Wayang in their Java project using the m
```
A sample pom file can be found [here](pom-example.xml).

# Test WordCount
# Test org.apache.wayang.examples.WordCount
## Create a Java class that contains the main method that runs the Wordcount
Here is a sample implementation getting as input the filename (e.g., file:/Projects/Wayang/test.txt)

Expand All @@ -85,8 +85,8 @@ public static void main(String[] args) {

/* Get a plan builder */
JavaPlanBuilder planBuilder = new JavaPlanBuilder(wayangContext)
.withJobName("WordCount")
.withUdfJarOf(WordCount.class);
.withJobName("org.apache.wayang.examples.WordCount")
.withUdfJarOf(org.apache.wayang.examples.WordCount.class);

/* Start building the Apache WayangPlan */
Collection<Tuple2<String, Integer>> wordcounts = planBuilder
Expand Down Expand Up @@ -119,4 +119,4 @@ public static void main(String[] args) {
System.out.println(wordcounts);
}
```
A sample Java class file can be found [here](WordCount.java).
A sample Java class file can be found [here](org.apache.wayang.examples.WordCount.java).
2 changes: 1 addition & 1 deletion guides/ml-in-Wayang.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class CustomEstimatableCost implements EstimatableCost {
* by implementing the interface in this class.
*/
}
public class WordCount {
public class org.apache.wayang.examples.WordCount {
public static void main(String[] args) {
/* Create a Wayang context and specify the platforms Wayang will consider */
Configuration config = new Configuration();
Expand Down
4 changes: 2 additions & 2 deletions guides/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
limitations under the License.
-->
This tutorial will show users how to run the WordCount example locally with Wayang.
This tutorial will show users how to run the org.apache.wayang.examples.WordCount example locally with Wayang.

# Clone repository
```shell
Expand Down Expand Up @@ -57,7 +57,7 @@ source ~/.zshrc

# Run the program

To execute the WordCount example with Apache Wayang, you need to execute your program with the 'wayang-submit' command:
To execute the org.apache.wayang.examples.WordCount example with Apache Wayang, you need to execute your program with the 'wayang-submit' command:

```shell
cd wayang-0.7.1-SNAPSHOT
Expand Down
8 changes: 4 additions & 4 deletions guides/wayang-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
-->
This page contains examples to be executed using Wayang.
- [WordCount](#wordcount)
- [org.apache.wayang.examples.WordCount](#wordcount)
* [Java scala-like API](#java-scala-like-api)
* [Scala API](#scala-api)
- [k-means](#k-means)
* [Scala API](#scala-api-1)

## WordCount
## org.apache.wayang.examples.WordCount

The "Hello World!" of data processing systems is the wordcount.

Expand Down Expand Up @@ -51,7 +51,7 @@ public class WordcountJava {
.withPlugin(Java.basicPlugin())
.withPlugin(Spark.basicPlugin());
JavaPlanBuilder planBuilder = new JavaPlanBuilder(wayangContext)
.withJobName(String.format("WordCount (%s)", inputUrl))
.withJobName(String.format("org.apache.wayang.examples.WordCount (%s)", inputUrl))
.withUdfJarOf(WordcountJava.class);

// Start building the WayangPlan.
Expand Down Expand Up @@ -107,7 +107,7 @@ object WordcountScala {
.withPlugin(Java.basicPlugin)
.withPlugin(Spark.basicPlugin)
val planBuilder = new PlanBuilder(wayangContext)
.withJobName(s"WordCount ($inputUrl)")
.withJobName(s"org.apache.wayang.examples.WordCount ($inputUrl)")
.withUdfJarsOf(this.getClass)

val wordcounts = planBuilder
Expand Down
7 changes: 4 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1338,14 +1338,15 @@
<modules>
<module>wayang-commons</module>
<module>wayang-platforms</module>
<module>wayang-tests-integration</module>
<module>wayang-api</module>
<module>wayang-profiler</module>
<module>wayang-plugins</module>
<module>wayang-resources</module>
<module>wayang-benchmark</module>
<module>wayang-assembly</module>
<module>wayang-ml4all</module>
<!-- <module>wayang-docs</module> -->
<module>wayang-applications</module>
<module>wayang-benchmark</module>
<module>wayang-tests-integration</module>
<!--module>wayang-docs</module-->
</modules>
</project>
6 changes: 3 additions & 3 deletions wayang-api/wayang-api-scala-java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ import org.apache.wayang.core.api.Configuration
import org.apache.wayang.java.Java
import org.apache.wayang.spark.Spark

class WordCount {}
class org.apache.wayang.examples.WordCount {}

object WordCount {
object org.apache.wayang.examples.WordCount {

def main(args: Array[String]): Unit = {
println("WordCount")
println("org.apache.wayang.examples.WordCount")
println("Scala version:")
println(scala.util.Properties.versionString)

Expand Down
31 changes: 31 additions & 0 deletions wayang-applications/bin/run_wordcount.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
#

export JAVA_HOME=/Users/kamir/.sdkman/candidates/java/current

cd ..
cd ..

#mvn clean compile package install -pl :wayang-assembly -Pdistribution -DskipTests

cd wayang-applications
mvn compile package install -DskipTests

cd ..

source ./.env.sh; bin/wayang-submit org.apache.wayang.applications.WordCount java file://$(pwd)/wayang-applications/data/case-study/DATA_REPO_001/README.md
31 changes: 31 additions & 0 deletions wayang-applications/bin/run_wordcount_kafka.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
#

export JAVA_HOME=/Users/kamir/.sdkman/candidates/java/current

cd ..
cd ..

#mvn clean compile package install -pl :wayang-assembly -Pdistribution -DskipTests

cd wayang-applications
mvn compile package install -DskipTests

cd ..

source ./.env.sh; bin/wayang-submit org.apache.wayang.applications.WordCount java file://$(pwd)/wayang-applications/data/case-study/DATA_REPO_001/README.md
3 changes: 3 additions & 0 deletions wayang-applications/data/case-study/DATA_REPO_001/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Blossom Sky Setup on the "central node"

docker pull ghcr.io/databloom-ai/bde:main
Binary file not shown.
3 changes: 3 additions & 0 deletions wayang-applications/data/case-study/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Blossom Sky Setup on the "central node"

docker pull ghcr.io/databloom-ai/bde:main
145 changes: 145 additions & 0 deletions wayang-applications/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.wayang</groupId>
<artifactId>wayang</artifactId>
<version>0.7.1</version>
</parent>

<artifactId>wayang-applications</artifactId>
<packaging>jar</packaging>

<name>wayang-applications</name>
<url>http://maven.apache.org</url>


<properties>
<DATA_REPO_001>file://${project.basedir}/wayang-applications/data/case-study/DATA_REPO_001</DATA_REPO_001>
<DATA_REPO_002>https://kamir.solidcommunity.net/public/ecolytiq-sustainability-profile</DATA_REPO_002>
<DIST_WAYANG_HOME>${project.basedir}/../wayang-assembly/target/apache-wayang-assembly-0.7.1-incubating-dist/wayang-0.7.1</DIST_WAYANG_HOME>
<WAYANG_VERSION>0.7.1</WAYANG_VERSION>

<spark.version>3.5.0</spark.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>

<!-- We also specify the file encoding of our source files, to avoid a warning -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<assertj.version>3.17.2</assertj.version>
<commons-io.version>2.5</commons-io.version>
<guava.version>19.0</guava.version>
<hamcrest.version>1.3</hamcrest.version>
<jackson.version>2.10.2</jackson.version>
<jacoco.version>0.8.5</jacoco.version>
<jodatime.version>2.10.6</jodatime.version>
<jsonpath.version>2.4.0</jsonpath.version>
<junit5.version>5.6.1</junit5.version>
<mockito.version>3.5.10</mockito.version>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.wayang</groupId>
<artifactId>wayang-core</artifactId>
<version>${WAYANG_VERSION}</version>
</dependency>
<dependency>
<groupId>org.apache.wayang</groupId>
<artifactId>wayang-basic</artifactId>
<version>${WAYANG_VERSION}</version>
</dependency>
<dependency>
<groupId>org.apache.wayang</groupId>
<artifactId>wayang-java</artifactId>
<version>${WAYANG_VERSION}</version>
</dependency>
<dependency>
<groupId>org.apache.wayang</groupId>
<artifactId>wayang-spark_2.12</artifactId>
<version>${WAYANG_VERSION}</version>
</dependency>
<dependency>
<groupId>org.apache.wayang</groupId>
<artifactId>wayang-api-scala-java_2.12</artifactId>
<version>${WAYANG_VERSION}</version>
<!--scope>system</scope-->
<!--systemPath>/Users/mkaempf/GITHUB.private/kamir-incubator-wayang/wayang-assembly/target/apache-wayang-assembly-0.7.1-SNAPSHOT-incubating-dist/wayang-0.7.1-SNAPSHOT/jars/wayang-api-scala-java_2.12-0.7.1-SNAPSHOT.jar</systemPath-->
</dependency>
<!--dependency>
<groupId>org.apache.wayang</groupId>
<artifactId>wayang-api-scala-java_2.12</artifactId>
<version>${WAYANG_VERSION}</version>
</dependency-->

<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.12</artifactId>
<version>${spark.version}</version>
</dependency>

<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.12.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.13</version>
</dependency>

<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>3.4.0</version> <!-- Use the latest version available -->
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.4</version>
</dependency>

<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<!--configuration>
<outputDirectory>/opt/homebrew/opt/apache-spark/jars</outputDirectory>
</configuration-->
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.wayang.applications;

public class App
{
public static void main( String[] args )
{
System.out.println( "Hello Apache Wayang friends!" );
}

}
Loading

0 comments on commit a7afeee

Please sign in to comment.