Commit 6d77591b authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 6092b390
......@@ -119,13 +119,24 @@ type ΔBtail struct {
// tracked index: BTree|Bucket -> top tree element.
// XXX allow only single root (else it is "tree corrupt") ?
// XXX as of @head state
trackIdx map[zodb.Oid]SetOid // oid -> {} roots
// trackIdx map[zodb.Oid]SetOid // oid -> {} roots
// tracked objects that are not yet taken into account in current δBtail
trackNew SetOid
// tracked keys that are not in current version of the tree.
tkdel SetKey
// tracked nodes index: node -> parent + keys tracked under this node
trackIdx map[zodb.Oid]nodeTrack
}
// XXX place
// nodeTrack represents tracking information about a node.
type nodeTrack struct {
parent zodb.Oid // parent node | InvalidOid for root
trackedKeys SetKey // keys tracked under this node; nil for root
}
// ΔB represents a change in BTrees space.
......@@ -173,7 +184,8 @@ func NewΔBtail(at0 zodb.Tid, db *zodb.DB) *ΔBtail {
return &ΔBtail{
δZtail: zodb.NewΔTail(at0),
byRoot: make(map[zodb.Oid]*ΔTtail),
trackIdx: make(map[zodb.Oid]SetOid),
// trackIdx: make(map[zodb.Oid]SetOid),
trackIdx: map[zodb.Oid]nodeTrack{},
tkdel: SetKey{},
db: db,
}
......@@ -227,16 +239,26 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node, flags Track
for _, node := range path { oidv = append(oidv, node.POid()) }
fmt.Printf("Track %v\n", oidv)
parent := zodb.InvalidOid
for _, node := range path {
oid := node.POid()
// XXX check for InvalidOid (e.g. T/B1:a with bucket not having its own oid.
nodeRoots, ok := δBtail.trackIdx[oid]
track, ok := δBtail.trackIdx[oid]
if !ok {
nodeRoots = make(SetOid)
δBtail.trackIdx[oid] = nodeRoots
track = nodeTrack{parent: parent}
if parent != zodb.InvalidOid {
track.trackedKeys = SetKey{}
}
δBtail.trackIdx[oid] = track
// XXX .trackNew += oid
}
nodeRoots.Add(root)
if track.parent != parent {
// XXX -> error (e.g. due to corrupt data in ZODB)
panicf("node %s is reachable from multiple parents: %s %s",
oid, track.parent, parent)
}
track.trackedKeys.Add(key)
parent = oid
}
_, ok := δBtail.byRoot[root]
......
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