Commit 2a8b0802 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 16571605
...@@ -330,9 +330,10 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) { ...@@ -330,9 +330,10 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
δfile.Blocks = nil δfile.Blocks = nil
δfile.Size = false δfile.Size = false
// XXX + rebuild XXX not here - in track(new file)
_ = δ _ = δ
//fmt.Printf("δZBigFile: %v\n", δ) //fmt.Printf("δZBigFile: %v\n", δ)
//return ΔF{}, fmt.Errorf("ZBigFile<%s> changed @%s", oid, δZ.Tid)
} }
// fmt.Printf("-> δF: %v\n", δF) // fmt.Printf("-> δF: %v\n", δF)
...@@ -538,7 +539,7 @@ func (δFtail *ΔFtail) LastBlkRev(ctx context.Context, zf *ZBigFile, blk int64, ...@@ -538,7 +539,7 @@ func (δFtail *ΔFtail) LastBlkRev(ctx context.Context, zf *ZBigFile, blk int64,
// ---------------------------------------- // ----------------------------------------
// zfilediff ... XXX // zfilediff returns direct difference for ZBigFile<foid> old..new .
type _ΔZBigFile struct { type _ΔZBigFile struct {
blksizeOld, blksizeNew int64 blksizeOld, blksizeNew int64
blktabOld, blktabNew zodb.Oid blktabOld, blktabNew zodb.Oid
...@@ -565,7 +566,7 @@ func zfilediff(db *zodb.DB, foid zodb.Oid, old, new zodb.Tid) (δ *_ΔZBigFile, ...@@ -565,7 +566,7 @@ func zfilediff(db *zodb.DB, foid zodb.Oid, old, new zodb.Tid) (δ *_ΔZBigFile,
return diffF(ctx, a, b) return diffF(ctx, a, b)
} }
// diffF computes direct difference in between two ZBigFile objects. // diffF returns direct difference in between two ZBigFile objects.
func diffF(ctx context.Context, a, b *ZBigFile) (δ *_ΔZBigFile, err error) { func diffF(ctx context.Context, a, b *ZBigFile) (δ *_ΔZBigFile, err error) {
defer xerr.Contextf(&err, "diffF %s %s", xzodb.XidOf(a), xzodb.XidOf(b)) defer xerr.Contextf(&err, "diffF %s %s", xzodb.XidOf(a), xzodb.XidOf(b))
......
...@@ -256,49 +256,49 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) { ...@@ -256,49 +256,49 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
if epoch { if epoch {
blkTab = map[int64]string{} blkTab = map[int64]string{}
Zinblk = map[string]setI64{} Zinblk = map[string]setI64{}
} δblk = nil
} else {
// XXX else? // rebuild blkTab/Zinblk
// rebuild blkTab/Zinblk for blk, zblk := range test.δblkTab {
for blk, zblk := range test.δblkTab { zprev, ok := blkTab[blk]
zprev, ok := blkTab[blk] if ok {
if ok { delete(Zinblk[zprev], blk)
delete(Zinblk[zprev], blk) } else {
} else { zprev = ø
zprev = ø }
}
if zblk != ø { if zblk != ø {
blkTab[blk] = zblk blkTab[blk] = zblk
inblk, ok := Zinblk[zblk] inblk, ok := Zinblk[zblk]
if !ok { if !ok {
inblk = setI64{} inblk = setI64{}
Zinblk[zblk] = inblk Zinblk[zblk] = inblk
}
inblk.Add(blk)
} else {
delete(blkTab, blk)
} }
inblk.Add(blk)
} else {
delete(blkTab, blk)
}
// update δblk due to change in blkTab // update δblk due to change in blkTab
if zblk != zprev { if zblk != zprev {
δblk.Add(blk) δblk.Add(blk)
δtree = true δtree = true
}
} }
}
// rebuild dataTab // rebuild dataTab
for zblk := range test.δdataTab { for zblk := range test.δdataTab {
data, ok := dataTab[zblk] // e.g. a -> a2 data, ok := dataTab[zblk] // e.g. a -> a2
if !ok { if !ok {
t.Fatalf("BUG: blk %s not in dataTab\ndataTab: %v", zblk, dataTab) t.Fatalf("BUG: blk %s not in dataTab\ndataTab: %v", zblk, dataTab)
} }
data = fmt.Sprintf("%s%d", data[:1], i) // e.g. a4 data = fmt.Sprintf("%s%d", data[:1], i) // e.g. a4
dataTab[zblk] = data dataTab[zblk] = data
// update δblk due to change in ZBlk data // update δblk due to change in ZBlk data
for blk := range Zinblk[zblk] { for blk := range Zinblk[zblk] {
δblk.Add(blk) δblk.Add(blk)
}
} }
} }
...@@ -337,10 +337,10 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) { ...@@ -337,10 +337,10 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
err = zconn.Resync(ctx, commit.At); X(err) err = zconn.Resync(ctx, commit.At); X(err)
var δfok *ΔFile var δfok *ΔFile
if len(δblk) != 0 { if epoch || len(δblk) != 0 {
δfok = &ΔFile{ δfok = &ΔFile{
Rev: commit.At, Rev: commit.At,
Epoch: epoch, // XXX epoch -> blocks/size = nil ? Epoch: epoch,
Blocks: δblk, Blocks: δblk,
Size: δtree, // not strictly ok, but matches current ΔFtail code Size: δtree, // not strictly ok, but matches current ΔFtail code
} }
......
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