In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to talk to you about the use of Fields in Storm. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.
TransactionalTopologyBuilder builder = new TransactionalTopologyBuilder ("test", "spout", new TweetsTransactionalSpout ()); builder.setBolt ("users-splitter", new UserSplitterBolt (), 4). ShuffleGrouping ("spout"); builder.setBolt ("hashtag-splitter", new HashtagSplitterBolt (), 4). ShuffleGrouping ("spout") Builder.setBolt ("user-hashtag-merger", new UserHashtagJoinBolt (), 4) .fieldsGrouping ("users-splitter", "users", new Fields ("tweet_id")) .fieldsGrouping ("hashtag-splitter", "hashtags", new Fields ("tweet_id"))
Here are two bolt sending data to user-hashtag-merger. The two bolt may send different tuple when they are in emit, for example:
Emit (new Values (a, b, c)) in users-splitter; declarer.declare (new Fields ("id", "name", "tweet_id"))
In hashtag-splitter, emit (new Values (a, b)); declarer.declare (new Fields ("id", "tweet_id"))
For example, what is needed in user-hashtag-merger is b in users-splitter, and b in user-hashtag-merger.
When receiving data in, it is impossible to know which bolt sent the data (or even if it does, it is not a good design to send the data in a different format), so here is a
Fields, so that when sending data, only the data of the specified Fields is sent, for example, when the user-hashtag-merger here is regardless of the previous bolt emit
What was sent, only one was received at last, which is convenient to deal with.
Builder.setBolt ("redis-committer", new RedisCommiterCommiterBolt ()) .globalGrouping ("users-splitter", "users") .globalGrouping ("hashtag-splitter", "hashtags") .globalGrouping ("user-hashtag-merger"). After reading the above, do you have any further understanding of the use of Fields in Storm? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.