I have real time data which is handled by storm topology. Data can be in of four types let's say A, B, C, D. Each of this data is consumed by bolt in random order. What I need to do is to compare two tuples of same data type. Example, I want to compare type A tuple with next type A tuple or lets say compare current type A tuple with previously received type A tuple. Is there a way to do this in bolt? Or I have to save the previous result somewhere in database (let's say hbase or cache) and query it to compare with current tuple of particular type.
EDIT
Lets say stream of data of type A, B, C, D is coming from spout
B4 A4 C7 D2 A3 A2 B3 C6 D1 B2 C5 C4 B1 C3 C2 C1 A1-----> Spout --> BOLT
Now at bolt I want to compare A1 with A2, A2 with A3, A3 with A4. Similarly B1 with B2, B2 with B3 etc.