Commit c0e34350 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 67fbcf8e
......@@ -96,8 +96,7 @@ type ΔFtail struct {
// zblkTrack keeps information in which root/blocks ZBlk is present as of @head.
type zblkTrack struct {
// inroot map[zodb.Oid]setI64 // {} root -> {}blk XXX later switch to this
infile map[zodb.Oid]setI64 // {} foid -> {}blk
inroot map[zodb.Oid]setI64 // {} root -> {}blk XXX later switch to this
}
// ΔF represents a change in files space.
......@@ -162,10 +161,11 @@ func (δFtail *ΔFtail) Track(file *ZBigFile, blk int64, path []btree.LONode, zb
}
root := path[0].(*btree.LOBTree)
files, ok := δFtail.fileIdx[root.POid()]
roid := root.POid()
files, ok := δFtail.fileIdx[roid]
if !ok {
files = setOid{}
δFtail.fileIdx[root.POid()] = files
δFtail.fileIdx[roid] = files
}
files.Add(foid)
......@@ -180,15 +180,15 @@ func (δFtail *ΔFtail) Track(file *ZBigFile, blk int64, path []btree.LONode, zb
δFtail.trackSetZBlk[zoid] = zt
}
blocks, ok := zt.infile[foid]
inblk, ok := zt.inroot[roid]
if !ok {
blocks = make(setI64, 1)
if zt.infile == nil {
zt.infile = make(map[zodb.Oid]setI64)
inblk = make(setI64, 1)
if zt.inroot == nil {
zt.inroot = make(map[zodb.Oid]setI64)
}
zt.infile[foid] = blocks
zt.inroot[roid] = inblk
}
blocks.Add(blk)
inblk.Add(blk)
if !ok {
// zblk was not associated with this file
......@@ -249,7 +249,7 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
δfile = &ΔFile{Rev: δF.Rev, Blocks: make(setI64)}
δF.ByFile[file] = δfile
}
for blk /*, zblk*/ := range δt {
for blk /*, δzblk*/ := range δt {
// XXX document, and in particular how to include atTail
δfile.Blocks.Add(blk)
}
......@@ -260,6 +260,36 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
// XXX currently we invalidate size on any topology change.
δfile.Size = true
}
// update trackSetZBlk according to btree changes
for blk, δzblk := range δt {
if δzblk.Old != xbtree.VDEL {
ztOld, ok := δFtail.trackSetZBlk[δzblk.Old]
if ok {
inblk, ok := ztOld.inroot[root]
if ok {
inblk.Del(blk)
}
}
}
if δzblk.New != xbtree.VDEL {
ztNew, ok := δFtail.trackSetZBlk[δzblk.New]
if !ok {
ztNew = &zblkTrack{}
δFtail.trackSetZBlk[δzblk.New] = ztNew
}
inblk, ok := ztNew.inroot[root]
if !ok {
inblk = make(setI64, 1)
if ztNew.inroot == nil {
ztNew.inroot = make(map[zodb.Oid]setI64)
}
ztNew.inroot[root] = inblk
}
inblk.Add(blk)
}
}
}
// take zblk changes into account
......@@ -276,17 +306,18 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
continue // not tracked
}
for foid, blocks := range zt.infile {
δfile, ok := δF.ByFile[foid]
for root, inblk := range zt.inroot {
files := δFtail.fileIdx[root]
for file := range files {
δfile, ok := δF.ByFile[file]
if !ok {
δfile = &ΔFile{Rev: δF.Rev, Blocks: make(setI64)}
δF.ByFile[foid] = δfile
δF.ByFile[file] = δfile
}
δfile.Blocks.Update(blocks)
δfile.Blocks.Update(inblk)
}
}
// XXX update zt.infile according to btree changes
}
δFtail.vδF = append(δFtail.vδF, δF)
......@@ -334,7 +365,8 @@ func (δFtail *ΔFtail) update(file *ZBigFile) {
δF.ByFile[foid] = δfile
}
δfile.Blocks.Update(z.infile[foid])
// δfile.Blocks.Update(z.infile[foid])
δfile.Blocks.Update(z.inroot[file.blktab.POid()]) // XXX need .blktab.PActivate
}
}
}
......
......@@ -203,9 +203,9 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
trackZinblk := map[string]setI64{}
for oid, zt := range δftail.trackSetZBlk {
zblki := commit.ZBlkTab[oid]
for foid, blocks := range zt.infile {
if foid != zfileOid {
t.Errorf(".trackSetZBlk: zblk %s points to unexpected file %s", zblki.Name, foid)
for root, blocks := range zt.inroot {
if root != zfile.blktab.POid() {
t.Errorf(".trackSetZBlk: zblk %s points to unexpected blktab %s", zblki.Name, zfile.blktab.POid())
continue
}
......
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