Esempio n. 1
0
 private static void RemoveTestAssert(PersistentHashTable hashTable, int valueSize, byte[] key)
 {
     hashTable.Put(key, new byte[valueSize]);
     hashTable.Remove(key);
     try
     {
         hashTable.Get(key);
     }
     catch (KeyNotFoundException) {}
 }
Esempio n. 2
0
        public void ReopenTest()
        {
            string hastTableName          = "ReopenHashTableTest";
            PersistentHashTable hashTable = InitTable(hastTableName, 20, 4, 4, 6);

            try
            {
                byte[] key   = new byte[] { 4, 4, 4, 4 };
                byte[] value = new byte[] { 5, 5, 5, 5 };
                hashTable.Put(key, value);
                hashTable.Close();

                hashTable = new PersistentHashTable(hastTableName);

                TestHelper.AssertByteArraysAreSame(value, hashTable.Get(key));
            }
            finally
            {
                hashTable.Close();
            }
        }
Esempio n. 3
0
        public void PutGetCollisionsTest()
        {
            const string        tableName      = "HashTablePutCollisions";
            const int           tableSize      = 20;
            const int           keySize        = 4;
            const int           valueSize      = 4;
            const int           userHeaderSize = 6;
            PersistentHashTable hashTable      = InitTable(tableName, tableSize, keySize, valueSize, userHeaderSize);

            try
            {
                //fill the table up with collisions
                byte[] lastCollisionKey = FillTableWithCollisions(5, hashTable);

                TestHelper.AssertByteArraysAreSame(new byte[] { 0, 0, 0, tableSize - 1 }, hashTable.Get(lastCollisionKey));
            }
            finally
            {
                hashTable.Close();
            }
        }
Esempio n. 4
0
 private static void PutGetTestAssert(PersistentHashTable hashTable, byte[] key, byte[] value)
 {
     hashTable.Put(key, value);
     byte[] actual = hashTable.Get(key);
     TestHelper.AssertByteArraysAreSame(value, actual);
 }