flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fhue...@apache.org
Subject [2/2] flink git commit: [FLINK-1105] [docs] Added documentation for locally sorted output
Date Tue, 03 Feb 2015 10:12:40 GMT
[FLINK-1105] [docs] Added documentation for locally sorted output


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

Branch: refs/heads/master
Commit: 94c3e9c085e3451d42ef838ace95f62ec05dfdd9
Parents: 5f47559
Author: Fabian Hueske <fhueske@apache.org>
Authored: Thu Jan 29 11:59:10 2015 +0100
Committer: Fabian Hueske <fhueske@apache.org>
Committed: Tue Feb 3 10:51:39 2015 +0100

----------------------------------------------------------------------
 docs/programming_guide.md | 63 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/94c3e9c0/docs/programming_guide.md
----------------------------------------------------------------------
diff --git a/docs/programming_guide.md b/docs/programming_guide.md
index 9f0d442..6ed6e04 100644
--- a/docs/programming_guide.md
+++ b/docs/programming_guide.md
@@ -1773,6 +1773,37 @@ myResult.output(
     );
 {% endhighlight %}
 
+#### Locally Sorted Output
+
+The output of a data sink can be locally sorted on specified fields in specified orders using
[tuple field positions](#define-keys-for-tuples) or [field expressions](#define-keys-using-field-expressions).
This works for every output format.
+
+The following examples show how to use this feature:
+
+{% highlight java %}
+
+DataSet<Tuple3<Integer, String, Double>> tData = // [...]
+DataSet<Tuple2<BookPojo, Double>> pData = // [...]
+DataSet<String> sData = // [...]
+
+// sort output on String field in ascending order
+tData.print().sortLocalOutput(1, Order.ASCENDING);
+
+// sort output on Double field in descending and Integer field in ascending order
+tData.print().sortLocalOutput(2, Order.DESCENDING).sortLocalOutput(0, Order.ASCENDING);
+
+// sort output on the "author" field of nested BookPojo in descending order
+pData.writeAsText(...).sortLocalOutput("f0.author", Order.DESCENDING);
+
+// sort output on the full tuple in ascending order
+tData.writeAsCsv(...).sortLocalOutput("*", Order.ASCENDING);
+
+// sort atomic type (String) output in descending order
+sData.writeAsText(...).sortLocalOutput("*", Order.DESCENDING);
+
+{% endhighlight %}
+
+Globally sorted output is not supported yet.
+
 </div>
 <div data-lang="scala" markdown="1">
 Data sinks consume DataSets and are used to store or return them. Data sink operations are
described
@@ -1824,6 +1855,38 @@ values map { tuple => tuple._1 + " - " + tuple._2 }
   .writeAsText("file:///path/to/the/result/file")
 {% endhighlight %}
 
+
+#### Locally Sorted Output
+
+The output of a data sink can be locally sorted on specified fields in specified orders using
[tuple field positions](#define-keys-for-tuples) or [field expressions](#define-keys-using-field-expressions).
This works for every output format.
+
+The following examples show how to use this feature:
+
+{% highlight scala %}
+
+val tData: DataSet[(Int, String, Double)] = // [...]
+val pData: DataSet[(BookPojo, Double)] = // [...]
+val sData: DataSet[String] = // [...]
+
+// sort output on String field in ascending order
+tData.print.sortLocalOutput(1, Order.ASCENDING);
+
+// sort output on Double field in descending and Int field in ascending order
+tData.print.sortLocalOutput(2, Order.DESCENDING).sortLocalOutput(0, Order.ASCENDING);
+
+// sort output on the "author" field of nested BookPojo in descending order
+pData.writeAsText(...).sortLocalOutput("_1.author", Order.DESCENDING);
+
+// sort output on the full tuple in ascending order
+tData.writeAsCsv(...).sortLocalOutput("_", Order.ASCENDING);
+
+// sort atomic type (String) output in descending order
+sData.writeAsText(...).sortLocalOutput("_", Order.DESCENDING);
+
+{% endhighlight %}
+
+Globally sorted output is not supported yet.
+
 </div>
 </div>
 


Mime
View raw message