Commit 786dd336 authored by Kirill Smelkov's avatar Kirill Smelkov

X Size no longer tracks [0,∞) since we start tracking when zfile is non-empty

-> Always track all blocks in blkTab.
parent 46624787
...@@ -63,7 +63,7 @@ const ø = "ø" ...@@ -63,7 +63,7 @@ const ø = "ø"
// ΔFTestEntry represents one entry in ΔFtail tests. // ΔFTestEntry represents one entry in ΔFtail tests.
type ΔFTestEntry struct { type ΔFTestEntry struct {
δblkTab map[int64]string // changes in tree part {} #blk -> ZBlk<name> δblkTab map[int64]string // changes in tree part {} #blk -> ZBlk<name>
δdataTab setStr // changes to ZBlk objects δdataTab setStr // changes to ZBlk objects
} }
...@@ -177,19 +177,20 @@ func TestΔFtailRandom(t *testing.T) { ...@@ -177,19 +177,20 @@ func TestΔFtailRandom(t *testing.T) {
testΔFtail(t, testq) testΔFtail(t, testq)
} }
// testΔFtail verifies ΔFtail on sequence on testcases coming from testq. // testΔFtail verifies ΔFtail on sequence of testcases coming from testq.
func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) { func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
t := xbtreetest.NewT(t_) t := xbtreetest.NewT(t_)
X := exc.Raiseif X := exc.Raiseif
xat := map[zodb.Tid]string{} // tid > "at<i>" xat := map[zodb.Tid]string{} // tid -> "at<i>"
// start δFtail when zfile does not yet exists // data built via applying changes from testv
// this way we'll verify how ΔFtail rebuilds vδE for started-to-be-tracked file vδf := []*ΔFile{} // (rev↑, {}blk)
t0 := t.CommitTree("øf") vδE := []_ΔFileEpoch{} // (rev↑, EPOCH)
xat[t0.At] = "at0" blkTab := map[int64]string{} // #blk -> ZBlk<name>
t.Logf("# @at0 (%s)", t0.At) Zinblk := map[string]setI64{} // ZBlk<name> -> which #blk refer to it
δFtail := NewΔFtail(t.Head().At, t.DB) blkRevAt := map[zodb.Tid]map[int64]zodb.Tid{} // {} at -> {} #blk -> rev
epochv := []zodb.Tid{} // XXX vs vδE ?
// load dataTab // load dataTab
dataTab := map[string]string{} // ZBlk<name> -> data dataTab := map[string]string{} // ZBlk<name> -> data
...@@ -197,10 +198,24 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) { ...@@ -197,10 +198,24 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
dataTab[zblki.Name] = zblki.Data dataTab[zblki.Name] = zblki.Data
} }
// start δFtail when zfile does not yet exists
// this way we'll verify how ΔFtail rebuilds vδE for started-to-be-tracked file
t0 := t.CommitTree("øf")
xat[t0.At] = "at0"
t.Logf("# @at0 (%s)", t0.At)
epochv = append(epochv, t0.At)
δFtail := NewΔFtail(t.Head().At, t.DB)
// create zfile, but do not track it yet // create zfile, but do not track it yet
t1 := t.CommitTree(fmt.Sprintf("t0:a D%s", dataTabTxt(dataTab))) // vδf + friends will be updated after "load zfile"
δt1 := map[int64]string{0:"a"}
t1 := t.CommitTree(fmt.Sprintf("t%s D%s", xbtreetest.KVTxt(δt1), dataTabTxt(dataTab)))
xat[t1.At] = "at1" xat[t1.At] = "at1"
t.Logf("# → @at1 (%s) %s\t; not-yet-tracked", t1.At, t1.Tree) δblk1 := setI64{}
for blk := range δt1 {
δblk1.Add(blk)
}
t.Logf("# → @at1 (%s) δT%s δD{} ; %s\tδ%s *not-yet-tracked", t1.At, xbtreetest.KVTxt(δt1), t1.Tree, δblk1)
δF, err := δFtail.Update(t1.ΔZ); X(err) δF, err := δFtail.Update(t1.ΔZ); X(err)
if !(δF.Rev == t1.At && len(δF.ByFile) == 0) { if !(δF.Rev == t1.At && len(δF.ByFile) == 0) {
t.Errorf("wrong δF:\nhave {%s, %v}\nwant: {%s, ø}", δF.Rev, δF.ByFile, t1.At) t.Errorf("wrong δF:\nhave {%s, %v}\nwant: {%s, ø}", δF.Rev, δF.ByFile, t1.At)
...@@ -223,45 +238,39 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) { ...@@ -223,45 +238,39 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
} }
zfile.PDeactivate() zfile.PDeactivate()
// start track zfile[0,∞) from the beginning // update vδf + co for t1
// this should make ΔFtail to see all zfile changes vδf = append(vδf, &ΔFile{Rev: t1.At, Epoch: true})
size, path, err := zfile.Size(ctx); X(err) vδE = append(vδE, _ΔFileEpoch{
δFtail.Track(zfile, /*blk*/-1, path, /*zblk*/nil) Rev: t1.At,
if sizeOK := 1*blksize; size != sizeOK { // NOTE maches t1 commit oldRoot: zodb.InvalidOid,
t.Fatalf("BUG: zfile size: have %d ; want %d", size, sizeOK) newRoot: blktabOid,
newBlkSize: blksize,
oldTrackSetZBlk: nil,
})
epochv = append(epochv, t1.At)
for blk, zblk := range δt1 {
blkTab[blk] = zblk
inblk, ok := Zinblk[zblk]
if !ok {
inblk = setI64{}
Zinblk[zblk] = inblk
}
inblk.Add(blk)
} }
// data built via applying changes from testv
vδf := []*ΔFile{ // (rev↑, {}blk)
{Rev: t1.At, Epoch: true},
}
vδE := []_ΔFileEpoch{ // (rev↑, EPOCH)
{
Rev: t1.At,
oldRoot: zodb.InvalidOid,
newRoot: blktabOid,
newBlkSize: blksize,
oldTrackSetZBlk: nil,
},
}
blkTab := map[int64]string{} // #blk -> ZBlk<name>
Zinblk := map[string]setI64{} // ZBlk<name> -> which #blk refer to it
blkRevAt := map[zodb.Tid]map[int64]zodb.Tid{} // {} at -> {} #blk -> rev
// retrack should be called after new epoch to track zfile[-∞,∞) again // start track zfile[-∞,∞) from the beginning
// this should make ΔFtail to see all zfile changes
// ( retrack should be called after new epoch to track zfile[-∞,∞) again )
retrack := func() { retrack := func() {
for blk := range blkTab { for blk := range blkTab {
_, path, zblk, _, err := zfile.LoadBlk(ctx, blk); X(err) _, path, zblk, _, err := zfile.LoadBlk(ctx, blk); X(err)
δFtail.Track(zfile, blk, path, zblk) δFtail.Track(zfile, blk, path, zblk)
} }
} }
retrack()
epochv := []zodb.Tid{t0.At, t1.At}
blkTab[0] = "a" // matches t1
Zinblk["a"] = setI64{} // matches t1
Zinblk["a"].Add(0)
// δfstr/vδfstr converts δf/vδf to string taking xat into account // δfstr/vδfstr converts δf/vδf to string taking xat into account
δfstr := func(δf *ΔFile) string { δfstr := func(δf *ΔFile) string {
s := fmt.Sprintf("@%s·%s", xat[δf.Rev], δf.Blocks) s := fmt.Sprintf("@%s·%s", xat[δf.Rev], δf.Blocks)
......
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