Commit bc1b465f authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 57b00793
...@@ -233,6 +233,11 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node, flags Track ...@@ -233,6 +233,11 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node, flags Track
panic("empty path") panic("empty path")
} }
treeRoot := path[0].(*Tree) treeRoot := path[0].(*Tree)
var leafBucket *Bucket
if l := len(path); l > 1 {
leafBucket = path[l-1].(*Bucket)
}
// XXX assert Tree Tree ... Tree Bucket // XXX assert Tree Tree ... Tree Bucket
root := treeRoot.POid() root := treeRoot.POid()
...@@ -241,11 +246,13 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node, flags Track ...@@ -241,11 +246,13 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node, flags Track
fmt.Printf("Track %v\n", oidv) fmt.Printf("Track %v\n", oidv)
parent := zodb.InvalidOid parent := zodb.InvalidOid
var track nodeTrack
var oldTrack bool
for _, node := range path { for _, node := range path {
oid := node.POid() oid := node.POid()
// XXX check for InvalidOid (e.g. T/B1:a with bucket not having its own oid. // XXX check for InvalidOid (e.g. T/B1:a with bucket not having its own oid.
track, ok := δBtail.trackIdx[oid] track, oldTrack = δBtail.trackIdx[oid]
if !ok { if !oldTrack {
track = nodeTrack{parent: parent, trackedKeys: SetKey{}} track = nodeTrack{parent: parent, trackedKeys: SetKey{}}
δBtail.trackIdx[oid] = track δBtail.trackIdx[oid] = track
// XXX .trackNew += oid // XXX .trackNew += oid
...@@ -256,12 +263,27 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node, flags Track ...@@ -256,12 +263,27 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node, flags Track
oid, track.parent, parent) oid, track.parent, parent)
} }
if track.trackedKeys != nil { // root always covers [-∞, ∞) if track.trackedKeys != nil { // root always covers [-∞, ∞)
// XXX add all keys of leaf bucket XXX for bucket _and_ back for parents
track.trackedKeys.Add(key) track.trackedKeys.Add(key)
} }
parent = oid parent = oid
} }
// tracked += all keys of leaf bucket for every node up to the root
if !oldTrack && leafBucket != nil {
bkeys := SetKey{}
for _, __ := range leafBucket.Entryv() {
bkeys.Add(__.Key())
}
for {
track.trackedKeys.Update(bkeys)
if track.parent == zodb.InvalidOid {
break
}
track = δBtail.trackIdx[track.parent]
}
}
_, ok := δBtail.byRoot[root] _, ok := δBtail.byRoot[root]
if !ok { if !ok {
δBtail.byRoot[root] = newΔTtail() δBtail.byRoot[root] = newΔTtail()
......
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