Commit 7973b942 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f626ec3e
...@@ -282,7 +282,7 @@ func (δBtail *ΔBtail) rebuildAll() (err error) { ...@@ -282,7 +282,7 @@ func (δBtail *ΔBtail) rebuildAll() (err error) {
for root := range trackNewRoots { for root := range trackNewRoots {
δTtail := δBtail.vδTbyRoot[root] // must be there δTtail := δBtail.vδTbyRoot[root] // must be there
δtrackSet, err := δTtail.rebuild(δBtail.δZtail, δBtail.db) δtrackSet, err := δTtail.rebuild(root, δBtail.δZtail, δBtail.db)
if err != nil { if err != nil {
return err return err
} }
...@@ -298,7 +298,7 @@ func (δBtail *ΔBtail) rebuildAll() (err error) { ...@@ -298,7 +298,7 @@ func (δBtail *ΔBtail) rebuildAll() (err error) {
// It returns set of nodes that must be added to ΔBtail.trackSet to account for // It returns set of nodes that must be added to ΔBtail.trackSet to account for
// keys that becomes tracked. Note: this set is potentially wider compared to what was in .trackNew. // keys that becomes tracked. Note: this set is potentially wider compared to what was in .trackNew.
// XXX place // XXX place
func (δTtail *ΔTtail) rebuild(δZtail *zodb.ΔTail, db *zodb.DB) (δtrackSet PPTreeSubSet, err error) { func (δTtail *ΔTtail) rebuild(root zodb.Oid, δZtail *zodb.ΔTail, db *zodb.DB) (δtrackSet PPTreeSubSet, err error) {
defer xerr.Context(&err, "ΔTtail rebuild") defer xerr.Context(&err, "ΔTtail rebuild")
// XXX locking // XXX locking
...@@ -352,27 +352,42 @@ func (δTtail *ΔTtail) rebuild(δZtail *zodb.ΔTail, db *zodb.DB) (δtrackSet P ...@@ -352,27 +352,42 @@ func (δTtail *ΔTtail) rebuild(δZtail *zodb.ΔTail, db *zodb.DB) (δtrackSet P
break break
} }
top := &nodeInRange{prefix: nil, lo: KeyMin, hi_: KeyMax, node: root} widenTrackNew := func() error {
V := rangeSplit{top} // XXX errctx, debug
for _, r := δtkeycov.AllRanges() {
lo := r.lo txn, ctx := transaction.New(context.TODO()) // XXX
for { defer txn.Abort()
b, err := V.GetToLeaf(ctx, lo)
if err != nil { zhead, err := db.Open(ctx, &zodb.ConnOptions{At: δZtail.Head()}); /*X*/ if err != nil { return err }
return nil, err
} xtree, err := zhead.Get(ctx, root); /*X*/ if err != nil { return err }
tree := xtree.(*Tree) // must succeed
trackNew.AddPath(b.Path()) top := &nodeInRange{prefix: nil, lo: KeyMin, hi_: KeyMax, node: tree}
V := rangeSplit{top}
for _, r := range δtkeycov.AllRanges() {
lo := r.lo
for {
b, err := V.GetToLeaf(ctx, lo); /*X*/ if err != nil { return err }
trackNew.AddPath(b.Path())
// continue with next right bucket until r coverage is complete // continue with next right bucket until r coverage is complete
if r.hi_ <= b.hi_ { if r.hi_ <= b.hi_ {
break break
}
lo = b.hi_ + 1
} }
lo = b.hi_ + 1
} }
return nil
}
err := widenTrackNew()
if err != nil {
return nil, err
} }
} }
return trackNew, nil
/* /*
// trackNew was adjusted to correspond to @tail potentially growing its key coverage. // trackNew was adjusted to correspond to @tail potentially growing its key coverage.
...@@ -384,7 +399,6 @@ func (δTtail *ΔTtail) rebuild(δZtail *zodb.ΔTail, db *zodb.DB) (δtrackSet P ...@@ -384,7 +399,6 @@ func (δTtail *ΔTtail) rebuild(δZtail *zodb.ΔTail, db *zodb.DB) (δtrackSet P
δBtail.trackSet.UnionInplace(trackNew) δBtail.trackSet.UnionInplace(trackNew)
return δtrackSet, nil return δtrackSet, nil
*/ */
return trackNew
} }
// rebuild1 rebuilds δT for single δZ. // rebuild1 rebuilds δT for single δZ.
......
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