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

.

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