Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions src/experimental/zipper_algebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ impl<V: Clone + Send + Sync + Unpin, A: Allocator> ZipperAlgebraExt<V, A>
{
}

impl<V: Clone + Send + Sync + Unpin, A: Allocator> ZipperAlgebraExt<V, A>
for ReadZipperOwned<V, A>
{
}

impl<Z, V: Clone + Send + Sync + Unpin, A: Allocator> ZipperAlgebraExt<V, A> for PrefixZipper<'_, Z> where
Z: ZipperInfallibleSubtries<V, A> + ZipperSubtries<V, A> + ZipperConcrete + ZipperMoving
{
}

/// Performs an ordered join (least upper bound) of two radix-256 tries using zipper traversal.
///
/// This function merges two tries by simultaneously traversing them in lexicographic order,
Expand Down Expand Up @@ -1475,7 +1485,7 @@ impl<V: Clone + Send + Sync> MergePolicy<V> for Join {
Z: ZipperInfallibleSubtries<V, A> + ZipperMoving,
Out: ZipperWriting<V, A>,
{
out.graft_children(z, range);
out.graft_masked_branches(z, range, false)
}

#[inline]
Expand All @@ -1490,7 +1500,7 @@ impl<V: Clone + Send + Sync> MergePolicy<V> for Join {
Z: ZipperInfallibleSubtries<V, A> + ZipperConcrete + ZipperMoving,
Out: ZipperWriting<V, A>,
{
out.graft_children(z, ByteMask::FULL);
out.graft_masked_branches(z, ByteMask::FULL, false)
}
}

Expand Down Expand Up @@ -1565,7 +1575,7 @@ impl<V: Clone + Send + Sync> MergePolicy<V> for Meet {
Z: ZipperInfallibleSubtries<V, A> + ZipperConcrete + ZipperMoving,
Out: ZipperWriting<V, A>,
{
out.graft_children(z, ByteMask::FULL);
out.graft_masked_branches(z, ByteMask::FULL, false);
}
}

Expand Down Expand Up @@ -1640,7 +1650,7 @@ impl<V: Clone + Send + Sync> MergePolicy<V> for Subtract {
Z: ZipperInfallibleSubtries<V, A> + ZipperMoving,
Out: ZipperWriting<V, A>,
{
out.graft_children(z, range);
out.graft_masked_branches(z, range, false);
}

#[inline]
Expand All @@ -1660,7 +1670,7 @@ impl<V: Clone + Send + Sync> MergePolicy<V> for Subtract {
Out: ZipperWriting<V, A>,
{
if mask == 1 {
out.graft_children(z, range);
out.graft_masked_branches(z, range, false)
}
}

Expand Down Expand Up @@ -1760,6 +1770,8 @@ mod zipper_algebra_poly {
pub(super) enum SomeMutRefZ<'a, 'trie, 'path, V: Clone + Send + Sync + Unpin, A: Allocator> {
RZ(&'a mut ReadZipperUntracked<'trie, 'path, V, A>),
RZT(&'a mut ReadZipperTracked<'trie, 'path, V, A>),
PZRZ(&'a mut PrefixZipper<'a, ReadZipperUntracked<'trie, 'path, V, A>>),
PZRZT(&'a mut PrefixZipper<'a, ReadZipperTracked<'trie, 'path, V, A>>),
}

impl<V: Clone + Send + Sync + Unpin, A: Allocator> ZipperInfallibleSubtries<V, A>
Expand All @@ -1769,34 +1781,44 @@ mod zipper_algebra_poly {
match self {
SomeMutRefZ::RZ(inner) => inner.make_map(),
SomeMutRefZ::RZT(inner) => inner.make_map(),
SomeMutRefZ::PZRZ(inner) => inner.make_map(),
SomeMutRefZ::PZRZT(inner) => inner.make_map(),
}
}

fn get_trie_ref(&self) -> TrieRef<'_, V, A> {
match self {
SomeMutRefZ::RZ(inner) => inner.get_trie_ref(),
SomeMutRefZ::RZT(inner) => inner.get_trie_ref(),
SomeMutRefZ::PZRZ(inner) => inner.get_trie_ref(),
SomeMutRefZ::PZRZT(inner) => inner.get_trie_ref(),
}
}

fn get_focus(&self) -> OpaqueAbstractNodeRef<'_, V, A> {
match self {
SomeMutRefZ::RZ(inner) => inner.get_focus(),
SomeMutRefZ::RZT(inner) => inner.get_focus(),
SomeMutRefZ::PZRZ(inner) => inner.get_focus(),
SomeMutRefZ::PZRZT(inner) => inner.get_focus(),
}
}

fn get_focus_at<K: AsRef<[u8]>>(&self, path: K) -> OpaqueAbstractNodeRef<'_, V, A> {
match self {
SomeMutRefZ::RZ(inner) => inner.get_focus_at(path),
SomeMutRefZ::RZT(inner) => inner.get_focus_at(path),
SomeMutRefZ::PZRZ(inner) => inner.get_focus_at(path),
SomeMutRefZ::PZRZT(inner) => inner.get_focus_at(path),
}
}

fn try_borrow_focus(&self) -> Option<OpaqueTrieNodeRef<'_, V, A>> {
match self {
SomeMutRefZ::RZ(inner) => inner.try_borrow_focus(),
SomeMutRefZ::RZT(inner) => inner.try_borrow_focus(),
SomeMutRefZ::PZRZ(inner) => inner.try_borrow_focus(),
SomeMutRefZ::PZRZT(inner) => inner.try_borrow_focus(),
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions src/write_zipper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,6 @@ pub trait ZipperWriting<V: Clone + Send + Sync, A: Allocator = GlobalAlloc>: Wri
}
}

/// Deprecated alias for [graft_masked_branches](ZipperWriting::graft_masked_branches)
#[deprecated]
fn graft_children<Z: ZipperInfallibleSubtries<V, A>>(&mut self, src: &Z, child_mask: ByteMask) {
self.graft_masked_branches(src, child_mask, false)
}

/// Joins (union of) the subtrie below the focus of `read_zipper` into the subtrie downstream from the
/// focus of `self`
///
Expand Down