1

I am trying to create a sentiment indicator with a Redis state. Here is my code:

TweetSpout twitterSpout = new TweetSpout();
Stream textStream = topology.newStream("tweetSpout", twitterSpout);
        textStream.each(new Fields("texto"), new TwitterSentimentClassifier(), new Fields("sentiment","date"))
       .each(new Fields("sentiment","date"),new Union(), new Fields("key"))
       .groupBy(new Fields("key"))
       .persistentAggregate(state, new Count(), new Fields("count"))
       .parallelismHint(6);

Basically, I receive a tweet, and I classify the tweet with the TwitterSentimentClassifier function into positive or negative, and I obtain the date, too. Then, the Union function concatenate the feeling and the date (e.g. positive2014.15.05), in order to have one key (I'm doing this because Trident-Redis only allow one key). Next, Trident groups by the key. Finally, .persistentAggregate persists the counts per keys in a Redis database. This works fine.

But now, I want to show this indicator in a node.js application connected with Redis.

Indicator today = Number of tweets negatives today /Total of tweets today

So, I was wondering:

  • Should I use a DRCP call with a state query?
  • Do i have to use another persistent aggregator in order to store the indicator value?
  • Do I have to create a Trident function to store the indicator value in a Redis db?
  • I am going to use Node.js, socket.io, express and d3.js for the visualization. Can I use a normal division operation in Javascript with my actual Redis state?
4

0 回答 0