Commit 7ed177e4 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 1e985a6c
...@@ -70,7 +70,7 @@ func (rbs RBucketSet) Get(k Key) *RBucket { ...@@ -70,7 +70,7 @@ func (rbs RBucketSet) Get(k Key) *RBucket {
} }
rb := rbs[i] rb := rbs[i]
if !(rb.Keycov.Lo <= k && k <= rb.Keycov.Hi_) { if !rb.Keycov.Has(k) {
panicf("BUG: get(%v) -> %s; coverage: %s", k, rb.Keycov, rbs.coverage()) panicf("BUG: get(%v) -> %s; coverage: %s", k, rb.Keycov, rbs.coverage())
} }
......
...@@ -42,7 +42,7 @@ type T struct { ...@@ -42,7 +42,7 @@ type T struct {
work string // working directory work string // working directory
treeSrv *TreeSrv treeSrv *TreeSrv
zstor zodb.IStorage zstor zodb.IStorage
db *zodb.DB DB *zodb.DB
// all committed trees // all committed trees
commitv []*Commit commitv []*Commit
...@@ -50,13 +50,13 @@ type T struct { ...@@ -50,13 +50,13 @@ type T struct {
// Commit represent test commit changing a tree. // Commit represent test commit changing a tree.
type Commit struct { type Commit struct {
tree string // the tree in topology-encoding Tree string // the tree in topology-encoding
prev *Commit // previous commit Prev *Commit // previous commit
at zodb.Tid // commit revision At zodb.Tid // commit revision
δZ *zodb.EventCommit // raw ZODB changes; δZ.tid == at ΔZ *zodb.EventCommit // raw ZODB changes; δZ.tid == at
xkv RBucketSet // full tree state as of @at Xkv RBucketSet // full tree state as of @at
δxkv map[Key]Δstring // full tree-diff against parent Δxkv map[Key]Δstring // full tree-diff against parent
blkDataTab map[zodb.Oid]string // full snapshot of all ZBlk data @at XXX -> zblkDataTab zblkDataTab map[zodb.Oid]string // full snapshot of all ZBlk data @at
// δzblkData map[zodb.Oid]Δstring // full diff for zblkData against parent XXX ? // δzblkData map[zodb.Oid]Δstring // full diff for zblkData against parent XXX ?
} }
...@@ -81,25 +81,25 @@ func NewT(t *testing.T) *T { ...@@ -81,25 +81,25 @@ func NewT(t *testing.T) *T {
err := tt.zstor.Close(); X(err) err := tt.zstor.Close(); X(err)
}) })
tt.db = zodb.NewDB(tt.zstor, &zodb.DBOptions{ tt.DB = zodb.NewDB(tt.zstor, &zodb.DBOptions{
// We need objects to be cached, because otherwise it is too // We need objects to be cached, because otherwise it is too
// slow to run the test for many testcases, especially // slow to run the test for many testcases, especially
// xverifyΔBTail_rebuild. // xverifyΔBTail_rebuild.
CacheControl: &tZODBCacheEverything{}, CacheControl: &tZODBCacheEverything{},
}) })
t.Cleanup(func() { t.Cleanup(func() {
err := tt.db.Close(); X(err) err := tt.DB.Close(); X(err)
}) })
head := tt.treeSrv.head head := tt.treeSrv.head
t1 := &Commit{ t1 := &Commit{
tree: "T/B:", // treegen.py creates the tree as initially empty Tree: "T/B:", // treegen.py creates the tree as initially empty
prev: nil, Prev: nil,
at: head, At: head,
xkv: xGetTree(tt.db, head, tt.Root()), Xkv: xGetTree(tt.DB, head, tt.Root()),
blkDataTab: xGetBlkDataTab(tt.db, head), zblkDataTab: xGetBlkDataTab(tt.DB, head),
δZ: nil, ΔZ: nil,
δxkv: nil, Δxkv: nil,
} }
tt.commitv = []*Commit{t1} tt.commitv = []*Commit{t1}
...@@ -152,7 +152,7 @@ func (t *T) CommitTree(tree string) *Commit { ...@@ -152,7 +152,7 @@ func (t *T) CommitTree(tree string) *Commit {
// if the tree does not exist yet - report its structure as empty // if the tree does not exist yet - report its structure as empty
var xkv RBucketSet var xkv RBucketSet
if tree != DEL { if tree != DEL {
xkv = xGetTree(t.db, δZ.Tid, t.Root()) xkv = xGetTree(t.DB, δZ.Tid, t.Root())
} else { } else {
// empty tree with real treeRoot as oid even though the tree is // empty tree with real treeRoot as oid even though the tree is
// deleted. Having real oid in the root tests that after deletion, // deleted. Having real oid in the root tests that after deletion,
...@@ -178,16 +178,16 @@ func (t *T) CommitTree(tree string) *Commit { ...@@ -178,16 +178,16 @@ func (t *T) CommitTree(tree string) *Commit {
} }
ttree := &Commit{ ttree := &Commit{
tree: tree, Tree: tree,
at: δZ.Tid, At: δZ.Tid,
δZ: δZ, ΔZ: δZ,
xkv: xkv, Xkv: xkv,
blkDataTab: xGetBlkDataTab(t.db, δZ.Tid), zblkDataTab: xGetBlkDataTab(t.DB, δZ.Tid),
} }
tprev := t.Head() tprev := t.Head()
ttree.prev = tprev ttree.Prev = tprev
ttree.δxkv = kvdiff(tprev.xkv.Flatten(), ttree.xkv.Flatten()) ttree.Δxkv = kvdiff(tprev.Xkv.Flatten(), ttree.Xkv.Flatten())
t.commitv = append(t.commitv, ttree) t.commitv = append(t.commitv, ttree)
...@@ -242,16 +242,16 @@ func xGetBlkDataTab(db *zodb.DB, at zodb.Tid) map[zodb.Oid]string { ...@@ -242,16 +242,16 @@ func xGetBlkDataTab(db *zodb.DB, at zodb.Tid) map[zodb.Oid]string {
return blkDataTab return blkDataTab
} }
// xgetBlkData loads blk data for ZBlk<oid> @t.at // XGetBlkData loads blk data for ZBlk<oid> @t.at
// //
// For speed the load is done via preloaded t.blkDataTab instead of access to the DB. // For speed the load is done via preloaded t.blkDataTab instead of access to the DB.
func (t *Commit) xgetBlkData(oid zodb.Oid) string { func (t *Commit) XGetBlkData(oid zodb.Oid) string {
if oid == VDEL { if oid == VDEL {
return DEL return DEL
} }
data, ok := t.blkDataTab[oid] data, ok := t.zblkDataTab[oid]
if !ok { if !ok {
exc.Raisef("getBlkData ZBlk<%s> @%s: no such ZBlk", oid, t.at) exc.Raisef("getBlkData ZBlk<%s> @%s: no such ZBlk", oid, t.At)
} }
return data return data
} }
......
This diff is collapsed.
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