Beispiel #1
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);
 }
Beispiel #2
0
 // Enqueue the Tweets received
 public void WriteTweet(TweetSentimentData tweet)
 {
     lock (this.WriteQueue)
     {
         this.WriteQueue.Enqueue(tweet);
     }
 }
Beispiel #3
0
 // Enqueue the Tweets received
 public void WriteTweet(TweetSentimentData tweet)
 {
     lock (this.WriteQueue)
     {
         this.WriteQueue.Enqueue(tweet);
     }
 }
Beispiel #4
0
 private static void ReceiveTweet(object sender, TweetReceivedEventArgs args)
 {            
     if(hbaseWriter != null)
     {
         TweetSentimentData data = new TweetSentimentData(args.Tweet);
         hbaseWriter.WriteTweet(data);
         Console.WriteLine(args.Tweet.Text);
     }
 }
Beispiel #5
0
 private static void ReceiveTweet(object sender, TweetReceivedEventArgs args)
 {
     if (hbaseWriter != null)
     {
         TweetSentimentData data = new TweetSentimentData(args.Tweet);
         hbaseWriter.WriteTweet(data);
         Console.WriteLine(args.Tweet.Text);
     }
 }
Beispiel #6
0
 // Write a Tweet (CellSet) to HBase
 public void WriterThreadFunction()
 {
     while (ThreadRunning)
     {
         if (WriteQueue.Count > 0)
         {
             CellSet set = new CellSet();
             lock (WriteQueue)
             {
                 do
                 {
                     TweetSentimentData tweet = WriteQueue.Dequeue();
                     CreateTweetByWordsCells(set, tweet);
                 } while (WriteQueue.Count > 0);
             }
             // Write the Tweet by words cell set to the HBase table
             client.StoreCells(this.HBaseTableName, set);
             Console.WriteLine("\tRows written: {0}", set.rows.Count);
         }
     }
 }
Beispiel #7
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);
        }