2
Vote

Remove key from index, but not acutally mark delete flag in data file

description

var db = RaptorDB<string>.Open(_Path + "strings", 255, false);
...
        for (int i = 0; i < trials; i++)
        {
            db.Set("asdfasd" + i, "" + i);
        }
....
        int removes = trials / 2;
        for (int i = 0; i < removes; i++)
        {
            if (!db.RemoveKey("asdfasd" + i))
                Console.WriteLine("Remove key[{0}] failed", "asdfasd" + i);
        }
 
....
 
        for (int i = 0; i < trials; i++)
        {
            string str = "";
            if (db.Get("asdfasd" + i, out str))
            {
                if (i.ToString() != str)
                {
                    notfound++; //Assert.Fail("value does not match");
                    Console.WriteLine("Mismatch KEY:{0},VALUE:{1}", "asdfasd" + i, str);
                }
                else
                    Console.WriteLine("Hit KEY:{0},VALUE:{1}", "asdfasd" + i, str);
            }
            else
            {
                notfound++;// Assert.Fail("value not found");
                Console.WriteLine("Mismatch KEY:{0},VALUE:{1}", "asdfasd" + i, str);
            }
        }
 
       // here get the result: the first part key ( trials/2 ) will get Mismatch, Correct!!!
 
....
        var elements = db.EnumerateStorageFile();
        int total = elements.Count();
        foreach (var vv in elements)
        {
            Console.WriteLine("KEY:{0},VALUE:{1}", (string)vv.Key, Encoding.Unicode.GetString(vv.Value));
        }
 
      //here get all Key/Value data, even if the key is remove above, Incorrect!!
 
    I try to fix this, and please see detail in attachments, pls make sure if it is correct!
 
...

file attachments

comments