Commit 4fec22ea authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 54276eb7
......@@ -117,20 +117,20 @@ type _ΔTtail struct {
//
// It describes which trees were changed, but does not provide δkv details for changed trees.
type _ΔBroots struct {
Rev zodb.Tid
ΔRoots setOid // which roots changed in this revision
Rev zodb.Tid
Roots setOid // which roots changed in this revision
}
// ΔB represents a change in BTrees space.
type ΔB struct {
Rev zodb.Tid
ΔByRoot map[zodb.Oid]map[Key]ΔValue // {} root -> {}(key, δvalue)
Rev zodb.Tid
ByRoot map[zodb.Oid]map[Key]ΔValue // {} root -> {}(key, δvalue)
}
// ΔTree describes changes to one BTree in one revision.
type ΔTree struct {
Rev zodb.Tid
ΔKV map[Key]ΔValue
ΔKV map[Key]ΔValue // XXX -> KV ?
}
......@@ -174,8 +174,8 @@ func (orig *ΔBtail) Clone() *ΔBtail {
klon.vδBroots = make([]_ΔBroots, 0, len(orig.vδBroots))
for _, origδBroots := range orig.vδBroots {
klonδBroots := _ΔBroots{
Rev: origδBroots.Rev,
ΔRoots: origδBroots.ΔRoots.Clone(),
Rev: origδBroots.Rev,
Roots: origδBroots.Roots.Clone(),
}
klon.vδBroots = append(klon.vδBroots, klonδBroots)
}
......@@ -566,7 +566,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
δB1, err := δBtail._Update1(δZ)
δB := ΔB{Rev: δZ.Tid, ΔByRoot: make(map[zodb.Oid]map[Key]ΔValue)}
δB := ΔB{Rev: δZ.Tid, ByRoot: make(map[zodb.Oid]map[Key]ΔValue)}
for root, δT1 := range δB1.ByRoot {
δTtail := δBtail.vδTbyRoot[root] // must succeed
......@@ -597,7 +597,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
if l > 0 {
δT := δTtail.vδT[l-1] // δT head
if δT.Rev == δZ.Tid {
δB.ΔByRoot[root] = δT.ΔKV
δB.ByRoot[root] = δT.ΔKV
}
}
......@@ -605,7 +605,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
}
// vδBroots += δB (δB.Rev could be already there added by ^^^ rebuild)
for root := range δB.ΔByRoot {
for root := range δB.ByRoot {
δBtail.vδBroots_Update1(root, δB.Rev)
}
......@@ -704,14 +704,14 @@ func (δBtail *ΔBtail) vδBroots_Update1(root zodb.Oid, rev zodb.Tid) {
return rev <= δBtail.vδBroots[k].Rev
})
if j == l || rev != δBtail.vδBroots[j].Rev {
δBroots := _ΔBroots{Rev: rev, ΔRoots: setOid{}}
δBroots := _ΔBroots{Rev: rev, Roots: setOid{}}
// insert(@j, δBroots)
δBtail.vδBroots = append(δBtail.vδBroots[:j],
append([]_ΔBroots{δBroots},
δBtail.vδBroots[j:]...)...)
}
δBroots := δBtail.vδBroots[j]
δBroots.ΔRoots.Add(root)
δBroots.Roots.Add(root)
}
// ForgetPast forgets history entries with revision ≤ revCut.
......@@ -729,7 +729,7 @@ func (δBtail *ΔBtail) ForgetPast(revCut zodb.Tid) {
if δBroots.Rev > revCut {
break
}
totrim.Update(δBroots.ΔRoots)
totrim.Update(δBroots.Roots)
}
// vδBroots[:icut] should be forgotten
......
......@@ -757,20 +757,20 @@ func xverifyΔBTail_Update1(t *testing.T, subj string, db *zodb.DB, treeRoot zod
rootsOK.Add(treeRoot)
}
roots := setOid{}
for root := range δB.ΔByRoot {
for root := range δB.ByRoot {
roots.Add(root)
}
if !reflect.DeepEqual(roots, rootsOK) {
badf("δB: roots != rootsOK ; roots=%v rootsOK=%v", roots, rootsOK)
}
_, inδB := δB.ΔByRoot[treeRoot]
_, inδB := δB.ByRoot[treeRoot]
if !inδB {
return
}
// δT <- δB
δToid := δB.ΔByRoot[treeRoot] // {} k -> δoid
δToid := δB.ByRoot[treeRoot] // {} k -> δoid
δT = xgetδKV(t1,t2, δToid) // {} k -> δ(ZBlk(oid).data)
// δT must be subset of d12.
......@@ -1020,15 +1020,15 @@ func xverifyΔBTail_rebuild_U(t *testing.T, δbtail *ΔBtail, treeRoot zodb.Oid,
for root := range δbtail.vδTbyRoot {
δroots.Add(root)
}
δToid, ok := δB.ΔByRoot[treeRoot]
δToid, ok := δB.ByRoot[treeRoot]
if ok {
δT = xgetδKV(ti, tj, δToid)
}
if δB.Rev != tj.At {
t.Errorf("%s: δB.Rev: have %s ; want %s", subj, δB.Rev, tj.At)
}
if len(δB.ΔByRoot) != δrootsOK {
t.Errorf("%s: len(δB.ΔByRoot) != %d ; δroots=%v", subj, δrootsOK, δroots)
if len(δB.ByRoot) != δrootsOK {
t.Errorf("%s: len(δB.ByRoot) != %d ; δroots=%v", subj, δrootsOK, δroots)
}
if !δTEqual(δT, δTok) {
t.Errorf("%s: δB.ΔBByRoot[%s]:\nhave: %v\nwant: %v", subj, treeRoot, δT, δTok)
......@@ -1554,7 +1554,7 @@ func assertΔTtail(t *testing.T, subj string, δbtail *ΔBtail, tj *xbtreetest.C
var vatδB []zodb.Tid // δbtail.vδBroots/treeRoot
for _, δBroots := range δbtail.vδBroots {
if δBroots.ΔRoots.Has(treeRoot) {
if δBroots.Roots.Has(treeRoot) {
vatδB = append(vatδB, δBroots.Rev)
}
}
......
......@@ -305,13 +305,13 @@ func (δFtail *ΔFtail) rebuildIfNeeded(foid zodb.Oid) (_ *_ΔFileTail, err erro
return δftail, err
}
// rebuild rebuilds vδE.
// rebuild1 rebuilds vδE.
func (δftail *_ΔFileTail) rebuild1(foid zodb.Oid, δZtail *zodb.ΔTail, db *zodb.DB) (err error) {
defer xerr.Contextf(&err, "file<%s>: rebuild", foid)
// XXX locking
if δftail.vδE != nil {
panic("rebuild: vδE != nil")
panic("rebuild1: vδE != nil")
}
vδE := []_ΔFileEpoch{}
......@@ -372,7 +372,6 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
}
headOld := δFtail.Head()
δB, err := δFtail.δBtail.Update(δZ)
if err != nil {
return ΔF{}, err
......@@ -418,8 +417,8 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
}
// take btree changes into account
//fmt.Printf("δB.ΔByRoot: %v\n", δB.ΔByRoot)
for root, δt := range δB.ΔByRoot {
//fmt.Printf("δB.ByRoot: %v\n", δB.ByRoot)
for root, δt := range δB.ByRoot {
//fmt.Printf("root: %v δt: %v\n", root, δt)
files := δFtail.filesByRoot[root]
// NOTE files might be empty e.g. if a zfile was tracked, then
......
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