public void WriteConversation(FSConversation convo) { CellSet.Row row = TableDomainMappers.ConversationToRow(convo); CellSet set = new CellSet(); set.rows.Add(row); HadoopContext.HBaseClient.StoreCells(HadoopContext.ConversationTableName, set); Thread.Sleep(100); }
public static CellSet.Row ConversationToRow(FSConversation convo) { var row = new CellSet.Row { key = Encoding.UTF8.GetBytes(convo.Id) }; // Add columns to the row for (int i = 0; i < convo.Tweets.Count(); i++) { row.values.Add( new Cell { column = Encoding.UTF8.GetBytes("d:TweetId_" + i.ToString()), data = Encoding.UTF8.GetBytes(convo.Tweets.ElementAt(i).Id) }); } return(row); }
private static IEnumerable <FSConversation> PopulateConversationsFromFile(string fileLocation) { List <FSConversation> conversations = new List <FSConversation>(); var data = File.ReadAllLines(fileLocation); TwitterCredentials.SetCredentials( ConfigurationManager.AppSettings["AccessToken"], ConfigurationManager.AppSettings["AccessSecret"], ConfigurationManager.AppSettings["ConsumerKey"], ConfigurationManager.AppSettings["ConsumerSecret"]); #region getdata foreach (string s in data) { var tweetTriplet = s.Split("\t".ToCharArray()); List <FSTweet> tweets = new List <FSTweet>(); foreach (string tweetId in tweetTriplet) { long id = long.Parse(tweetId); var t = Tweetinvi.Tweet.GetTweet(id); if (t != null) { var ptTweet = InviTweetToPTTweet(t); tweets.Add(ptTweet); } } if (tweets.Count > 0) { FSConversation c = new FSConversation(); Guid g = Guid.NewGuid(); c.Id = g.ToString(); c.Tweets = tweets; conversations.Add(c); PTHBaseWriter writer = new PTHBaseWriter(); writer.WriteConversation(c); } } #endregion getdata return(conversations); }
private static IEnumerable<FSConversation> PopulateConversationsFromFile(string fileLocation) { List<FSConversation> conversations = new List<FSConversation>(); var data = File.ReadAllLines(fileLocation); TwitterCredentials.SetCredentials( ConfigurationManager.AppSettings["AccessToken"], ConfigurationManager.AppSettings["AccessSecret"], ConfigurationManager.AppSettings["ConsumerKey"], ConfigurationManager.AppSettings["ConsumerSecret"]); #region getdata foreach (string s in data) { var tweetTriplet = s.Split("\t".ToCharArray()); List<FSTweet> tweets = new List<FSTweet>(); foreach(string tweetId in tweetTriplet) { long id = long.Parse(tweetId); var t = Tweetinvi.Tweet.GetTweet(id); if (t != null) { var ptTweet = InviTweetToPTTweet(t); tweets.Add(ptTweet); } } if(tweets.Count > 0) { FSConversation c = new FSConversation(); Guid g = Guid.NewGuid(); c.Id = g.ToString(); c.Tweets = tweets; conversations.Add(c); PTHBaseWriter writer = new PTHBaseWriter(); writer.WriteConversation(c); } } #endregion getdata return conversations; }
public static CellSet.Row ConversationToRow(FSConversation convo) { var row = new CellSet.Row { key = Encoding.UTF8.GetBytes(convo.Id) }; // Add columns to the row for (int i = 0; i < convo.Tweets.Count(); i++ ) { row.values.Add( new Cell { column = Encoding.UTF8.GetBytes("d:TweetId_"+i.ToString()), data = Encoding.UTF8.GetBytes(convo.Tweets.ElementAt(i).Id) }); } return row; }