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,16 +352,23 @@ func (δTtail *ΔTtail) rebuild(δZtail *zodb.ΔTail, db *zodb.DB) (δtrackSet P ...@@ -352,16 +352,23 @@ 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 {
// 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
top := &nodeInRange{prefix: nil, lo: KeyMin, hi_: KeyMax, node: tree}
V := rangeSplit{top} V := rangeSplit{top}
for _, r := δtkeycov.AllRanges() { for _, r := range δtkeycov.AllRanges() {
lo := r.lo lo := r.lo
for { for {
b, err := V.GetToLeaf(ctx, lo) b, err := V.GetToLeaf(ctx, lo); /*X*/ if err != nil { return err }
if err != nil {
return nil, err
}
trackNew.AddPath(b.Path()) trackNew.AddPath(b.Path())
// continue with next right bucket until r coverage is complete // continue with next right bucket until r coverage is complete
...@@ -371,8 +378,16 @@ func (δTtail *ΔTtail) rebuild(δZtail *zodb.ΔTail, db *zodb.DB) (δtrackSet P ...@@ -371,8 +378,16 @@ func (δTtail *ΔTtail) rebuild(δZtail *zodb.ΔTail, db *zodb.DB) (δtrackSet P
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