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

.

parent f626ec3e
......@@ -282,7 +282,7 @@ func (δBtail *ΔBtail) rebuildAll() (err error) {
for root := range trackNewRoots {
δ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 {
return err
}
......@@ -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
// keys that becomes tracked. Note: this set is potentially wider compared to what was in .trackNew.
// 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")
// XXX locking
......@@ -352,27 +352,42 @@ func (δTtail *ΔTtail) rebuild(δZtail *zodb.ΔTail, db *zodb.DB) (δtrackSet P
break
}
top := &nodeInRange{prefix: nil, lo: KeyMin, hi_: KeyMax, node: root}
V := rangeSplit{top}
for _, r := δtkeycov.AllRanges() {
lo := r.lo
for {
b, err := V.GetToLeaf(ctx, lo)
if err != nil {
return nil, err
}
widenTrackNew := func() error {
// XXX errctx, debug
txn, ctx := transaction.New(context.TODO()) // XXX
defer txn.Abort()
zhead, err := db.Open(ctx, &zodb.ConnOptions{At: δZtail.Head()}); /*X*/ if err != nil { return 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
if r.hi_ <= b.hi_ {
break
// continue with next right bucket until r coverage is complete
if r.hi_ <= b.hi_ {
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.
......@@ -384,7 +399,6 @@ func (δTtail *ΔTtail) rebuild(δZtail *zodb.ΔTail, db *zodb.DB) (δtrackSet P
δBtail.trackSet.UnionInplace(trackNew)
return δtrackSet, nil
*/
return trackNew
}
// 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