Commit c0e34350 authored by Kirill Smelkov's avatar Kirill Smelkov

.

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