Beispiel #1
0
 // Enqueue the Tweets received
 public void WriteTweet(TweetSentimentData tweet)
 {
     lock (this.WriteQueue)
     {
         this.WriteQueue.Enqueue(tweet);
     }
 }
Beispiel #2
0
 // Popular a CellSet object to be written into HBase
 private void CreateTweetByWordsCells(CellSet set, TweetSentimentData tweet)
 {
     // Create a row with a key
     var row = new CellSet.Row { key = Encoding.UTF8.GetBytes(tweet.Id) };
     // Add columns to the row
     row.values.Add(
         new Cell
         {
             column = Encoding.UTF8.GetBytes("d:Text"),
             data = Encoding.UTF8.GetBytes(tweet.Text)
         });
     row.values.Add(
         new Cell
         {
             column = Encoding.UTF8.GetBytes("d:CreatedOn"),
             data = Encoding.UTF8.GetBytes(tweet.CreatedOn.ToString())
         });
     row.values.Add(
         new Cell
         {
             column = Encoding.UTF8.GetBytes("d:ReplyToId"),
             data = Encoding.UTF8.GetBytes(tweet.ReplyToId)
         });
     row.values.Add(
         new Cell
         {
             column = Encoding.UTF8.GetBytes("d:Sentiment"),
             data = Encoding.UTF8.GetBytes(tweet.Sentiment.ToString())
         });
     if (tweet.Coordinates != null)
     {
         row.values.Add(
             new Cell
             {
                 column = Encoding.UTF8.GetBytes("d:Coordinates"),
                 data = Encoding.UTF8.GetBytes(tweet.Coordinates)
             });
     }
     set.rows.Add(row);
 }