Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
30e1b2a5
Commit
30e1b2a5
authored
Sep 23, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
ebc286c3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
46 deletions
+18
-46
wcfs/internal/xbtree/treediff.go
wcfs/internal/xbtree/treediff.go
+18
-46
No files found.
wcfs/internal/xbtree/treediff.go
View file @
30e1b2a5
...
@@ -34,57 +34,29 @@ package xbtree
...
@@ -34,57 +34,29 @@ package xbtree
//
//
// BTree diff algorithm
// BTree diff algorithm
//
//
// The central part of BTree-diff algorithm is in diffT and diffB.
// diffT, diffB and δMerge constitute the diff algorithm implementation.
// diff(A,B) works on pair of A and B whole key range splitted into regions
// covered by tree nodes. The splitting represents current state of recursion
// into corresponding tree. If a node in particular key range is Bucket, that
// bucket contributes to δ- in case of A, and to δ+ in case of B. If a node in
// particular key range is Tree, the algorithm may want to expand that tree
// node into its children and to recourse into children.
//
//
// There are two phases:
//
//
// FIXME the algorithm is different: recursion is implemented by expanding rangeSplit step by step.
// - Phase 1 expands A top->down driven by δZTC, adds reached buckets to δ-,
// and queues key regions of those buckets to be processed on B.
//
//
// δ(BTree) notes
// - Phase 2 starts processing from queued key regions, expands them on B and
// ==============
// adds reached buckets to δ+. Then it iterates to reach consistency in between
// A and B because processing buckets on B side may increase δ key coverage,
// and so corresponding key ranges has to be again processed on A. Which in
// turn may increase δ key coverage again, and needs to be processed on B side,
// etc...
//
//
//
input: BTree, (@new, []oid) -> find out δ(BTree) i.e. {-k(v), +k'(v'), ...}
//
The final δ is merge of δ- and δ+.
//
//
// - oid ∈ Bucket
// diffT has more detailed explanation of phase 1 and phase 2 logic.
// - oid ∈ BTree
//
// Bucket:
//
// old = {k -> v}
// new = {k' -> v'}
//
// Δ = -k(v), +k(v), ...
//
// => for all buckets
//
// Δ accumulates to []δk(v)[n+,n-] n+ ∈ {0,1}, n- ∈ {0,1}, if n+=n- - cancel
//
//
// BTree:
//
// old = {k -> B} or {k -> T}
// new = {k' -> B'} or {k' -> T'}
//
// Δ = -k(B), +k(B), -k(T), +K(T), ...
//
// we translate (in top-down order):
//
// k(B) -> {} of k(v)
// k(T) -> {} of k(B) -> {} of k(v)
//
// which gives
//
// Δ = k(v), +k(v), ...
//
// i.e. exactly as for buckets and it accumulates to global Δ.
//
// The globally-accumulated Δ is the answer for δ(BTree, (@new, []oid))
//
// top-down order is obtained via toposort({oid}) wrt visited PathSet.
//
// δ(BTree) in wcfs context:
//
// . -k(blk) -> invalidate #blk
// . +k(blk) -> invalidate #blk (e.g. if blk was previously read as hole)
import
(
import
(
"context"
"context"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment