Commit 719088f6 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent abc32c71
......@@ -210,10 +210,6 @@ type δtrackIndex struct {
Add trackIndex
}
//func (tidx trackIndex) DelLeaf(oid zodb.Oid) {
// panic("TODO")
//}
// ApplyΔ applies δ to trackIdx. XXX
func (tidx trackIndex) ApplyΔ(δ *δtrackIndex) {
// remove leafs and thier parents
......@@ -352,10 +348,10 @@ func (δBtail *ΔBtail) Tail() zodb.Tid { return δBtail.δZtail.Tail() }
//
// XXX catch cycles on add?
func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node) error { // XXX Tree|Bucket; path[0] = root
l := len(path)
if l == 0 {
panic("empty path")
}
// l := len(path)
// if l == 0 {
// panic("empty path")
// }
// XXX assert Tree Tree ... Tree Bucket
root := path[0].(*Tree).POid()
......@@ -364,6 +360,80 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node) error { //
for _, node := range path { pathv = append(pathv, vnode(node)) }
tracef("Track [%v] %s\n", key, strings.Join(pathv, " -> "))
δBtail.trackIdx.AddPath(path)
// parent := zodb.InvalidOid
// var ptrack *nodeTrack = nil
// var track *nodeTrack // XXX kill here
// var oldTrack bool
// for _, node := range path { // XXX -> trackIndex.AddPath(path) ?
// oid := node.POid()
// // XXX skip InvalidOid ?
// // InvalidOid means embedded bucket - e.g. T/B1:a with bucket not having its own oid.
//
// track, oldTrack = δBtail.trackIdx[oid]
// if !oldTrack {
// track = &nodeTrack{parent: parent, nchild: 0} // XXX
// /*
// if i == l-1 { // leaf
// track.holes = SetKey{}
// }
// */
// δBtail.trackIdx[oid] = track
// // XXX .trackNew += oid
// }
// 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)
// }
//
// if ptrack != nil {
// ptrack.nchild++
// }
//
// parent = oid
// ptrack = track
// }
// track is track of path[-1] (i.e. leaf)
// remember missing keys in track of leaf node (bucket or top-level ø tree)
if !keyPresent {
δBtail.holeIdx.Add(key)
//track.holes.Add(key)
} else {
/*
if track.holes.Has(key) {
panicf("[%v] was previously requested to be tracked as ø", key)
}
*/
if δBtail.holeIdx.Has(key) {
panicf("[%v] was previously requested to be tracked as ø", key)
}
}
_, ok := δBtail.byRoot[root]
if !ok {
δBtail.byRoot[root] = newΔTtail()
}
// XXX update diff XXX here? or as separate step?
// XXX update lastRevOf
return nil
}
// XXX place
func (tidx trackIndex) AddPath(path []Node) { // XXX Tree|Bucket; path[0] = root
l := len(path)
if l == 0 {
panic("empty path")
}
// XXX assert Tree Tree ... Tree Bucket
// root := path[0].(*Tree).POid()
parent := zodb.InvalidOid
var ptrack *nodeTrack = nil
var track *nodeTrack // XXX kill here
......@@ -373,7 +443,7 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node) error { //
// XXX skip InvalidOid ?
// InvalidOid means embedded bucket - e.g. T/B1:a with bucket not having its own oid.
track, oldTrack = δBtail.trackIdx[oid]
track, oldTrack = tidx[oid]
if !oldTrack {
track = &nodeTrack{parent: parent, nchild: 0} // XXX
/*
......@@ -381,7 +451,7 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node) error { //
track.holes = SetKey{}
}
*/
δBtail.trackIdx[oid] = track
tidx[oid] = track
// XXX .trackNew += oid
}
if track.parent != parent {
......@@ -397,33 +467,6 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node) error { //
parent = oid
ptrack = track
}
// track is track of path[-1] (i.e. leaf)
// remember missing keys in track of leaf node (bucket or top-level ø tree)
if !keyPresent {
δBtail.holeIdx.Add(key)
//track.holes.Add(key)
} else {
/*
if track.holes.Has(key) {
panicf("[%v] was previously requested to be tracked as ø", key)
}
*/
if δBtail.holeIdx.Has(key) {
panicf("[%v] was previously requested to be tracked as ø", key)
}
}
_, ok := δBtail.byRoot[root]
if !ok {
δBtail.byRoot[root] = newΔTtail()
}
// XXX update diff XXX here? or as separate step?
// XXX update lastRevOf
return nil
}
// Update updates δB with per-object level ZODB changes.
......@@ -752,15 +795,6 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
trackIdx.ApplyΔ(δtrack)
}
/*
for oid := range trackDel {
_, present := trackIdx[oid]
if !present {
continue
}
trackIdx.DelLeaf(oid)
}
*/
/*
for leaf := range trackAdd {
node := leaf
......@@ -895,7 +929,6 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx trackIndex, h
// XXX -> trackIndex
BtrackIdx := map[zodb.Oid]nodeTrack{B.POid(): nodeTrack{parent: trackIdx[B.POid()].parent}}
trackDel := SetOid{} // leaf nodes to be removed from trackIdx after treediff
// trackAdd := SetNode{} // leaf nodes to be added to trackIdx after treediff
// phase 1: expand A top->down driven by δZTC.
......@@ -919,7 +952,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx trackIndex, h
// a is bucket -> δ-
δA, err := diffB(ctx, a, nil); /*X*/if err != nil { return nil,nil, err }
err = δMerge(δ, δA); /*X*/if err != nil { return nil,nil, err }
trackDel.Add(a.POid())
δtrack.DelLeaf.Add(a.POid())
// Bkqueue <- δA
for k := range δA {
......@@ -1042,6 +1075,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx trackIndex, h
// δ <- δB
err = δMerge(δ, δB); /*X*/if err != nil { return nil,nil, err }
δtrack.Add.AddPath(b.NodePath())
// trackAdd.Add(b)
// Akqueue <- δB
......@@ -1072,7 +1106,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackIdx trackIndex, h
// δ <- δA
err = δMerge(δ, δA); /*X*/if err != nil { return nil,nil, err }
trackDel.Add(a.node.POid())
δtrack.DelLeaf.Add(a.node.POid())
// Bkqueue <- δA
for k_ := range δA {
......
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