Github user arunmahadevan commented on a diff in the pull request:

    https://github.com/apache/storm/pull/1914#discussion_r100952160
  
    --- 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`'
    +to be the first stream and specifies that it will always use field `key1` 
when joining this with the others streams.
    +The name of the component specified must refer to the spout or bolt that 
is directly connected to the Join bolt. 
    +Here data received from `spout1` must be fields grouped on `key1`. 
Similarly, each of the `leftJoin()` and `join()` method
    +calls introduce a new stream along with the field to use for the join. As 
seen in above example, the same FieldsGrouping
    +requirement applies to these streams as well. The 3rd argument to the join 
methods refers to another stream with which
    +to join.
    +
    +The `select()` method is used to specify the output fields. The argument 
to `select` is a comma separated list of fields.
    +Individual field names can be prefixed with a stream name to disambiguate 
between the same field name occurring in
    +multiple streams as follows:  `.select("spout3:key3, spout4:key3")`. 
Nested tuple types are supported if the
    +nesting has been done using `Map`s. For example  `outer.inner.innermost` 
refers to a field that is nested three levels
    +deep where `outer` and `inner` are of type `Map`.   
    +
    +Stream name prefix is not allowed for the fields in any of the join() 
arguments, but nested fields are supported. 
    +
    +The call to `withTumblingWindow()` above, configures the join window to be 
a 10 minute tumbling window. Since `JoinBolt` 
    +is a Windowed Bolt, we can also use the `withWindow` method to configure 
it as a sliding window (see tips section below). 
    +
    +## Stream names and Join order
    +1. Stream names must be introduced (in constructor or as 1st arg to 
various join methods) before being referred
    +to (in the 3rd argument of the join methods). Forward referencing of 
stream names, as shown below, is not allowed:
    +
    +```java
    +new JoinBolt( "spout1", "key1")                 
    +  .join     ( "spout2", "userId",  "spout3") //not allowed. spout3 not yet 
introduced
    +  .join     ( "spout3", "key3",    "spout1")
    +```
    +
    +2. Internally, the joins will be performed in the order expressed by the 
user.
    --- End diff --
    
    Its showing up as 1. in the rich diff mode.


---
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.
---

Reply via email to