Commit c0e82d8b authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 55f9e24e
...@@ -52,6 +52,12 @@ const VDEL = zodb.InvalidOid ...@@ -52,6 +52,12 @@ const VDEL = zodb.InvalidOid
type Oid = zodb.Oid type Oid = zodb.Oid
type SetKey = SetI64 type SetKey = SetI64
// ΔValue represents change in value.
type ΔValue struct {
Vold Value
Vnew Value
}
// ΔBtail represents tail of revisional changes to BTrees. // ΔBtail represents tail of revisional changes to BTrees.
// //
...@@ -431,13 +437,15 @@ func diffX(ctx context.Context, a, b Node, δZTC SetOid) (δ map[Key]Value, err ...@@ -431,13 +437,15 @@ func diffX(ctx context.Context, a, b Node, δZTC SetOid) (δ map[Key]Value, err
// //
// a, b point to top of the subtree @old and @new revisions. // a, b point to top of the subtree @old and @new revisions.
// δZTC is connected set of objects covering δZT (objects changed in this tree in old..new). // δZTC is connected set of objects covering δZT (objects changed in this tree in old..new).
func diffT(ctx context.Context, a, b *Tree, δZTC SetOid) (δ map[Key]Value, err error) { func diffT(ctx context.Context, a, b *Tree, δZTC SetOid) (δ map[Key]ΔValue, err error) {
fmt.Printf(" T %s %s\n", xidOf(a), xidOf(b)) fmt.Printf(" T %s %s\n", xidOf(a), xidOf(b))
defer xerr.Contextf(&err, "diffT %s %s", xidOf(a), xidOf(b)) defer xerr.Contextf(&err, "diffT %s %s", xidOf(a), xidOf(b))
/*
if (a != nil && b != nil) && (a.POid() != b.POid()) { if (a != nil && b != nil) && (a.POid() != b.POid()) {
panic("different trees") // XXX wrong - tree object can be changed completely panic("different trees") // XXX wrong - tree object can be changed completely ?
} }
*/
var av []TreeEntry var av []TreeEntry
var bv []TreeEntry var bv []TreeEntry
...@@ -499,7 +507,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid) (δ map[Key]Value, err ...@@ -499,7 +507,7 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid) (δ map[Key]Value, err
return nil, fmt.Errorf("BUG or btree corrupt: [%v] has " + return nil, fmt.Errorf("BUG or btree corrupt: [%v] has " +
"duplicate entries: %v, %v", k, vprev, v) "duplicate entries: %v, %v", k, vprev, v)
} }
delete(δ, k) delete(δ, k) // FIXME does not notice change in v on reflow
} }
} }
...@@ -522,13 +530,15 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid) (δ map[Key]Value, err ...@@ -522,13 +530,15 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid) (δ map[Key]Value, err
// diffB computes difference in between two revisions of a bucket. // diffB computes difference in between two revisions of a bucket.
// see diffX for details. // see diffX for details.
func diffB(ctx context.Context, a, b *Bucket) (δ map[Key]Value, err error) { func diffB(ctx context.Context, a, b *Bucket) (δ map[Key]ΔValue, err error) {
fmt.Printf(" B %s %s\n", xidOf(a), xidOf(b)) fmt.Printf(" B %s %s\n", xidOf(a), xidOf(b))
defer xerr.Contextf(&err, "diffB %s %s", xidOf(a), xidOf(b)) defer xerr.Contextf(&err, "diffB %s %s", xidOf(a), xidOf(b))
// XXX oid can be InvalidOid for T/B... (i.e. B is part of T and is not yet committed separately) // XXX oid can be InvalidOid for T/B... (i.e. B is part of T and is not yet committed separately)
/*
if (a != nil && b != nil) && (a.POid() != b.POid()) { if (a != nil && b != nil) && (a.POid() != b.POid()) {
panic("different buckets") // XXX wrong - bucket object can be changed completely panic("different buckets") // XXX wrong - bucket object can be changed completely ?
} }
*/
var av []BucketEntry var av []BucketEntry
...@@ -572,17 +582,17 @@ func diffB(ctx context.Context, a, b *Bucket) (δ map[Key]Value, err error) { ...@@ -572,17 +582,17 @@ func diffB(ctx context.Context, a, b *Bucket) (δ map[Key]Value, err error) {
switch { switch {
case ka < kb: // -a[0] case ka < kb: // -a[0]
δ[ka] = VDEL δ[ka] = ΔValue{va, VDEL}
av = av[1:] av = av[1:]
case ka > kb: // +b[0] case ka > kb: // +b[0]
δ[kb] = vb δ[kb] = ΔValue{VDEL, vb}
bv = bv[1:] bv = bv[1:]
// ka == kb // va->vb // ka == kb // va->vb
default: default:
if va != vb { if va != vb {
δ[ka] = vb δ[ka] = ΔValue{va, vb}
} }
av = av[1:] av = av[1:]
bv = bv[1:] bv = bv[1:]
......
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