Commit ec7b9c09 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e092f7c9
...@@ -330,38 +330,27 @@ func (δBtail *ΔBtail) treediff(ctx context.Context, root zodb.Oid, δZT SetOid ...@@ -330,38 +330,27 @@ func (δBtail *ΔBtail) treediff(ctx context.Context, root zodb.Oid, δZT SetOid
fmt.Printf("treediff %s δZT: %v\n", root, δZT) fmt.Printf("treediff %s δZT: %v\n", root, δZT)
// XXX δZT -> δZT* (all changed nodes are connected) // XXX δZT -> δZTC (all changed nodes are connected)
// e.g. t₀->t₁->b₂ δZ={t₀ b₂} -> δZ*=δZ+{t₁} // e.g. t₀->t₁->b₂ δZ={t₀ b₂} -> δZC=δZ+{t₁}
δZTC := δZT // FIXME stub δZTC := δZT // FIXME stub
δT = map[Key]Value{} δT = map[Key]Value{}
for top := range δZT { // XXX -> for each top-level nodes in δZT* for top := range δZT { // XXX -> sorted?
xa, err1 := zconnOld.Get(ctx, top) a, err1 := zgetNode(ctx, zconnOld, top)
xb, err2 := zconnNew.Get(ctx, top) b, err2 := zgetNode(ctx, zconnNew, top)
err := xerr.Merge(err1, err2) err := xerr.Merge(err1, err2)
if err != nil { if err != nil {
return nil, err return nil, err
} }
a, ok := xa.(Node)
if !ok {
return nil, fmt.Errorf("object %s@%s: type unexpected: %s",
top, zconnOld.At(), zodb.ClassOf(xa))
}
b, ok := xb.(Node)
if !ok {
return nil, fmt.Errorf("object %s@%s: type unexpected: %s",
top, zconnNew.At(), zodb.ClassOf(xb))
}
δtop, err := diffX(ctx, a, b, δZTC) δtop, err := diffX(ctx, a, b, δZTC)
if err != nil { if err != nil {
return nil, err return nil, err
} }
// FIXME -> merge (VDEL vs add) // FIXME -> merge (VDEL vs add)
// XXX no - not needed here - changes cannot migrate in between two disconnected subtrees
for k,v := range δtop { for k,v := range δtop {
δT[k] = v δT[k] = v
} }
...@@ -564,6 +553,22 @@ func diffB(ctx context.Context, a, b *Bucket) (δ map[Key]Value, err error) { ...@@ -564,6 +553,22 @@ func diffB(ctx context.Context, a, b *Bucket) (δ map[Key]Value, err error) {
return δ, nil return δ, nil
} }
// zgetNode returns btree node corresponding to zconn.Get(oid)
func zgetNode(ctx context.Context, zconn *zodb.Connection, oid zodb.Oid) (_ Node, err error) {
defer xerr.Contextf(&err, "getnode %s@%s", oid, zconn.At())
xnode, err := zconn.Get(ctx, oid)
if err != nil {
return nil, err
}
node, ok := xnode.(Node)
if !ok {
return nil, fmt.Errorf("unexpected type: %s", zodb.ClassOf(xnode))
}
return node, nil
}
// vOid returns OID of a value object. // vOid returns OID of a value object.
// it is an error if value is not persistent object. // it is an error if value is not persistent object.
func vOid(xvalue interface{}) (zodb.Oid, error) { func vOid(xvalue interface{}) (zodb.Oid, error) {
......
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