You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by gr...@apache.org on 2017/12/01 02:58:48 UTC

flink git commit: [hotfix] [gelly] Fix Gelly CSV output

Repository: flink
Updated Branches:
  refs/heads/master f0e82dca3 -> 740f711c4


[hotfix] [gelly] Fix Gelly CSV output

Algorithm result types no longer extend Tuple but are now custom POJOs.
This prevents the use of DataSet#writeAsCsv which accepts custom line
and field delimiters. Anticipating this lose the result types override

This patch uses DataSet#writeAsCsv for types extending Tuple and
DataSet#writeAsText otherwise. Since most algorithm result types are now
custom POJOs the custom delimiters are now largely ineffective.


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

Branch: refs/heads/master
Commit: 740f711c4ec9c4b7cdefd01c9f64857c345a68a1
Parents: f0e82dc
Author: Greg Hogan <co...@greghogan.com>
Authored: Thu Nov 30 15:25:48 2017 -0500
Committer: Greg Hogan <co...@greghogan.com>
Committed: Thu Nov 30 21:54:51 2017 -0500

----------------------------------------------------------------------
 .../org/apache/flink/graph/drivers/output/CSV.java  | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/740f711c/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
index 9b6aae6..a24255c 100644
--- 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
@@ -20,6 +20,7 @@ package org.apache.flink.graph.drivers.output;
 
 import org.apache.flink.api.java.DataSet;
 import org.apache.flink.api.java.io.CsvOutputFormat;
+import org.apache.flink.api.java.tuple.Tuple;
 import org.apache.flink.graph.drivers.parameter.StringParameter;
 
 import java.io.PrintStream;
@@ -42,8 +43,17 @@ extends OutputBase<T> {
 
 	@Override
 	public void write(String executionName, PrintStream out, DataSet<T> data) throws Exception {
-		data
-			.writeAsCsv(filename.getValue(), lineDelimiter.getValue(), fieldDelimiter.getValue())
-				.name("CSV: " + filename.getValue());
+		if (Tuple.class.isAssignableFrom(data.getType().getTypeClass())) {
+			data
+				.writeAsCsv(filename.getValue(), lineDelimiter.getValue(), fieldDelimiter.getValue())
+					.name("CSV: " + filename.getValue());
+		} else {
+			// line and field delimiters are ineffective when writing custom POJOs result types
+			data
+				.writeAsText(filename.getValue())
+					.name("CSV: " + filename.getValue());
+		}
+
+		data.getExecutionEnvironment().execute();
 	}
 }