Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Building Python Real time Applications with Storm

You're reading from   Building Python Real time Applications with Storm Learn to process massive real-time data streams using Storm and Python—no Java required!

Arrow left icon
Product type Paperback
Published in Dec 2015
Publisher
ISBN-13 9781784392857
Length 122 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

Finding the top n ranked topics using Redis

The topology will compute a rolling ranking of the most popular words in the past 5 minutes. The word counts are stored in individual windows of 60 seconds in length. It consists of the following components:

  • Twitter stream spout (twitterstream.py): This reads tweets from the Twitter sample stream. This spout is unchanged from Chapter 4, Example Topology – Twitter.
  • Splitter bolt (splitsentence.py): This receives tweets and splits them into words. This is also identical to the one in Chapter 4, Example Topology – Twitter.
  • Rolling word count bolt (rollingcount.py): This receives words and counts the occurrences. The Redis keys look like twitter_word_count:<start time of current window in seconds>, and the values are stored in a hash using the following simple format:
    {
        "word1": 5,
        "word2", 3,
    }

    This bolt uses the Redis expireat command to discard old data after 5 minutes. These lines of code perform the...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image