Commit 2716a284 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 19f3a09d
...@@ -635,16 +635,24 @@ func (tidx trackIndex) AddPath(path []zodb.Oid) { ...@@ -635,16 +635,24 @@ func (tidx trackIndex) AddPath(path []zodb.Oid) {
} }
} }
// rebuild rebuilds ΔBtree taking trackNew requests into account. XXX // rebuild rebuilds ΔBtail taking trackNew requests into account. XXX
// XXX place // XXX place
func (δBtail *ΔBtail) rebuild() { func (δBtail *ΔBtail) rebuild() {
// XXX stub // XXX locking
/*
// vδT <- merge treediff(lo..hi/trackNew)
vδZ := δBtail.δZtail.Data()
for i := len(vδZ)-1; i>=0; i-- {
δZ := vδZ[i]
δZTC, δtopsByRoot := δBtail.δZConnectTracked(δZ, trackNew)
}
*/
// merge .trackNew into .trackIdx // merge .trackNew into .trackIdx
δBtail.trackIdx.Update(δBtail.trackNew) δBtail.trackIdx.Update(δBtail.trackNew)
δBtail.trackNew = trackIndex{} δBtail.trackNew = trackIndex{}
return
panic("TODO")
} }
// Update updates δB with per-object level ZODB changes. // Update updates δB with per-object level ZODB changes.
...@@ -669,7 +677,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) { ...@@ -669,7 +677,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
tracef("trackIdx: %v\n", δBtail.trackIdx) tracef("trackIdx: %v\n", δBtail.trackIdx)
tracef("holeIdxByRoot: %v\n", δBtail.holeIdxByRoot) tracef("holeIdxByRoot: %v\n", δBtail.holeIdxByRoot)
δZTC, δtopsByRoot := δBtail.δZConnectTracked(δZ) δZTC, δtopsByRoot := δZConnectTracked(δZ, δBtail.trackIdx)
δB := ΔB{Rev: δZ.Tid, ByRoot: make(map[zodb.Oid]map[Key]ΔValue)} δB := ΔB{Rev: δZ.Tid, ByRoot: make(map[zodb.Oid]map[Key]ΔValue)}
...@@ -718,13 +726,13 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) { ...@@ -718,13 +726,13 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
// for example for e.g. t₀->t₁->b₂ if δZ/T={t₀ b₂} -> δZ/TC=δZ/T+{t₁} // for example for e.g. t₀->t₁->b₂ if δZ/T={t₀ b₂} -> δZ/TC=δZ/T+{t₁}
// //
// δtopsByRoot = {} root -> {top changed nodes in that tree} // δtopsByRoot = {} root -> {top changed nodes in that tree}
func (δBtail *ΔBtail) δZConnectTracked(δZv *zodb.EventCommit) (δZTC SetOid, δtopsByRoot map[zodb.Oid]SetOid) { func δZConnectTracked(δZv *zodb.EventCommit, T trackIndex) (δZTC SetOid, δtopsByRoot map[zodb.Oid]SetOid) {
δZ := SetOid{}; for _, δ := range δZv.Changev { δZ.Add(δ) } δZ := SetOid{}; for _, δ := range δZv.Changev { δZ.Add(δ) }
δZTC = SetOid{} δZTC = SetOid{}
δtopsByRoot = map[zodb.Oid]SetOid{} δtopsByRoot = map[zodb.Oid]SetOid{}
for δ := range δZ { for δ := range δZ {
track, ok := δBtail.trackIdx[δ] track, ok := T[δ]
if !ok { if !ok {
continue // not tracked at all continue // not tracked at all
} }
...@@ -759,7 +767,7 @@ func (δBtail *ΔBtail) δZConnectTracked(δZv *zodb.EventCommit) (δZTC SetOid, ...@@ -759,7 +767,7 @@ func (δBtail *ΔBtail) δZConnectTracked(δZv *zodb.EventCommit) (δZTC SetOid,
} }
path = append(path, parent) path = append(path, parent)
trackUp, ok := δBtail.trackIdx[parent] trackUp, ok := T[parent]
if !ok { if !ok {
panicf("BUG: .p%s -> %s, but %s is not tracked", node, parent, parent) panicf("BUG: .p%s -> %s, but %s is not tracked", node, parent, parent)
} }
...@@ -1574,10 +1582,10 @@ func (δBtail *ΔBtail) GetAt(ctx context.Context, root *Tree, key Key, at zodb. ...@@ -1574,10 +1582,10 @@ func (δBtail *ΔBtail) GetAt(ctx context.Context, root *Tree, key Key, at zodb.
} }
// XXX don't need // XXX don't need
func (δBtail *ΔBtail) SliceByRev(lo, hi zodb.Tid) /*readonly*/ []ΔB { //func (δBtail *ΔBtail) SliceByRev(lo, hi zodb.Tid) /*readonly*/ []ΔB {
δassertSlice(δBtail, lo, hi) // δassertSlice(δBtail, lo, hi)
panic("TODO") // panic("TODO")
} //}
// SliceByRootRev returns history of a tree changes in (lo, hi] range. // SliceByRootRev returns history of a tree changes in (lo, hi] range.
// //
......
...@@ -1019,7 +1019,7 @@ func xverifyΔBTail_rebuild_TR(t *testing.T, db *zodb.DB, δbtail *ΔBtail, tj * ...@@ -1019,7 +1019,7 @@ func xverifyΔBTail_rebuild_TR(t *testing.T, db *zodb.DB, δbtail *ΔBtail, tj *
// XXX verify Get // XXX verify Get
// verify SliceByRootRev // verify SliceByRootRev XXX -> verify δbtail.byRoot[treeRoot] directly
l := len(vδTok) l := len(vδTok)
vatOK := make([]zodb.Tid, l) vatOK := make([]zodb.Tid, l)
t0 := tj t0 := tj
......
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