Commit 75cbf7be authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent effb897e
...@@ -391,29 +391,39 @@ func xwalkDFS(ctx context.Context, lo, hi Key, ztree *Tree, bvisit func(*RBucket ...@@ -391,29 +391,39 @@ func xwalkDFS(ctx context.Context, lo, hi Key, ztree *Tree, bvisit func(*RBucket
} }
// XGetKV translates {k -> <oid>} to {k -> ZBlk(oid).data} according to db@at snapshot. // XGetδKV translates {k -> δ<oid>} to {k -> δ(ZBlk(oid).data)} according to db@at1..at2 snapshots.
func XGetKV(db *zodb.DB, at zodb.Tid, kvOid map[Key]Value) map[Key]string { func XGetδKV(db *zodb.DB, at1, at2 zodb.Tid, δkvOid map[Key]ΔValue) map[Key]Δstring {
defer exc.Contextf("%s: @%s: get kv %v", db.Storage().URL(), at, kvOid) defer exc.Contextf("%s: get δkv %s..%s %v", db.Storage().URL(), at1, at2, δkvOid)
X := exc.Raiseif X := exc.Raiseif
txn, ctx := transaction.New(context.Background()) txn, ctx := transaction.New(context.Background())
defer txn.Abort() defer txn.Abort()
zconn, err := db.Open(ctx, &zodb.ConnOptions{At: at}); X(err) zconn1, err := db.Open(ctx, &zodb.ConnOptions{At: at1}); X(err)
zconn2, err := db.Open(ctx, &zodb.ConnOptions{At: at2}); X(err)
kv := map[Key]string{}
for k, vOid := range kvOid { δkv := map[Key]Δstring{}
if vOid == VDEL { for k, δvOid := range δkvOid {
kv[k] = DEL δkv[k] = Δstring{
continue Old: xzgetBlkData(ctx, zconn1, δvOid.Old),
New: xzgetBlkData(ctx, zconn2, δvOid.New),
} }
}
xv, err := zconn.Get(ctx, vOid); X(err) return δkv
zv := xv.(zBlk) }
data, _, err := zv.loadBlkData(ctx); X(err)
kv[k] = string(data) // xzgetBlkData loads block data from ZBlk object specified by its oid.
func xzgetBlkData(ctx context.Context, zconn *zodb.Connection, zblkOid zodb.Oid) string {
X := exc.Raiseif
if zblkOid == VDEL {
return DEL
} }
return kv xblk, err := zconn.Get(ctx, zblkOid); X(err)
zblk := xblk.(zBlk)
data, _, err := zblk.loadBlkData(ctx); X(err)
return string(data)
} }
...@@ -596,8 +606,8 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, ...@@ -596,8 +606,8 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
// δT <- δB // δT <- δB
δToid := δB.ByRoot[treeRoot] // {} k -> δoid δToid := δB.ByRoot[treeRoot] // {} k -> δoid
δT = XGetKV(db, at2, δToid) // {} k -> ZBlk(oid).data δT = XGetδKV(db, at1,at2, δToid) // {} k -> δ(ZBlk(oid).data)
// δT must be subset of d12. // δT must be subset of d12.
// changed keys, that are // changed keys, that are
......
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