public void RecursiveGetUser(string uid, int gen) { gen++; var result = ThriftTool.GetSingleKey(ThriftTool.ToByte(uid), "M01UserRelaction", 5000); var node = new RelactionNode { id = uid, weight = result.Count }; if (!NodeList.Contains(node)) { NodeList.Add(node); //add new node NodeStringList.Add(uid); } if (gen >= 4) { return; } foreach (var ks in result) { var target = ThriftTool.ToString(ks.Counter_column.Name); var weight = (int)ks.Counter_column.Value; var edge = new RelactionEdge { id = uid + "_" + target, source = uid, target = target, weight = weight }; EdgeList.Add(edge); if (!NodeStringList.Contains(target)) { RecursiveGetUser(target, gen); } } }
public List <string> BahaGetDayList(string mode) { var result = new List <string>(); var client = ThriftTool.GetClient("default", ref _transport); CqlResult cqlResult = client.execute_cql_query(ThriftTool.ToByte("select first 30 Date from BahamutDays where Mode='" + mode + "'"), Compression.NONE); foreach (CqlRow t in cqlResult.Rows) { foreach (var col in t.Columns) { var name = ThriftTool.ToString(col.Name); switch (name) { case "Date": result.Add(ThriftTool.ToString(col.Value)); break; } } } ThriftTool.TransportClose(ref _transport); result.Sort(); return(result); }
static void Check2NodeValue(string n1, string n2, long val) { if (n1 == n2) { return; } var secondVal = ThriftTool.GetSingleCounter(ThriftTool.ToByte(n2), "M01UserRelaction", n1); var org1 = n1; var org2 = n2; //save N1>N2 if (Int32.Parse(n2) > Int32.Parse(n1)) { Utility.Swap(ref n1, ref n2); } var key = n1 + "_" + n2; var sum = val + secondVal; Utility.Logging("\tKey: " + key, Utility.DebugLevel.Info); Utility.Logging("\tsecondVal: " + secondVal, Utility.DebugLevel.Info); Utility.Logging("\tsum: " + sum, Utility.DebugLevel.Info); Utility.Logging("\t" + org1 + ">" + org2 + ": " + val, Utility.DebugLevel.Info); Utility.Logging("\t" + org2 + ">" + org1 + ": " + secondVal, Utility.DebugLevel.Info); //ThriftTool.CounterAdd(key, "M01UserRelactionN2", "sum", val + secondVal); //ThriftTool.CounterAdd(key, "M01UserRelactionN2", org1 + " > " + org2, val); //ThriftTool.CounterAdd(key, "M01UserRelactionN2", org2 + " > " + org1, secondVal); }
static long Get2NodeValue(string n1, string n2) { if (int.Parse(n2) > int.Parse(n1)) { Utility.Swap(ref n1, ref n2); } return(ThriftTool.GetSingleCounter(ThriftTool.ToByte(n1 + "_" + n2), "M01UserRelactionN2", "sum")); }
public HighChart[] BahaGetOneGame(string game, string startDate, string endDate) { var gameList = game.Split(','); var chartList = new HighChart[gameList.Length]; var client = ThriftTool.GetClient("default", ref _transport); for (var i = 0; i < gameList.Length; i++) { var rank = new List <ScoreList>(); CqlResult cqlResult = client.execute_cql_query(ThriftTool.ToByte("select * from BahamutGames where Title='" + gameList[i] + "'"), Compression.NONE); foreach (CqlRow t in cqlResult.Rows) { var rl = new ScoreList(); foreach (var col in t.Columns) { var name = ThriftTool.ToString(col.Name); switch (name) { case "Title": rl.Title = ThriftTool.ToString(col.Value); break; case "Link": rl.Link = ThriftTool.ToString(col.Value); break; case "Article": rl.Article = ThriftTool.ToString(col.Value); break; case "Popular": rl.Popular = ThriftTool.ToString(col.Value); break; case "Date": rl.Date = ThriftTool.ToInt(col.Value); break; } } rank.Add(rl); } var ranks = from n in rank orderby n.Date select n; chartList[i] = ParseToHighChart(ranks); } ThriftTool.TransportClose(ref _transport); return(chartList); }
/// <summary> /// 取得Baha單日資料 /// </summary> /// <param name="key">日期</param> /// <param name="columnFamily">CF name (BahamutOnline,BahamutAll)</param> /// <returns></returns> public IOrderedEnumerable <RankList> BahaGetOneDay(string key, string columnFamily) { var rank = new List <RankList>(); var lb = new List <byte[]> { ThriftTool.ToByte(key) }; Dictionary <byte[], List <ColumnOrSuperColumn> > results = Client.multiget_slice(lb, ThriftTool.GetParent(columnFamily), ThriftTool.GetPredicate(100), ConsistencyLevel.ONE); if (results.Count > 0) //if have result { foreach (var result in results) { foreach (var scol in result.Value) { if (scol.GetType() == typeof(ColumnOrSuperColumn)) { var rl = new RankList(); foreach (var col in scol.Super_column.Columns) { string name = ThriftTool.ToString(col.Name); if (name == "Title") { rl.Title = ThriftTool.ToString(col.Value); } if (name == "Rank") { rl.Rank = int.Parse(ThriftTool.ToString(col.Value)); } if (name == "Article") { rl.Article = ThriftTool.ToString(col.Value); } if (name == "Link") { rl.Link = ThriftTool.ToString(col.Value); } if (name == "Popular") { rl.Popular = ThriftTool.ToString(col.Value); } if (name == "Date") { rl.Date = DateTime.Parse(ThriftTool.ToString(col.Value)); } if (name == "Change") { rl.Change = ThriftTool.ToString(col.Value); } } rank.Add(rl); } } } } ThriftTool.TransportClose(); var ranks = from n in rank orderby n.Rank select n; return(ranks); }