Github user roshannaik commented on a diff in the pull request: https://github.com/apache/storm/pull/1914#discussion_r100959503 --- Diff: docs/Joins.md --- @@ -0,0 +1,126 @@ +--- +title: Joining Streams in Storm Core +layout: documentation +documentation: true +--- + +Storm core supports joining multiple data streams into one with the help of `JoinBolt`. +`JoinBolt` is a Windowed bolt, i.e. it waits for the configured window duration to match up the +tuples among the streams being joined. This helps align the streams within a Window boundary. + +Each of `JoinBolt`'s incoming data streams must be Fields Grouped on a single field. A stream +should only be joined with the other streams using the field on which it has been FieldsGrouped. +Knowing this will help understand the join syntax described below. + +## Performing Joins +Consider the following SQL join involving 4 tables: + +```sql +select userId, key4, key2, key3 +from table1 +inner join table2 on table2.userId = table1.key1 +inner join table3 on table3.key3 = table2.userId +left join table4 on table4.key4 = table3.key3 +``` + +Similar joins could be expressed on tuples generated by 4 spouts using `JoinBolt`: + +```java +JoinBolt jbolt = new JoinBolt("spout1", "key1") // from spout1 + .join ("spout2", "userId", "spout1") // inner join spout2 on spout2.userId = spout1.key1 + .join ("spout3", "key3", "spout2") // inner join spout3 on spout3.key3 = spout2.userId + .leftJoin ("spout4", "key4", "spout3") // left join spout4 on spout4.key4 = spout3.key3 + .select ("userId, key4, key2, spout3:key3") // chose output fields + .withTumblingWindow( new Duration(10, TimeUnit.MINUTES) ) ; + +topoBuilder.setBolt("joiner", jbolt, 1) + .fieldsGrouping("spout1", new Fields("key1") ) + .fieldsGrouping("spout2", new Fields("userId") ) + .fieldsGrouping("spout3", new Fields("key3") ) + .fieldsGrouping("spout4", new Fields("key4") ); +``` + +The bolt constructor takes two arguments. The 1st argument introduces the data from `spout1`' --- End diff -- fixed. thanks.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---