??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????socket??????????????????л???Щ???????????????????????????????????洢?????????????в???????????????2???????????

????Url.db?洢????????????????Url.idx ?洢???????????????????????λ???Begin???????Length?????????Щ?????????Hits??DateTime????????????????????????????????????Append?????????????????????????????????GB????????????IO?????
?????????Url.idx????????ID???????????Int64??????????????????????8?????????Begin??????????????????д??Url.db???????Url.db???????????????Int64??????????????????????????Int16????????Int16.MaxValue==65536????Url?淶?????4Kb???????Int16???????????????2????Hits??????????????????????Int32?????????4??DateTime ???Int64??????8??????ID????????????????????????????????????????????д??Url.idx???????????????У???????????????30?????е??ID????????????д???μ???С?
????????????????????????????????ж??????????65536??????Url.idx ???????????? 30 ????
????????????????????????????????????ü????????????????????????????????????????http://????/1000????http://????/1001???????????a???????????ID?????????????????????????????????????????????????10???????????????????????100???????????????????????????????????塣
??????????濪???ID???и?????????????2??
????1??????????????????????ID???????????????
????2???????????????????100???????????ID??????????????仯??
?????????????????????10????????62?????0-9a-zA-Z????????????abcdef…???????μ??????ID?????62????????????????????Σ?
????/// <summary>
????/// ?????????0-9a-zA-Z?????
????/// </summary>
????/// <returns></returns>
????public static string GenerateKeys()
????{
????string[] Chars = "0??1??2??3??4??5??6??7??8??9??A??B??C??D??E??F??G??H??I??J??K??L??M??N??O??P??Q??R??S??T??U??V??W??X??Y??Z??a??b??c??d??e??f??g??h??i??j??k??l??m??n??o??p??q??r??s??t??u??v??w??x??y??z".Split('??');
????int SeekSeek = unchecked((int)DateTime.Now.Ticks);
????Random SeekRand = new Random(SeekSeek);
????for (int i = 0; i < 100000; i++)
????{
????int r = SeekRand.Next(1?? Chars.Length);
????string f = Chars[0];
????Chars[0] = Chars[r - 1];
????Chars[r - 1] = f;
????}
????return string.Join(""?? Chars);
????}
??????????????????????????????У?
????string Seq = "s9LFkgy5RovixI1aOf8UhdY3r4DMplQZJXPqebE0WSjBn7wVzmN2Gc6THCAKut";
?????????????????????0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ?????к???????????????10???????????????????????62????????????????????????????
????/// <summary>
????/// 10????????62????
????/// </summary>
????/// <param name="id"></param>
????/// <returns></returns>
????private static string Convert(long id)
????{
????if (id < 62)
????{
????return Seq[(int)id].ToString();
????}
????int y = (int)(id % 62);
????long x = (long)(id / 62);
????return Convert(x) + Seq[y];
????}
????/// <summary>
????/// ??62??????10????
????/// </summary>
????/// <param name="Num"></param>
????/// <returns></returns>
????private static long Convert(string Num)
????{
????long v = 0;
????int Len = Num.Length;
????for (int i = Len - 1; i >= 0; i--)
????{
????int t = Seq.IndexOf(Num[i]);
????double s = (Len - i) - 1;
????long m = (long)(Math.Pow(62?? s) * t);
????v += m;
????}
????return v;
????}
??????????? Convert(123456789) ??? RYswX????? Convert(123456790) ??? RYswP??
???????????????????????????????????????????????Seq????????????2????ID???????????????????????????????ID??ε??????λ????????1???????????????????1000??1005??1013??1014??1020?????????????
????private static Int16 GetRnd(Random seekRand)
????{
????Int16 s = (Int16)seekRand.Next(1?? 11);
????return s;
????}
?????????62??????????????10?????ID????????2????????????????????????????????????????????????????????2??62???????????RyswX??RyswP??????λ?????????????????????????е????μ??????????62??????????????????????????????????????????????????
????/// <summary>
????/// ????id??????
????/// </summary>
????/// <param name="id"></param>
????/// <returns></returns>
????private static string Mixup(long id)
????{
????string Key = Convert(id);
????int s = 0;
????foreach (char c in Key)
????{
????s += (int)c;
????}
????int Len = Key.Length;
????int x = (s % Len);
????char[] arr = Key.ToCharArray();
????char[] newarr = new char[arr.Length];
????Array.Copy(arr?? x?? newarr?? 0?? Len - x);
????Array.Copy(arr?? 0?? newarr?? Len - x?? x);
????string NewKey = "";
????foreach (char c in newarr)
????{
????NewKey += c;
????}
????return NewKey;
????}
????/// <summary>
????/// ???????????
????/// </summary>
????/// <param name="Key"></param>
????/// <returns></returns>
????private static long UnMixup(string Key)
????{
????int s = 0;
????foreach (char c in Key)
????{
????s += (int)c;
????}
????int Len = Key.Length;
????int x = (s % Len);
????x = Len - x;
????char[] arr = Key.ToCharArray();
????char[] newarr = new char[arr.Length];
????Array.Copy(arr?? x?? newarr?? 0?? Len - x);
????Array.Copy(arr?? 0?? newarr?? Len - x?? x);
????string NewKey = "";
????foreach (char c in newarr)
????{
????NewKey += c;
????}
????return Convert(NewKey);
????}
??????? Mixup(123456789)???wXRYs???????????????7??????????????ID??? Mixup(123456796)???swWRY???????????????????????ID?????????
????????????????????ID?????????????潲????????????????????
?????????????????wXRYs????????????????????UnMixup()??????????????ID???????ID????????????1????????????????ID?????????????????????е?λ????磺ID * 30????????ID???С???????????У??????????????ж?λID???????????ī???
????//???????????????????
????FileStream Index = new FileStream(IndexFile?? FileMode.OpenOrCreate?? FileAccess.ReadWrite);
????long Id =;//?????????????????ID
????long Left = 0;
????long Right = (long)(Index.Length / 30) - 1;
????long Middle = -1;           
????while (Left <= Right)
????{
????Middle = (long)(Math.Floor((double)((Right + Left) / 2)));
????if (Middle < 0) break;
????Index.Position = Middle * 30;
????Index.Read(buff?? 0?? 8);
????long val = BitConverter.ToInt64(buff?? 0);
????if (val == Id) break;               
????if (val < Id)
????{
????Left = Middle + 1;
????}
????else
????{
????Right = Middle - 1;
????}
????}      
????Index.Close();
????????????????????????????????м??8????????????????????ID???????????????????????????????н??43??????????????????????ID???????????32??????????while???32?Σ??????????????2^32=4294967296??
??????????????????????????????????????????????????????1???????????????? ID*30 ????????λ??????????е?λ?á?