public static void ReadData() { string host = "localhost"; using (RedisClient redisClient = new RedisClient(host)) { StreamReader sr = new StreamReader(DataPath); Console.WriteLine("开始读取原数据"); var locDic = new Dictionary<string, int>(); var sw = new Stopwatch(); sw.Start(); string s = sr.ReadLine(); long i = 0; while (s != null) { if (i % 10000 == 0) Console.WriteLine("已读取数据量:" + i); var sData = s.Split('\t'); var dateSplit = sData[4].Split(':'); int min = int.Parse(dateSplit[1]); min = (min / 5) * 5; var locate = sData[6]; string key = string.Format("{0}:{1:D2}@{2}", dateSplit[0], min, locate); redisClient.Incr(key); locDic[locate] = 0; s = sr.ReadLine(); i++; } locDic.Keys.ToList().ForEach(p => { redisClient.ZAdd("AllLocates", 0, System.Text.Encoding.UTF8.GetBytes(p)); }); sw.Stop(); Console.WriteLine("读取完毕,总数据量:" + i + ",时间:" + sw.ElapsedMilliseconds + " ms"); } }