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

.

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