static void RunWordTest() { const int KeyLength = 16; const uint iSlaveCount = 1; const uint iZblocksPerSlave = 113; List <List <byte> > samples = new List <List <byte> >(1000); foreach (string part in MySpaceText.Split('\n')[0].Split(' ')) // Sample from first line. { string word = part.Trim(WordTrimChars).ToLower(); if (0 != word.Length) { List <byte> key = new List <byte>(KeyLength); key.AddRange(Encoding.ASCII.GetBytes(word.PadRight(KeyLength, '\0'))); samples.Add(key); } } MdoDistro pCRangeEstimator = new MdoDistro(samples, iSlaveCount, iZblocksPerSlave); { Dictionary <string, List <GlyphNode> > results = new Dictionary <string, List <GlyphNode> >(); List <Word> words = new List <Word>(1000); foreach (string part in MySpaceText.Split(' ', '\n')) { string word = part.Trim(WordTrimChars).ToLower(); if (0 != word.Length) { List <byte> key = new List <byte>(KeyLength); key.AddRange(Encoding.ASCII.GetBytes(word.PadRight(KeyLength, '\0'))); GlyphNode pRangeItem = pCRangeEstimator.Distro(key); if (pRangeItem.iMajorId >= iSlaveCount) { throw new Exception("pRangeItem.iMajorId >= iSlaveCount"); } if (pRangeItem.iMinorId >= iZblocksPerSlave) { throw new Exception("pRangeItem.iMinorId >= iZblocksPerSlave"); } Word w = new Word(); w.word = word; w.range = pRangeItem; words.Add(w); string sExchangePath = @"" + pRangeItem.iMajorId.ToString() + @"_" + pRangeItem.iMinorId + ""; if (!results.ContainsKey(sExchangePath)) { results[sExchangePath] = new List <GlyphNode>(); } results[sExchangePath].Add(pRangeItem); } } words.Sort(); int i333 = 33 + 33; { Console.WriteLine("Testing WordTest..."); int lastmajor = 0; int lastminor = 0; for (int i = 0; i < words.Count; i++) { if (words[i].word == "create") { int i3323 = 33 + 33; } if (words[i].range.iMajorId < lastmajor) { throw new Exception("Whoops!"); } if (words[i].range.iMajorId != lastmajor) { lastminor = 0; } if (words[i].range.iMinorId < lastminor) { while (true) { GlyphNode ppRangeItem1 = pCRangeEstimator.Distro("create".PadRight(16, '\0')); GlyphNode ppRangeItem2 = pCRangeEstimator.Distro("day".PadRight(16, '\0')); GlyphNode ppRangeItem3 = pCRangeEstimator.Distro("decide".PadRight(16, '\0')); int i23zzz = 23 + 23; } throw new Exception("Whoops!"); } lastmajor = words[i].range.iMajorId; lastminor = words[i].range.iMinorId; } Console.WriteLine("Done with WordTest!"); } { Console.WriteLine("Testing WordTest..."); byte last = 0; byte lastn = 0; for (int major = 0; major < iSlaveCount; major++) { for (int minor = 0; minor < iZblocksPerSlave; minor++) { string key = major.ToString() + "_" + minor.ToString(); if (results.ContainsKey(key)) { results[key].Sort(new cmprGlyphNode()); for (int ig = 0; ig < results[key].Count; ig++) { byte current = results[key][ig].leaf_word_ref[0]; byte currentn = results[key][ig].leaf_word_ref[1]; if (current < last) { throw new Exception("Whoops"); } if (current != last) { lastn = 0; } if (currentn < lastn) { throw new Exception("Whoops"); } last = current; lastn = currentn; } } } } Console.WriteLine("Done with WordTest!"); } int i2233zz = 23 + 23; } }
static void Main(string[] args) { RunWordTest(); List <List <byte> > samples = MdoDistro.GenerateRandomSamples_DenseInLowValues(100000, 0); uint iSlaveCount = 31; uint iZblocksPerSlave = 113; MdoDistro pCRangeEstimator = new MdoDistro(samples, iSlaveCount, iZblocksPerSlave); Random rnd = new Random(); long total_major = 0; long total_minor = 0; List <List <int> > lii = new List <List <int> >((int)iSlaveCount); for (int i = 0; i < iSlaveCount; i++) { List <int> ilist = new List <int>((int)iZblocksPerSlave); lii.Add(ilist); for (int j = 0; j < iZblocksPerSlave; j++) { ilist.Add(0); } } Dictionary <string, List <GlyphNode> > results = new Dictionary <string, List <GlyphNode> >(); for (int i = 0; i < 100000; i++) { GlyphNode pRangeItem = pCRangeEstimator.Distro(samples[rnd.Next(0, samples.Count)]); if (pRangeItem.iMajorId >= iSlaveCount) { throw new Exception("pRangeItem.iMajorId >= iSlaveCount"); } if (pRangeItem.iMinorId >= iZblocksPerSlave) { throw new Exception("pRangeItem.iMinorId >= iZblocksPerSlave"); } string sExchangePath = @"" + pRangeItem.iMajorId.ToString() + @"_" + pRangeItem.iMinorId + ""; total_major += pRangeItem.iMajorId; total_minor += pRangeItem.iMinorId; lii[pRangeItem.iMajorId][pRangeItem.iMinorId]++; if (!results.ContainsKey(sExchangePath)) { results[sExchangePath] = new List <GlyphNode>(); } results[sExchangePath].Add(pRangeItem); } double majorpercent = ((double)(total_major / 100000)) / iSlaveCount; double minorpercent = ((double)(total_minor / 100000)) / iZblocksPerSlave; { Console.WriteLine("Testing..."); byte last = 0; byte lastn = 0; for (int major = 0; major < iSlaveCount; major++) { for (int minor = 0; minor < iZblocksPerSlave; minor++) { string key = major.ToString() + "_" + minor.ToString(); if (results.ContainsKey(key)) { results[key].Sort(new cmprGlyphNode()); for (int ig = 0; ig < results[key].Count; ig++) { byte current = results[key][ig].leaf_word_ref[0]; byte currentn = results[key][ig].leaf_word_ref[1]; if (current < last) { throw new Exception("Whoops"); } if (current != last) { lastn = 0; } if (currentn < lastn) { throw new Exception("Whoops"); } last = current; lastn = currentn; } } } } Console.WriteLine("Done with test!"); } int i2233zz = 23 + 23; }