Repository: flink
Updated Branches:
  refs/heads/master 206ea2119 -> 70e78a620


[FLINK-5910] [gelly] Framework for Gelly examples

Driver jobs are composed of an input, an algorithm driver, and an
output. Create the interfaces for inputs, drivers, and outputs.

This closes #3431


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/70e78a62
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/70e78a62
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/70e78a62

Branch: refs/heads/master
Commit: 70e78a620df503f06e298dd5537f24a56a8cc866
Parents: 694794e
Author: Greg Hogan <c...@greghogan.com>
Authored: Tue Feb 28 12:20:42 2017 -0500
Committer: Greg Hogan <c...@greghogan.com>
Committed: Fri Mar 10 09:48:02 2017 -0500

----------------------------------------------------------------------
 .../org/apache/flink/graph/drivers/Driver.java  | 66 ++++++++++++++++++++
 .../apache/flink/graph/drivers/input/Input.java | 51 +++++++++++++++
 .../apache/flink/graph/drivers/output/CSV.java  | 34 ++++++++++
 .../apache/flink/graph/drivers/output/Hash.java | 33 ++++++++++
 .../flink/graph/drivers/output/Print.java       | 33 ++++++++++
 .../graph/drivers/parameter/Parameterized.java  | 51 +++++++++++++++
 6 files changed, 268 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/70e78a62/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/Driver.java
----------------------------------------------------------------------
diff --git 
a/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/Driver.java
 
b/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/Driver.java
new file mode 100644
index 0000000..b001875
--- /dev/null
+++ 
b/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/Driver.java
@@ -0,0 +1,66 @@
+/*
+ * 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.flink.graph.drivers;
+
+import org.apache.flink.graph.Graph;
+import org.apache.flink.graph.GraphAlgorithm;
+import org.apache.flink.graph.GraphAnalytic;
+import org.apache.flink.graph.drivers.parameter.Parameterized;
+
+/**
+ * A driver for one or more {@link GraphAlgorithm}s and/or
+ * {@link GraphAnalytic}s.
+ *
+ * It is preferable to include multiple, overlapping algorithms/analytics in
+ * the same driver both for simplicity and since this examples module
+ * demonstrates Flink capabilities rather than absolute performance.
+ *
+ * @param <K> graph ID type
+ * @param <VV> vertex value type
+ * @param <EV> edge value type
+ */
+public interface Driver<K, VV, EV>
+extends Parameterized {
+
+       /**
+        * A one-line description, presented in the algorithm listing.
+        *
+        * @return short description
+        */
+       String getShortDescription();
+
+       /**
+        * A multi-line description, presented in the algorithm usage.
+        *
+        * @return long description
+        */
+       String getLongDescription();
+
+       /**
+        * "Run" algorithms and analytics on the input graph. The execution plan
+        * is not finalized here but in the output methods.
+        *
+        * Drivers are first configured, next planned, and finally the chosen
+        * output method is called.
+        *
+        * @param graph input graph
+        * @throws Exception on error
+        */
+       void plan(Graph<K, VV, EV> graph) throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/70e78a62/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/input/Input.java
----------------------------------------------------------------------
diff --git 
a/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/input/Input.java
 
b/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/input/Input.java
new file mode 100644
index 0000000..d647dd6
--- /dev/null
+++ 
b/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/input/Input.java
@@ -0,0 +1,51 @@
+/*
+ * 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.flink.graph.drivers.input;
+
+import org.apache.flink.api.java.ExecutionEnvironment;
+import org.apache.flink.graph.Graph;
+import org.apache.flink.graph.drivers.parameter.Parameterized;
+import org.apache.flink.graph.generator.GraphGenerator;
+
+/**
+ * Input source for a {@link Graph}, for example a file reader or
+ * {@link GraphGenerator}.
+ *
+ * @param <K> graph ID type
+ * @param <VV> vertex value type
+ * @param <EV> edge value type
+ */
+public interface Input<K, VV, EV>
+extends Parameterized {
+
+       /**
+        * A human-readable identifier summarizing the input and configuration.
+        *
+        * @return the unique identifier
+        */
+       String getIdentity();
+
+       /**
+        * Create the input {@link Graph}.
+        *
+        * @param env the ExecutionEnvironment
+        * @return the input Graph
+        */
+       Graph<K, VV, EV> create(ExecutionEnvironment env) throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/70e78a62/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/output/CSV.java
----------------------------------------------------------------------
diff --git 
a/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/output/CSV.java
 
b/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/output/CSV.java
new file mode 100644
index 0000000..5d1faeb
--- /dev/null
+++ 
b/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/output/CSV.java
@@ -0,0 +1,34 @@
+/*
+ * 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.flink.graph.drivers.output;
+
+/**
+ * Write algorithm output to file using CSV format.
+ */
+public interface CSV {
+
+       /**
+        * Write execution results to file using CSV format.
+        *
+        * @param filename output filename
+        * @param lineDelimiter CSV delimiter between lines
+        * @param fieldDelimiter CSV delimiter between fields
+        */
+       void writeCSV(String filename, String lineDelimiter, String 
fieldDelimiter);
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/70e78a62/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/output/Hash.java
----------------------------------------------------------------------
diff --git 
a/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/output/Hash.java
 
b/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/output/Hash.java
new file mode 100644
index 0000000..e1c399e
--- /dev/null
+++ 
b/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/output/Hash.java
@@ -0,0 +1,33 @@
+/*
+ * 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.flink.graph.drivers.output;
+
+/**
+ * Print hash of algorithm output.
+ */
+public interface Hash {
+
+       /**
+        * Print hash of execution results.
+        *
+        * @param executionName job name
+        * @throws Exception on error
+        */
+       void hash(String executionName) throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/70e78a62/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/output/Print.java
----------------------------------------------------------------------
diff --git 
a/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/output/Print.java
 
b/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/output/Print.java
new file mode 100644
index 0000000..be421b0
--- /dev/null
+++ 
b/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/output/Print.java
@@ -0,0 +1,33 @@
+/*
+ * 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.flink.graph.drivers.output;
+
+/**
+ * Print algorithm output.
+ */
+public interface Print {
+
+       /**
+        * Print execution results.
+        *
+        * @param executionName job name
+        * @throws Exception on error
+        */
+       void print(String executionName) throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/70e78a62/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/parameter/Parameterized.java
----------------------------------------------------------------------
diff --git 
a/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/parameter/Parameterized.java
 
b/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/parameter/Parameterized.java
new file mode 100644
index 0000000..b24f8cf
--- /dev/null
+++ 
b/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/parameter/Parameterized.java
@@ -0,0 +1,51 @@
+/*
+ * 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.flink.graph.drivers.parameter;
+
+import org.apache.flink.api.java.utils.ParameterTool;
+import org.apache.flink.client.program.ProgramParametrizationException;
+
+/**
+ * A configurable command-line choice, such as an input or algorithm.
+ */
+public interface Parameterized {
+
+       /**
+        * A unique, human-readable identifier. Presented to the user as the
+        * name of a selectable choice.
+        *
+        * @return parameter name
+        */
+       String getName();
+
+       /**
+        * Human-readable format for the command-line usage string.
+        *
+        * @return command-line documentation string
+        */
+       String getParameterization();
+
+       /**
+        * Read parameter values from the command-line arguments.
+        *
+        * @param parameterTool parameter parser
+        * @throws ProgramParametrizationException when configuration is invalid
+        */
+       void configure(ParameterTool parameterTool) throws 
ProgramParametrizationException;
+}

Reply via email to