Skip to content

Commit

Permalink
[scala] Fix Formatting in Examples and add ITCases
Browse files Browse the repository at this point in the history
Also actually use termination criterion in TransitivelClosureNaive
Java example.

Add ConnectedComponentsITCase for Scala Example

Also fix some formatting in the example code

Add WebLogAnalysisITCase for Scala Example

Some minor reformatting of example code and scaladoc.

Add ITCases for TriangleEnumeration Scala Examples

Also fix some formatting and make TriangleEnumerationOpt Scala produce the
same output as the Java version.

Add PageRankITCase for Scala Example

Also fix formatting in PageRank Scala Example.

Fix formatting in EnumTriangles Scala Examples

Remove Old/Deprecated Scala Examples and ITCases

Fix formatting in EnumTrianglesBasic.scala

Fix formatting in LinearRegression Scala Example

Remove old Scala LineRank Code and RelQuery Example

[scala] Fix typo in scaladoc in GroupedDataSet

[scala] Fix Scaladoc of Join and CoGroup Operation

Was still referring to the type of join/coGroup function that returns an
Option.

Fix tab vs. spaces in flink-scala and flink-scala-examples
  • Loading branch information
aljoscha committed Sep 22, 2014
1 parent a41a29b commit 31ed0c4
Show file tree
Hide file tree
Showing 27 changed files with 447 additions and 1,021 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void coGroup(Iterable<Tuple2<Long, Long>> prevPaths, Iterable<Tuple2<Long
}
});

DataSet<Tuple2<Long, Long>> transitiveClosure = paths.closeWith(nextPaths);
DataSet<Tuple2<Long, Long>> transitiveClosure = paths.closeWith(nextPaths, newPaths);


// emit result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,13 @@
*/
public class ConnectedComponentsData {

public static final Object[][] VERTICES = new Object[][] {
new Object[]{1L}, new Object[]{2L}, new Object[]{3L}, new Object[]{4L},
new Object[]{5L},new Object[]{6L}, new Object[]{7L}, new Object[]{8L},
new Object[]{9L}, new Object[]{10L}, new Object[]{11L}, new Object[]{12L},
new Object[]{13L}, new Object[]{14L}, new Object[]{15L}, new Object[]{16L}
};
public static final long[] VERTICES = new long[] {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};

public static DataSet<Long> getDefaultVertexDataSet(ExecutionEnvironment env) {
List<Long> verticesList = new LinkedList<Long>();
for (Object[] vertex : VERTICES) {
verticesList.add((Long) vertex[0]);
for (long vertexId : VERTICES) {
verticesList.add(vertexId);
}
return env.fromCollection(verticesList);
}
Expand Down
54 changes: 27 additions & 27 deletions flink-examples/flink-scala-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ under the License.
<artifactId>flink-scala</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-java-examples</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-java-examples</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
Expand All @@ -54,7 +54,7 @@ under the License.
<version>3.1.4</version>
<executions>
<!-- Run scala compiler in the process-resources phase, so that dependencies on
scala classes can be resolved later in the (Java) compile phase -->
scala classes can be resolved later in the (Java) compile phase -->
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
Expand All @@ -64,7 +64,7 @@ under the License.
</execution>

<!-- Run scala compiler in the process-test-resources phase, so that dependencies on
scala classes can be resolved later in the (Java) test-compile phase -->
scala classes can be resolved later in the (Java) test-compile phase -->
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
Expand Down Expand Up @@ -237,7 +237,7 @@ under the License.
</includes>
</configuration>
</execution>
-->
-->

<execution>
<id>WordCount</id>
Expand All @@ -260,7 +260,7 @@ under the License.
</includes>
</configuration>
</execution>
<!--
<!--
<execution>
<id>ConnectedComponents</id>
<phase>package</phase>
Expand All @@ -282,27 +282,27 @@ under the License.
-->

<execution>
<id>TransitiveClosureNaive</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<execution>
<id>TransitiveClosureNaive</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>

<configuration>
<classifier>TransitiveClosureNaive</classifier>
<configuration>
<classifier>TransitiveClosureNaive</classifier>

<archive>
<manifestEntries>
<program-class>org.apache.flink.examples.scala.graph.TransitiveClosureNaive</program-class>
</manifestEntries>
</archive>
<archive>
<manifestEntries>
<program-class>org.apache.flink.examples.scala.graph.TransitiveClosureNaive</program-class>
</manifestEntries>
</archive>

<includes>
<include>**/wordcount/TransitiveClosureNaive*.class</include>
</includes>
</configuration>
</execution>
<includes>
<include>**/wordcount/TransitiveClosureNaive*.class</include>
</includes>
</configuration>
</execution>

</executions>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,26 @@ import org.apache.flink.api.common.functions.GroupReduceFunction
import org.apache.flink.util.Collector
import org.apache.flink.examples.java.graph.util.EnumTrianglesData
import org.apache.flink.api.common.operators.Order
import scala.collection.mutable.MutableList

import scala.collection.mutable


/**
* Triangle enumeration is a pre-processing step to find closely connected parts in graphs.
* A triangle consists of three edges that connect three vertices with each other.
*
* <p>
* The algorithm works as follows:
* The algorithm works as follows:
* It groups all edges that share a common vertex and builds triads, i.e., triples of vertices
* that are connected by two edges. Finally, all triads are filtered for which no third edge exists
* that closes the triangle.
*
* <p>
* Input files are plain text files and must be formatted as follows:
* <ul>
* <li>Edges are represented as pairs for vertex IDs which are separated by space
* characters. Edges are separated by new-line characters.<br>
* For example <code>"1 2\n2 12\n1 12\n42 63\n"</code> gives four (undirected) edges (1)-(2), (2)-(12), (1)-(12), and (42)-(63)
* that include a triangle
* </ul>
*
* - Edges are represented as pairs for vertex IDs which are separated by space
* characters. Edges are separated by new-line characters.
* For example `"1 2\n2 12\n1 12\n42 63\n"` gives four (undirected) edges (1)-(2), (2)-(12),
* (1)-(12), and (42)-(63) that include a triangle
*
* <pre>
* (1)
* / \
Expand All @@ -59,13 +58,11 @@ import scala.collection.mutable.MutableList
* If no parameters are provided, the program is run with default data from
* [[org.apache.flink.examples.java.graph.util.EnumTrianglesData]]
*
* <p>
* This example shows how to use:
* <ul>
* <li>Custom Java objects which extend Tuple
* <li>Group Sorting
* </ul>
*
*
* - Custom Java objects which extend Tuple
* - Group Sorting
*
*/
object EnumTrianglesBasic {

Expand All @@ -91,7 +88,7 @@ object EnumTrianglesBasic {

// emit result
if (fileOutput) {
triangles.writeAsCsv(outputPath, "\n", " ")
triangles.writeAsCsv(outputPath, "\n", ",")
} else {
triangles.print()
}
Expand Down Expand Up @@ -119,12 +116,12 @@ object EnumTrianglesBasic {
*/
class TriadBuilder extends GroupReduceFunction[Edge, Triad] {

val vertices = MutableList[Integer]()
val vertices = mutable.MutableList[Integer]()

override def reduce(edges: java.lang.Iterable[Edge], out: Collector[Triad]) = {

// clear vertex list
vertices.clear
vertices.clear()

// build and emit triads
for(e <- edges.asScala) {
Expand Down Expand Up @@ -153,10 +150,10 @@ object EnumTrianglesBasic {
false
}
} else {
System.out.println("Executing Enum Triangles Basic example with built-in default data.");
System.out.println(" Provide parameters to read input data from files.");
System.out.println(" See the documentation for the correct format of input files.");
System.out.println(" Usage: EnumTriangleBasic <edge path> <result path>");
System.out.println("Executing Enum Triangles Basic example with built-in default data.")
System.out.println(" Provide parameters to read input data from files.")
System.out.println(" See the documentation for the correct format of input files.")
System.out.println(" Usage: EnumTriangleBasic <edge path> <result path>")
}
true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import org.apache.flink.examples.java.graph.util.EnumTrianglesData
import org.apache.flink.api.common.operators.Order
import scala.collection.mutable.MutableList

import scala.collection.mutable


/**
* Triangle enumeration is a pre-processing step to find closely connected parts in graphs.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ object TransitiveClosureNaive {
env.fromCollection(edgeData)
}
}
}
}
Loading

0 comments on commit 31ed0c4

Please sign in to comment.