Commit 129fe522 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 831e5247
......@@ -157,8 +157,8 @@ func XGetTree(db *zodb.DB, at zodb.Tid, root zodb.Oid) map[Key]string {
txn, ctx := transaction.New(context.Background())
defer txn.Abort()
zconn, err := db.Open(ctx, &zodb.ConnOptions{At: at}); X(err)
xztree, err := zconn.Get(ctx, root); X(err)
ztree, ok := xztree.(*Tree)
if !ok {
......@@ -194,6 +194,31 @@ func XGetTree(db *zodb.DB, at zodb.Tid, root zodb.Oid) map[Key]string {
return kv
}
// XGetKV translates {k -> <oid>} to {k -> ZBlk(oid).data} according to db@at.
func XGetKV(db *zodb.DB, at zodb.Tid, kvOid map[Key]Value) map[Key]string {
defer exc.Contextf("%s: @%s: get kv %v", db.Storage().URL(), at, kvOid)
X := exc.Raiseif
txn, ctx := transaction.New(context.Background())
defer txn.Abort()
zconn, err := db.Open(ctx, &zodb.ConnOptions{At: at}); X(err)
kv := map[Key]string{}
for k, vOid := range kvOid {
if vOid == zodb.InvalidOid {
kv[k] = DEL
continue
}
xv, err := zconn.Get(ctx, vOid); X(err)
zv := xv.(zBlk)
data, _, err := zv.loadBlkData(ctx); X(err)
kv[k] = string(data)
}
return kv
}
// xverifyΔBTail verifies how ΔBTail handles ZODB update for a tree with changes in between at1->at2.
//
......@@ -257,15 +282,24 @@ func xverifyΔBTail1(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, at1,at2 zodb.
return
}
// δB.ByRoot.keys() == [treeRoot]
roots := []zodb.Oid{}
for root := range δB.ByRoot {
roots = append(roots, root)
}
assert.Equal(roots, []zodb.Oid{treeRoot})
δT := δB.ByRoot[treeRoot]
_ = δT
δT := δB.ByRoot[treeRoot] // {} k -> oid
δTstr := XGetKV(db, at2, δT) // {} k -> ZBlk(oid).data
fmt.Println("d12:", d12)
fmt.Println("δT: ", δTstr)
// δT must be subset of d12.
// changed keys, that are
// - in tracked set -> must be present in δT
// - outside tracked set -> may be present in δT
//
// all keys from d12/tracked are present in δT
//for (k,v) in d12:
// if k in initialTrackedKeys:
......
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