Commit f4ac3442 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 340f7659
...@@ -22,6 +22,53 @@ ...@@ -22,6 +22,53 @@
// TODO move -> btree when ΔTail matures. // TODO move -> btree when ΔTail matures.
package xbtree package xbtree
// δ(BTree) notes
// ==============
//
// input: BTree, (@new, []oid) -> find out δ(BTree) i.e. {-k(v), +k'(v'), ...}
//
// - oid ∈ Bucket
// - 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)
//go:generate ../../gen-set δbtree Tree *Tree zset_tree.go //go:generate ../../gen-set δbtree Tree *Tree zset_tree.go
//go:generate ../../gen-set δbtree Object interface{} zset_object.go //go:generate ../../gen-set δbtree Object interface{} zset_object.go
...@@ -110,7 +157,9 @@ func (δb *ΔTail) Track(path []Node) { // XXX Tree|Bucket; path[0] = root ...@@ -110,7 +157,9 @@ func (δb *ΔTail) Track(path []Node) { // XXX Tree|Bucket; path[0] = root
/* /*
root = path[0] root = path[0]
for obj in path: for obj in path:
.rootIdx[obj] += root if not obj in trackIdx:
.new += obj # XXX .4rebuild += ... ?
.trackIdx[obj] += root
*/ */
} }
...@@ -140,14 +189,14 @@ func (δB *ΔTail) Update(δZ *zodb.EventCommit) { ...@@ -140,14 +189,14 @@ func (δB *ΔTail) Update(δZ *zodb.EventCommit) {
for root, δZ in δbZ: for root, δZ in δbZ:
toposort(δZ) toposort(δZ)
for δ in δZ: for δ in δZ:
T | B = zconn.Get(δ) // XXX .zconn must be at .head and active T | B = zconnOld.Get(δ) // XXX .zconnOld must be at .head and active
T' | B' = zconnNew.Get(δ) T' | B' = zconnNew.Get(δ)
diff(T, T') diff(T, T')
diff(B, B') diff(B, B')
... ...
.tailv <- [] of (root, []key) .δBtail <- [] of (root, []key)
*/ */
} }
......
...@@ -182,53 +182,3 @@ Lock request has been issued. Thus the following scenario is possible:: ...@@ -182,53 +182,3 @@ Lock request has been issued. Thus the following scenario is possible::
To avoid such deadlocks zwatcher asks OS cache uploaders to pause while it is To avoid such deadlocks zwatcher asks OS cache uploaders to pause while it is
running, and retries taking zconnMu.Lock until all uploaders are indeed paused. running, and retries taking zconnMu.Lock until all uploaders are indeed paused.
δ(BTree) notes (XXX -> btreediff package)
=========================================
input: BTree, (@new, []oid) -> find out δ(BTree) i.e. {-k(v), +k'(v'), ...}
- oid ∈ Bucket
- 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.
XXX -> internal/btreediff ?
δ(BTree) in wcfs context:
. -k(blk) -> invalidate #blk
. +k(blk) -> invalidate #blk (e.g. if blk was previously read as hole)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment