public void IndexClean() { string path = Path.GetFullPath("TestData\\IndexClean"); using (var db = new KeyValueStore(path)) { db.Truncate(); db.Manifest.Logger = msg => Console.WriteLine(msg); db.Set(Encoding.UTF8.GetBytes("KeyA"), Encoding.UTF8.GetBytes("ValueA:1"), new Dictionary<string, byte[]> { { "Idx", Encoding.UTF8.GetBytes("1") } }); db.Set(Encoding.UTF8.GetBytes("KeyB"), Encoding.UTF8.GetBytes("ValueB:2"), new Dictionary<string, byte[]> { { "Idx", Encoding.UTF8.GetBytes("2") } }); db.Set(Encoding.UTF8.GetBytes("KeyC"), Encoding.UTF8.GetBytes("ValueC:3"), new Dictionary<string, byte[]> { { "Idx", Encoding.UTF8.GetBytes("3") } }); var lookupValue = db.Find("Idx", Encoding.UTF8.GetBytes("3")).Single(); Assert.AreEqual("ValueC:3", Encoding.UTF8.GetString(lookupValue.Value)); Assert.AreEqual("KeyC", Encoding.UTF8.GetString(lookupValue.Key)); db.Delete(Encoding.UTF8.GetBytes("KeyC")); } // Open the index directly and confirm that the lookup key is still there using (var db = new KeyValueStore(Path.Combine(path, "Idx"))) { Assert.AreEqual(3, db.Enumerate().Count()); } using (var db = new KeyValueStore(path)) { db.CleanIndex("Idx"); } // Open the index directly and confirm that the lookup key is now gone using (var db = new KeyValueStore(Path.Combine(path, "Idx"))) { Assert.AreEqual(2, db.Enumerate().Count()); } }