Beispiel #1
0
        public void TestCbIndex(bool shortHash = false, int indexKeyLength = 2)
        {
            int hashLength = shortHash ? 6 : 16;//16 bytes to simulate MD5 which is a common usage but could be any length key
            var cbIndex    = new CbIndex("memtest.index", 2, true);
            var r          = new Random(DateTime.UtcNow.Millisecond);

            Dictionary <ushort, byte[]> dummyData = new Dictionary <ushort, byte[]>();

            var maxKeys = (ushort)0;

            maxKeys = (ushort)~maxKeys;

            for (ushort i = 0; i < maxKeys; i++)
            {
                var buf = new byte[hashLength];
                r.NextBytes(buf);
                //replace the first part of the key with sequential nums. e.g. 0x00, 0x01, 0x02
                //and leave the rest random nums to simulate real-world usage.
                buf[^ 1]     = (byte)(i >> 8);
Beispiel #2
0
        IEnumerable <KeyValuePair <HashBin, byte[]> > GenerateDummyData(ushort keyLength, byte indexKeyLength)
        {
            //create some data that we can repeat later for verification
            //we need multiple items in each key space (index key length)
            //e.g.
            //0x0000ffffffffffffffffffffffffffff, 0x0001ffffffffffffffffffffffffffff .. etc
            //0x00000000000000000000000000000000, 0x00010000000000000000000000000000 .. etc
            //0x0000aaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x0001aaaaaaaaaaaaaaaaaaaaaaaaaaaa .. etc
            //0x00009999999999999999999999999999, 0x00019999999999999999999999999999 .. etc

            var numIndexes = CbIndex.MaxIndexesForIndexLength(indexKeyLength);

            string keyspaces = "0123456789abcdef";

            // var debugHashBin = new HashBin("0000000000000000000000000000d8f4");
            foreach (var keyspace in keyspaces)
            {
                var indexBuf = new byte[indexKeyLength];

                for (int i = 0; i < numIndexes; i++)
                {
                    var pattern = new HashBin("".PadLeft(32, keyspace));
                    //set index on key
                    Array.Copy(indexBuf, 0, pattern.Hash, pattern.Hash.Length - indexBuf.Length, indexBuf.Length);
                    //
                    // if (pattern == debugHashBin)
                    // {
                    //     Console.WriteLine("DebugMe");
                    // }

                    //send it
                    var dummyDat = new DummyData("This is your dummy data", indexBuf, pattern.Hash);
                    yield return(new KeyValuePair <HashBin, byte[]>(pattern, dummyDat.ToJsonBytes()));

                    //increment index bytes
                    IncrementBuf(indexBuf);
                }
            }
        }
        /// <summary>
        /// Lets you select/deselect one of the CheckBoxes with a enum indexer.
        /// </summary>
        /// <param name="index"></param>
        /// <param name="flag"></param>
        public void SelectCheckBox(CbIndex index, bool flag)
        {
            _checkBoxes[(int)index].Checked = flag;

            switch ((int)index)
            {
            case 0:
                ValidateCheckBox1();
                break;

            case 1:
                ValidateCheckBox2();
                break;

            case 2:
                ValidateCheckBox3();
                break;

            case 3:
                ValidateCheckBox4();
                break;
            }
        }