Commit 47e0730a authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent b3a7ce65
......@@ -146,25 +146,13 @@ type ΔFtail struct {
byFile map[zodb.Oid]*_ΔFileTail // file -> vδf tail
byRoot map[zodb.Oid]*_RootTrack // tree-root -> ({foid}, Zinblk) as of @head
// filesByRoot map[zodb.Oid]setOid // tree-root -> {} ZBigFile<oid> as of @head
// set of files, which are newly tracked and for which byFile[foid].vδE was not yet rebuilt
ftrackNew setOid // {}foid
// set of tracked ZBlk objects mapped to trees as of @head
// XXX -> Zinroot ? ztrackInRoot ?
ztrackInRoots map[zodb.Oid]setOid // {} zblk -> {}root
/*
// set of tracked ZBlk objects reverse-mapped to trees and block numbers
//
// XXX split -> :
// ΔFtail.trackSetZBlkRoots {} zblk -> {root}
// δftail.trackSetZBlkBlocks {} zblk -> {blk} in tha file/root (shared by all files with same root ?)
trackSetZBlk map[zodb.Oid]*zblkTrack // zblk -> {} root -> {}blk as of @head
ztrackRoots
*/
// XXX -> ztrackInRoot ?
zinroot map[zodb.Oid]setOid // {} zblk -> {}root
}
// _ΔFileTail represents tail of revisional changes to one file.
......@@ -184,14 +172,15 @@ type _ΔFileEpoch struct {
newBlkSize int64 // .blksize was changed to newBlkSize ; ----//----
// snapshot of trackSetZBlk for this file right before this epoch
// oldTrackSetZBlk map[zodb.Oid]setI64 // {} zblk -> {}blk
oldZinblk map[zodb.Oid]setI64 // {} zblk -> {}blk
}
// _RootTrack represents tracking information about one particular tree as of @head.
// XXX -> _TreeTrack ? _BlktabTrack ?
type _RootTrack struct {
// XXX -> ftrackSet ?
files setOid // {}foid which ZBigFiles refer to this tree
// XXX -> ztrackInBlk ?
Zinblk map[zodb.Oid]setI64 // {} zblk -> {}blk which blocks map to zblk
}
......@@ -233,11 +222,11 @@ type ΔFile struct {
// ZODB when needed.
func NewΔFtail(at0 zodb.Tid, db *zodb.DB) *ΔFtail {
return &ΔFtail{
δBtail: xbtree.NewΔBtail(at0, db),
byFile: map[zodb.Oid]*_ΔFileTail{},
byRoot: map[zodb.Oid]*_RootTrack{},
ftrackNew: setOid{},
ztrackInRoots: map[zodb.Oid]setOid{},
δBtail: xbtree.NewΔBtail(at0, db),
byFile: map[zodb.Oid]*_ΔFileTail{},
byRoot: map[zodb.Oid]*_RootTrack{},
ftrackNew: setOid{},
zinroot: map[zodb.Oid]setOid{},
}
}
......@@ -307,10 +296,10 @@ func (δFtail *ΔFtail) Track(file *ZBigFile, blk int64, path []btree.LONode, bl
if zblk != nil {
zoid := zblk.POid()
inroot, ok := δFtail.ztrackInRoots[zoid]
inroot, ok := δFtail.zinroot[zoid]
if !ok {
inroot = make(setOid, 1)
δFtail.ztrackInRoots[zoid] = inroot
δFtail.zinroot[zoid] = inroot
}
inroot.Add(root)
......@@ -455,7 +444,7 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
if ok {
for zoid, inblk := range rt.Zinblk {
δE.oldZinblk[zoid] = inblk.Clone()
inroot, ok := δFtail.ztrackInRoots[zoid]
inroot, ok := δFtail.zinroot[zoid]
if ok {
inroot.Del(δftail.root)
}
......@@ -502,8 +491,15 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
inblk, ok := rt.Zinblk[δzblk.Old]
if ok {
inblk.Del(blk)
if len(inblk) == 0 {
delete(rt.Zinblk, δzblk.Old)
inroot := δFtail.zinroot[δzblk.Old]
inroot.Del(root)
if len(inroot) == 0 {
delete(δFtail.zinroot, δzblk.Old)
}
}
}
// XXX update Zinroot (potentially del)
}
if δzblk.New != xbtree.VDEL {
......@@ -511,16 +507,21 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
if !ok {
inblk = make(setI64, 1)
rt.Zinblk[δzblk.New] = inblk
inroot, ok := δFtail.zinroot[δzblk.New]
if !ok {
inroot = make(setOid, 1)
δFtail.zinroot[δzblk.New] = inroot
}
inroot.Add(root)
}
inblk.Add(blk)
// XXX update Zinroot (add)
}
}
}
// take zblk changes into account
for _, oid := range δZ.Changev {
inroot, ok := δFtail.ztrackInRoots[oid]
inroot, ok := δFtail.zinroot[oid]
if !ok {
continue // not tracked
}
......@@ -564,6 +565,7 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
rt.files.Del(foid)
if len(rt.files) == 0 {
delete(δFtail.byRoot, δ.blktabOld)
// XXX reset Zinroot -= δ.blktabNew
}
}
}
......@@ -573,6 +575,7 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
rt = &_RootTrack{
files: setOid{},
Zinblk: map[zodb.Oid]setI64{},
// XXX reset Zinroot -= δ.blktabNew
}
δFtail.byRoot[δ.blktabNew] = rt
}
......
......@@ -445,31 +445,11 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
retrackAll()
}
// verify byRoot, Zinroot
trackZinroot := map[string]setOid{}
// verify byRoot
trackRfiles := map[zodb.Oid]setOid{}
for root, rt := range δFtail.byRoot {
trackRfiles[root] = rt.files
for zoid := range rt.Zinblk {
zblki := commit.ZBlkTab[zoid]
inroot, ok := trackZinroot[zblki.Name]
if !ok {
inroot = setOid{}
trackZinroot[zblki.Name] = inroot
}
inroot.Add(root)
}
}
Zinroot := map[string]setOid{}
for zblk := range Zinblk {
inroot := setOid{}; inroot.Add(t.Root())
Zinroot[zblk] = inroot
}
if !reflect.DeepEqual(trackZinroot, Zinroot) {
t.Errorf("Zinroot:\nhave: %v\n want: %v", trackZinroot, Zinroot)
}
filesOK := setOid{}
if !delfile {
filesOK.Add(foid)
......@@ -479,7 +459,22 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
RfilesOK[t.Root()] = filesOK
}
if !reflect.DeepEqual(trackRfiles, RfilesOK) {
t.Errorf("Rfiles:\nhave: %v\n want: %v", trackRfiles, RfilesOK)
t.Errorf("Rfiles:\nhave: %v\nwant: %v", trackRfiles, RfilesOK)
}
// verify Zinroot
trackZinroot := map[string]setOid{}
for zoid, inroot := range δFtail.zinroot {
zblki := commit.ZBlkTab[zoid]
trackZinroot[zblki.Name] = inroot.Clone() // XXX clone needed?
}
Zinroot := map[string]setOid{}
for zblk := range Zinblk {
inroot := setOid{}; inroot.Add(t.Root())
Zinroot[zblk] = inroot
}
if !reflect.DeepEqual(trackZinroot, Zinroot) {
t.Errorf("Zinroot:\nhave: %v\nwant: %v", trackZinroot, Zinroot)
}
// verify Zinblk
......@@ -503,7 +498,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
t.Errorf("len(.byRoot) != (0,1) ; byRoot: %v", δFtail.byRoot)
}
if !reflect.DeepEqual(trackZinblk, Zinblk) {
t.Errorf("Zinblk:\nhave: %v\n want: %v", trackZinblk, Zinblk)
t.Errorf("Zinblk:\nhave: %v\nwant: %v", trackZinblk, Zinblk)
}
// ForgetPast configured threshold
......
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