FieldGrouping on Multiple Bolts

874 views
Skip to first unread message

anahap

unread,
Jan 11, 2012, 10:34:15 AM1/11/12
to storm-user
Hi,


If I have multiple Bolts A and multiple Bolts B (with different
classes A.class and B.class) and I create the following grouping for
Bolt C:

C.fieldsGrouping("A", new Fields("my_field_name")).fieldsGrouping("B",
new Fields("my_field_name"))


will ALL tuples from A AND B that contain the field
my_field_name="zzz" go to the same instance of bolt C, or will they be
grouped by the source bolt?


TIA

Ben Hughes

unread,
Jan 11, 2012, 12:21:01 PM1/11/12
to storm-user
Yes. The task that a tuple goes to is determined by the hashcode of
the fields in the grouping modulo the number of tasks in that bolt.
As long as all fields in the fields grouping are the same and they
return sensible, value based hashcodes, everything will work fine.

The code that handles the grouping is like 5 lines and kind of neat:
https://github.com/nathanmarz/storm/blob/master/src/clj/backtype/storm/daemon/task.clj#L9-13

Ben

Nathan Marz

unread,
Jan 12, 2012, 4:29:31 AM1/12/12
to storm...@googlegroups.com
Just to make sure what Ben is saying is clear, in a fields grouping a grouping value will always go to the same consumer task, regardless of the source. Otherwise things like joins of different streams would not be possible. 
--
Twitter: @nathanmarz
http://nathanmarz.com

ivolo

unread,
Apr 26, 2012, 4:55:36 PM4/26/12
to storm...@googlegroups.com
In the exact example given above, can the two fields grouping have different stream Ids (or do they have to have the same one) if you want the same "my_field_name" to go to the same task regardless whether its sent from Bolt A or Bolt B?

Nathan Marz

unread,
Apr 28, 2012, 5:12:06 AM4/28/12
to storm...@googlegroups.com
Yes they can have different stream ids. The fields grouping equation is hash(subset of tuple fields) % number of consumer tasks. So all that matters is the values of the fields being grouped on.

invader zim

unread,
Mar 14, 2013, 10:11:30 AM3/14/13
to storm...@googlegroups.com
Check the docs :
 
 
Cheers,
Zim

On Thursday, 14 March 2013 07:28:57 UTC, Ryan Santos wrote:

Hi, 
I am very new here, I am just wondering how can I assign Stream ids to fieldGrouping? 
Reply all
Reply to author
Forward
0 new messages