public void deleting_a_value_from_a_path() { var subject = new ReverseTrie <SerialGuid>(); var val1 = SerialGuid.Wrap(Guid.NewGuid()); var val2 = SerialGuid.Wrap(Guid.NewGuid()); subject.Add("Deleted: no", val1); subject.Add("Deleted: yes", val2); subject.Delete("Deleted: yes"); subject.Delete("Not present"); // ok to try non-paths // Get Assert.That(subject.Get("Deleted: no"), Is.EqualTo(val1), "Failed to find data to a known path"); Assert.That(subject.Get("Deleted: yes"), Is.Null, "Should have been removed, but it's still there"); // Search var all = string.Join(",", subject.Search("Deleted")); Assert.That(all, Is.EqualTo("Deleted: no")); // Look-up Assert.That(subject.GetPathsForEntry(val2), Is.Empty, "Value cache was not updated"); Assert.That(subject.GetPathsForEntry(val1), Is.Not.Empty, "Value cache was destroyed?"); }
/// <summary> /// Remove a path binding if it exists. If the path is not bound, nothing happens. /// Linked documents are not removed. /// </summary> public void UnbindPath(string exactPath) { _pathLookupCache = null; lock (_fslock) { var pathLink = GetPathLookupLink(); var pathIndex = new ReverseTrie <SerialGuid>(); if (!pathLink.TryGetLink(0, out var pathPageId)) { return; } pathIndex.Defrost(GetStream(pathPageId)); // Unbind the path pathIndex.Delete(exactPath); // Write back to new chain var newPageId = WriteStream(pathIndex.Freeze()); // Update version link pathLink.WriteNewLink(newPageId, out var expired); SetPathLookupLink(pathLink); ReleaseChain(expired); Flush(); } }