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
}
// XGetKV translates {k -> <oid>} to {k -> ZBlk(oid).data} according to db@at snapshot.
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)
// XGetδKV translates {k -> δ<oid>} to {k -> δ(ZBlk(oid).data)} according to db@at1..at2 snapshots.
func XGetδKV(db *zodb.DB, at1, at2 zodb.Tid, δkvOid map[Key]ΔValue) map[Key]Δstring {
defer exc.Contextf("%s: get δkv %s..%s %v", db.Storage().URL(), at1, at2, δkvOid)
X := exc.Raiseif
txn, ctx := transaction.New(context.Background())
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 {
if vOid == VDEL {
kv[k] = DEL
continue
δkv := map[Key]Δstring{}
for k, δvOid := range δkvOid {
δkv[k] = Δstring{
Old: xzgetBlkData(ctx, zconn1, δvOid.Old),
New: xzgetBlkData(ctx, zconn2, δvOid.New),
}
}
xv, err := zconn.Get(ctx, vOid); X(err)
zv := xv.(zBlk)
data, _, err := zv.loadBlkData(ctx); X(err)
kv[k] = string(data)
return δkv
}
// 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)
}
......@@ -597,7 +607,7 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
// δT <- δB
δ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.
// 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