Commit 57fc1eb2 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c0e82d8b
......@@ -54,8 +54,8 @@ type SetKey = SetI64
// ΔValue represents change in value.
type ΔValue struct {
Vold Value
Vnew Value
Old Value
New Value
}
......@@ -496,21 +496,34 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid) (δ map[Key]ΔValue, e
}
// merge δ <- δc
for k, v := range δc {
vprev, already := δ[k]
for k, δv1 := range δc {
δv2, already := δ[k]
if !already {
δ[k] = v
δ[k] = δv1
continue
}
// both δ and δc has [k] - it can be that key
// entry migrated from one bucket into another.
if !( (δv2.New == VDEL && δv1.Old == VDEL) ||
(δv2.Old == VDEL && δv1.New == VDEL) ) {
return nil, fmt.Errorf("BUG or btree corrupt: [%v] has " +
"duplicate entries: %v, %v", k, δv1, δv2)
}
δv := ΔValue{}
if δv1.New == VDEL {
δv.Old = δv1.Old
δv.New = δv2.New
} else {
// both δ and δc has [k] - it can be that key
// entry migrated from one bucket into another.
if (vprev == VDEL && v == VDEL) || (vprev != VDEL && v != VDEL) {
return nil, fmt.Errorf("BUG or btree corrupt: [%v] has " +
"duplicate entries: %v, %v", k, vprev, v)
}
delete(δ, k) // FIXME does not notice change in v on reflow
δv.Old = δv2.Old
δv.New = δv1.New
}
δ[k] = δv
}
/*
// merge Tkdel <- δc
for k, v := range δc {
if v == VDEL {
......@@ -519,6 +532,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid) (δ map[Key]ΔValue, e
delete(Tkdel, k)
}
}
*/
// XXX process keys from δ outside of already tracked nodes
// XXX only deleted keys - no - delete can be from untracked
......@@ -557,7 +571,7 @@ func diffB(ctx context.Context, a, b *Bucket) (δ map[Key]ΔValue, err error) {
//fmt.Println("> diffB", a.POid())
//defer fmt.Println("< diffB")
δ = map[Key]Value{}
δ = map[Key]ΔValue{}
//fmt.Println("av:", av)
//fmt.Println("bv:", bv)
......
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