storm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kabh...@apache.org
Subject [1/2] storm git commit: [STORM-1527] Added trident api doc for peek
Date Fri, 05 Feb 2016 13:05:00 GMT
Repository: storm
Updated Branches:
  refs/heads/asf-site d9003e495 -> 7f68ed961


[STORM-1527] Added trident api doc for peek


Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/2df59c04
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/2df59c04
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/2df59c04

Branch: refs/heads/asf-site
Commit: 2df59c04836780d715272320cdf2062d884b364d
Parents: d9003e4
Author: Arun Mahadevan <aiyer@hortonworks.com>
Authored: Fri Feb 5 15:27:14 2016 +0530
Committer: Arun Mahadevan <aiyer@hortonworks.com>
Committed: Fri Feb 5 15:27:14 2016 +0530

----------------------------------------------------------------------
 documentation/Trident-API-Overview.md | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/2df59c04/documentation/Trident-API-Overview.md
----------------------------------------------------------------------
diff --git a/documentation/Trident-API-Overview.md b/documentation/Trident-API-Overview.md
index c247ffd..bc6943d 100644
--- a/documentation/Trident-API-Overview.md
+++ b/documentation/Trident-API-Overview.md
@@ -139,6 +139,22 @@ Of course these operations can be chained, so a stream of uppercase words
can be
 ```java
 mystream.flatMap(new Split()).map(new UpperCase())
 ```
+### peek
+`peek` can be used to perform an additional action on each trident tuple as they flow through
the stream.
+ This could be useful for debugging to see the tuples as they flow past a certain point in
a pipeline.
+
+For example, the below code would print the result of converting the words to uppercase before
they are passed to `groupBy`
+```java
+ mystream.flatMap(new Split()).map(new UpperCase())
+         .peek(new Consumer() {
+                @Override
+                public void accept(TridentTuple input) {
+                  System.out.println(input.getString(0));
+                }
+         })
+         .groupBy(new Fields("word"))
+         .persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count"))
+ ```
 
 ### partitionAggregate
 


Mime
View raw message