Commit effe6404 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 4a1737b4
......@@ -497,6 +497,7 @@ func (orig *ΔBtail) clone() *ΔBtail {
return klon
}
/*
// newΔTtail creates new empty ΔTtail object.
func newΔTtail() *ΔTtail {
return &ΔTtail{
......@@ -504,6 +505,7 @@ func newΔTtail() *ΔTtail {
lastRevOf: make(map[Key]zodb.Tid),
}
}
*/
// (tail, head] coverage
func (δBtail *ΔBtail) Head() zodb.Tid { return δBtail.δZtail.Head() }
......@@ -555,10 +557,12 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node) error { //
}
}
/*
_, ok := δBtail.byRoot[root]
if !ok {
δBtail.byRoot[root] = newΔTtail()
}
*/
// XXX update diff XXX here? or as separate step?
// XXX update lastRevOf
......@@ -651,9 +655,6 @@ func (δBtail *ΔBtail) rebuild() (err error) {
// XXX dup wrt Update?
δZTC, δtopsByRoot := δZConnectTracked(δZ.Changev, trackNew)
// XXX len(δtopsByRoot) == 0 -> skip
var atPrev zodb.Tid
if i > 0 {
atPrev = vδZ[i-1].Rev
......@@ -661,6 +662,17 @@ func (δBtail *ΔBtail) rebuild() (err error) {
atPrev = δBtail.δZtail.Tail()
}
δZTC, δtopsByRoot := δZConnectTracked(δZ.Changev, trackNew)
tracef("\nrebuild @%s <- @%s\n", atPrev, δZ.Rev)
tracef("δZ:\t%v\n", δZ.Changev)
tracef("trackNew: %v\n", trackNew)
tracef("trackIdx: %v\n", δBtail.trackIdx) // XXX needed?
defer tracef("\n\n")
// XXX len(δtopsByRoot) == 0 -> skip
// open ZODB connection corresponding to "current" and "prev" states
txn, ctx := transaction.New(context.TODO())
defer txn.Abort() // XXX -> into func() or don't use defer
......@@ -682,6 +694,8 @@ func (δBtail *ΔBtail) rebuild() (err error) {
return err
}
tracef("-> root<%s> δkv*: %v\n", root, δT)
if len(δT) == 0 { // an object might be resaved without change
continue
}
......@@ -700,7 +714,6 @@ func (δBtail *ΔBtail) rebuild() (err error) {
// XXX lastRevOf: ...,
}
δBtail.byRoot[root] = δTtail
}
// δTtail.vδT[i] <- merge δT*
......@@ -746,7 +759,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
// update .trackIdx and vδB from .trackNew
δBtail.rebuild()
tracef("Update @%s -> @%s\n", δBtail.Head(), δZ.Tid)
tracef("Update @%s -> @%s\n", δBtail.Head(), δZ.Tid)
tracef("δZ:\t%v\n", δZ.Changev)
tracef("trackIdx: %v\n", δBtail.trackIdx)
tracef("holeIdxByRoot: %v\n", δBtail.holeIdxByRoot)
......@@ -784,6 +797,8 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
return ΔB{}, err
}
tracef("\n-> root<%s> δkv: %v\n", root, δT)
if len(δT) > 0 { // an object might be resaved without change
δB.ByRoot[root] = δT
δTtail, 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