Commit 1e985a6c authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 11c95175
...@@ -67,21 +67,22 @@ type Δstring = xbtreetest.Δstring ...@@ -67,21 +67,22 @@ type Δstring = xbtreetest.Δstring
// trackSet returns what should be ΔBtail.trackSet coverage for specified tracked key set. // trackSet returns what should be ΔBtail.trackSet coverage for specified tracked key set.
func (rbs xbtreetest.RBucketSet) trackSet(tracked setKey) blib.PPTreeSubSet { // XXX was method -> change name?
func trackSet(rbs xbtreetest.RBucketSet, tracked setKey) blib.PPTreeSubSet {
// nil = don't compute keyCover // nil = don't compute keyCover
// (trackSet is called from inside hot inner loop of rebuild test) // (trackSet is called from inside hot inner loop of rebuild test)
trackSet := rbs._trackSetWithCov(tracked, nil) trackSet := _trackSetWithCov(rbs, tracked, nil)
return trackSet return trackSet
} }
// trackSetWithCov returns what should be ΔBtail.trackSet and its key coverage for specified tracked key set. // trackSetWithCov returns what should be ΔBtail.trackSet and its key coverage for specified tracked key set.
func (rbs xbtreetest.RBucketSet) trackSetWithCov(tracked setKey) (trackSet blib.PPTreeSubSet, keyCover *blib.RangedKeySet) { func trackSetWithCov(rbs xbtreetest.RBucketSet, tracked setKey) (trackSet blib.PPTreeSubSet, keyCover *blib.RangedKeySet) {
keyCover = &blib.RangedKeySet{} keyCover = &blib.RangedKeySet{}
trackSet = rbs._trackSetWithCov(tracked, keyCover) trackSet = _trackSetWithCov(rbs, tracked, keyCover)
return trackSet, keyCover return trackSet, keyCover
} }
func (rbs xbtreetest.RBucketSet) _trackSetWithCov(tracked setKey, outKeyCover *blib.RangedKeySet) (trackSet blib.PPTreeSubSet) { func _trackSetWithCov(rbs xbtreetest.RBucketSet, tracked setKey, outKeyCover *blib.RangedKeySet) (trackSet blib.PPTreeSubSet) {
trackSet = blib.PPTreeSubSet{} trackSet = blib.PPTreeSubSet{}
for k := range tracked { for k := range tracked {
kb := rbs.Get(k) kb := rbs.Get(k)
...@@ -92,41 +93,46 @@ func (rbs xbtreetest.RBucketSet) _trackSetWithCov(tracked setKey, outKeyCover *b ...@@ -92,41 +93,46 @@ func (rbs xbtreetest.RBucketSet) _trackSetWithCov(tracked setKey, outKeyCover *b
// embedded buckets all have oid=zodb.InvalidOid and would lead to z // embedded buckets all have oid=zodb.InvalidOid and would lead to z
newNode := false newNode := false
if kb.Oid != zodb.InvalidOid { if kb.Oid != zodb.InvalidOid {
track, already := trackSet[kb.oid] trackSet.AddPath(kb.Path())
/*
track, already := trackSet[kb.Oid]
if !already { if !already {
track = &nodeInTree{parent: kb.parent.oid, nchild: 0} track = &blib.nodeInTree{parent: kb.parent.oid, nchild: 0}
trackSet[kb.oid] = track trackSet[kb.Oid] = track
newNode = true newNode = true
} }
if track.parent != kb.parent.oid { if track.parent != kb.Parent.Oid {
panicf("BUG: %s: B%s -> multiple parents: %s %s", rbs.coverage(), kb.oid, track.parent, kb.parent.oid) panicf("BUG: %s: B%s -> multiple parents: %s %s", rbs.coverage(), kb.Oid, track.parent, kb.Parent.Oid)
} }
*/
} }
p := kb.parent /*
p := kb.Parent
for p != nil { for p != nil {
ppoid := zodb.InvalidOid // oid of p.parent ppoid := zodb.InvalidOid // oid of p.parent
if p.parent != nil { if p.Parent != nil {
ppoid = p.parent.oid ppoid = p.Parent.Oid
} }
newParent := false newParent := false
pt, already := trackSet[p.oid] pt, already := trackSet[p.Oid]
if !already { if !already {
pt = &nodeInTree{parent: ppoid, nchild: 0} pt = &nodeInTree{parent: ppoid, nchild: 0}
trackSet[p.oid] = pt trackSet[p.Oid] = pt
newParent = true newParent = true
} }
if pt.parent != ppoid { if pt.parent != ppoid {
panicf("BUG: %s: T%s -> multiple parents: %s %s", rbs.coverage(), p.oid, pt.parent, ppoid) panicf("BUG: %s: T%s -> multiple parents: %s %s", rbs.coverage(), p.Oid, pt.parent, ppoid)
} }
if newNode { if newNode {
pt.nchild++ pt.nchild++
} }
newNode = newParent newNode = newParent
p = p.parent p = p.Parent
} }
*/
} }
return trackSet return trackSet
} }
...@@ -452,8 +458,8 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod ...@@ -452,8 +458,8 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod
// trackSet1 = xkv1[tracked1] // trackSet1 = xkv1[tracked1]
// trackSet2 = xkv2[tracked2] ( = xkv2[kadj[tracked1]] // trackSet2 = xkv2[tracked2] ( = xkv2[kadj[tracked1]]
trackSet1, tkeyCov1 := t1.xkv.trackSetWithCov(initialTrackedKeys) trackSet1, tkeyCov1 := trackSetWithCov(t1.xkv, initialTrackedKeys)
trackSet2, tkeyCov2 := t2.xkv.trackSetWithCov(initialTrackedKeys.Union(kadjTrackedδZ)) trackSet2, tkeyCov2 := trackSetWithCov(t2.xkv, initialTrackedKeys.Union(kadjTrackedδZ))
// verify δbtail.trackSet against @at1 // verify δbtail.trackSet against @at1
δbtail.assertTrack(t, "1", ø, trackSet1) δbtail.assertTrack(t, "1", ø, trackSet1)
......
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