Commit 6356b4ae authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 3cc8369b
......@@ -374,6 +374,28 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) (_ ΔF, err error) {
// ForgetPast discards all δFtail entries with rev ≤ revCut.
func (δFtail *ΔFtail) ForgetPast(revCut zodb.Tid) {
δFtail.δBtail.ForgetPast(revCut)
// XXX locking
// XXX keep index which file changed epoch where (similarly to ΔBtail),
// and, instead of scanning all files, trim vδE only on files that is really necessary.
for _, δftail := range δFtail.byFile {
δftail.forgetPast(revCut)
}
}
func (δftail *_ΔFileTail) forgetPast(revCut zodb.Tid) {
// XXX locking
icut := 0
for ; icut < len(δftail.vδE); icut++ {
if δftail.vδE[icut].Rev > revCut {
break
}
}
// vδE[:icut] should be forgotten
if icut > 0 { // XXX workarond for ΔFtail.ForgetPast calling forgetPast on all files
δftail.vδE = append([]_ΔFileEpoch(nil), δftail.vδE[icut:]...)
}
}
// XXX don't need
......
......@@ -177,6 +177,9 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
t := xbtreetest.NewT(t_)
X := exc.Raiseif
// XXX start δFtail when zfile is not yet exists
// this way we'll verify how ΔFtail rebuilds vδE for started-to-be-tracked file
δFtail := NewΔFtail(t.Head().At, t.DB)
// load zfile via root['treegen/file']
......@@ -187,7 +190,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
err = zroot.PActivate(ctx); X(err)
zfile := zroot.Data["treegen/file"].(*ZBigFile)
zroot.PDeactivate()
zfileOid := zfile.POid()
foid := zfile.POid()
err = zfile.PActivate(ctx); X(err)
blktabOid := zfile.blktab.POid()
if blktabOid != t.Root() {
......@@ -400,7 +403,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
}
δfilesOK := setOid{}
if δfok != nil {
δfilesOK.Add(zfileOid)
δfilesOK.Add(foid)
}
if !δfiles.Equal(δfilesOK) {
t.Errorf("wrong δF.ByFile:\nhave keys: %s\nwant keys: %s", δfiles, δfilesOK)
......@@ -408,7 +411,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
}
// verify δf
δf := δF.ByFile[zfileOid]
δf := δF.ByFile[foid]
if !reflect.DeepEqual(δf, δfok) {
t.Errorf("δf:\nhave: %v\nwant: %v", δf, δfok)
}
......@@ -451,6 +454,19 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
//t.Logf("# vδt: %s", vδfstr(δFtail.SliceByFileRev(zfile, δFtail.Tail(), δFtail.Head())))
}
// verify vδE
vδEok := []_ΔFileEpoch{}
for _, δf := range vδf {
if δf.Epoch {
vδEok = append(vδEok, _ΔFileEpoch{Rev: δf.Rev}) // XXX + root,size
}
}
δftail := δFtail.byFile[foid]
if !reflect.DeepEqual(δftail.vδE, vδEok) {
t.Errorf("vδE:\nhave: %v\nwant: %v", δftail.vδE, vδEok)
}
// SliceByFileRev
for j := 0; j < len(vδf); j++ {
for k := j; k < len(vδf); k++ {
......
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