Commit 644bcd6a authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent aa0288ce
......@@ -432,6 +432,7 @@ func (δBtail *ΔBtail) rebuildAll() (err error) {
return nil
}
/* XXX kill
// rebuild1IfNeeded rebuilds ΔBtail for single root if that root needs rebuilding.
func (δBtail *ΔBtail) rebuild1IfNeeded(root zodb.Oid) error {
// XXX locking
......@@ -443,6 +444,7 @@ func (δBtail *ΔBtail) rebuild1IfNeeded(root zodb.Oid) error {
delete(δBtail.trackNewRoots, root)
return δBtail.rebuild1(root)
}
*/
// vδTSnapForTrackedKey returns vδT snapshot for root that takes into account at least all previous Track requests related to key.
func (δBtail *ΔBtail) vδTSnapForTrackedKey(root zodb.Oid, key Key) (vδT []ΔTree, err error) {
......@@ -579,168 +581,6 @@ func (δTtail *_ΔTtail) _runRebuildJob(root zodb.Oid, δBtail *ΔBtail) (err er
}
/*
// vδTSnapForTracked returns vδT snapshot for root that takes into account all previous Track requests.
func (δBtail *ΔBtail) vδTSnapForTracked(root zodb.Oid) (vδT []ΔTree, err error) {
// XXX δBtail.lock
δTtail := δBtail.byRoot[root] // must be there
/ * XXX check .trackNewRoots ?
_, ok := δBtail.trackNewRoots[root]
if !ok {
// XXX δBtail.unlock
return nil
}
* /
if !δTtail.ktrackNew.Has(key) {
// key ∉ ktrackNew
job, inJobs := δTtail.krebuildJobs.Get_(key)
if !inJobs {
// key ∉ krebuildJobs -> it should be already in trackSet
vδT = δTtail.vδT
// XXX δBtail.unlock
return vδT, nil
}
// rebuild for root[key] is in progress -> wait for corresponding job to complete
// XXX δBtail.unlock
<-job.ready
if job.err == nil {
// XXX δBtail.lock
vδT = δTtail.vδT
// XXX δBtail.unlock
}
return vδT, job.err
}
// key ∈ ktrackNew -> this goroutine becomes responsible to start rebuilding vδT for it
// lauch rebuild job for all keys queued in ktrackNew so far
job := &_RebuildJob{ready: make(chan struct{})}
trackNew := δTtail.trackNew
rebuildKeys := δTtail.ktrackNew
δTtail.trackNew = blib.PPTreeSubSet{}
δTtail.ktrackNew = blib.RangedKeySet{}
// krebuildJobs += rebuildKeys
for _, r := range rebuildKeys.AllRanges() {
// XXX assert !krebuildJobs.IntersectsRange(e.KeyRange)
δTtail.krebuildJobs.SetRange(r, job)
}
delete(δBtail.trackNewRoots, root)
// XXX δBtail.unlock
vδTnew, δtrackSet, err := vδTBuild(root, trackNew, δBtail.δZtail, δBtail.db)
// XXX δBtail.lock
// krebuildJobs -= rebuildKeys
for _, r := range rebuildKeys.AllRanges() {
// XXX assert krebuildJobs[r] == job
δTtail.krebuildJobs.DelRange(r)
}
// merge rebuild result
if err != nil {
// XXX comment about RCU snapshot
δTtail.vδT = vδTClone(δTtail.vδT)
δrevSet := vδTMergeInplace(&δTtail.vδT, vδTnew)
δBtail.trackSet.UnionInplace(δtrackSet)
δBtail.vδBroots_Update(root, δrevSet)
}
// we are done
job.err = err
close(job.ready)
// XXX δBtail.unlock
return job.err
}
*/
// rebuild1KeyIfNeeded rebuilds ΔBtail for single root if that root[key] needs rebuilding.
func (δBtail *ΔBtail) rebuild1KeyIfNeeded(root zodb.Oid, key Key) error {
// XXX δBtail.lock
_, ok := δBtail.trackNewRoots[root]
if !ok {
// XXX δBtail.unlock
return nil
}
// XXX move -> ΔTtail.rebuild1KeyIfNeeded?
δTtail := δBtail.byRoot[root] // must be there
// XXX δTtail.lock
// _, inNew := δTtail.ktrackNew.Get_(key)
inNew := δTtail.ktrackNew.Has(key)
if !inNew {
// key ∉ ktrackNew
job, inJobs := δTtail.krebuildJobs.Get_(key)
if !inJobs {
// key ∉ krebuildJobs -> it should be already in trackSet
// XXX δTtail.unlock
// XXX δBtail.unlock
return nil
}
// rebuild for root[key] is in progress -> wait for corresponding job to complete
// XXX δTtail.unlock
// XXX δBtail.unlock
<-job.ready
return job.err
}
// key ∈ ktrackNew -> this goroutine becomes responsible to start rebuilding vδT for it
// lauch rebuild job for all keys queued in ktrackNew so far
job := &_RebuildJob{ready: make(chan struct{})}
/*
trackNewSet := blib.PPTreeSubSet{} // trackNew corresponding to ktrackNew
rebuildKeys := blib.RangedKeySet{} // keys(ktrackNew)
for _, e := range δTtail.ktrackNew.AllRanges() {
trackNewSet.AddPath(e.Value)
rebuildKeys.AddRange(e.KeyRange)
}
*/
trackNew := δTtail.trackNew
rebuildKeys := δTtail.ktrackNew
δTtail.trackNew = blib.PPTreeSubSet{}
δTtail.ktrackNew = blib.RangedKeySet{}
// krebuildJobs += rebuildKeys
for _, r := range rebuildKeys.AllRanges() {
// XXX assert !krebuildJobs.IntersectsRange(e.KeyRange)
δTtail.krebuildJobs.SetRange(r, job)
}
delete(δBtail.trackNewRoots, root)
// XXX δTtail.unlock
// XXX δBtail.unlock
// XXX δTtail.rebuild(for trackNew) -> err
_ = trackNew
// XXX δBtail.lock ? (to update vδBroots)
// XXX δTtail.lock
// XXX merge rebuild result
// krebuildJobs -= rebuildKeys
for _, r := range rebuildKeys.AllRanges() {
// XXX assert krebuildJobs[r] == job
δTtail.krebuildJobs.DelRange(r)
}
// we are done
job.err = nil // XXX stub
close(job.ready)
// XXX unlock
return job.err
}
// rebuild1 rebuilds ΔBtail for single root.
func (δBtail *ΔBtail) rebuild1(root zodb.Oid) error {
// XXX locking
......
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