Commit 7dc564f5 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 53571524
......@@ -157,12 +157,26 @@ func (δFtail *ΔFtail) Tail() zodb.Tid { return δFtail.δBtail.Tail() }
//
// XXX Track adds tree path to tracked set and associates path root with file.
//
// XXX objects in path and zblk must be with .PJar().At() == .head
// Objects in path and zblk must be with .PJar().At() == .head
//
// A root can be associated with several files (each provided on different Track call).
func (δFtail *ΔFtail) Track(file *ZBigFile, blk int64, path []btree.LONode, zblk ZBlk) {
// XXX locking
head := δFtail.Head()
fileAt := file.PJar().At()
if fileAt != head {
panicf("file.at (@%s) != δFtail.head (@%s)", fileAt, head)
}
if zblk != nil {
zblkAt := zblk.PJar().At()
if zblkAt != head {
panicf("zblk.at (@%s) != δFtail.head (@%s)", zblkAt, head)
}
}
// path.at == head is verified by ΔBtail.Track
foid := file.POid()
if blk == -1 {
// XXX blk = ∞ from beginning ?
......
......@@ -626,14 +626,30 @@ func TestΔFtailSliceUntrackedUniform(t_ *testing.T) {
xat[at0] = "at0"
δFtail := NewΔFtail(at0, t.DB)
// commit t1. 0 and 1 are in the same bucket.
t1 := t.CommitTree("T/B0:a,1:b")
// commit t1. all 0, 1 and 2 are in the same bucket.
t1 := t.CommitTree("T/B0:a,1:b,2:c")
xat[t1.At] = "at1"
δF, err := δFtail.Update(t1.ΔZ); X(err)
// XXX assert δF == ø
_ = δF
t2 := t.CommitTree("t0:d,1:e,2:c Da:a,b:b,c:c2,d:d,e:e") // 0:-a+d 1:-b+e δc₂
xat[t2.At] = "at2"
δF, err = δFtail.Update(t2.ΔZ); X(err)
// XXX assert δF
t3 := t.CommitTree("t0:d,1:e,2:c Da:a,b:b,c:c3,d:d3,e:e3") // δc₃ δd₃ δe₃
xat[t3.At] = "at3"
δF, err = δFtail.Update(t3.ΔZ); X(err)
// XXX assert δF
t4 := t.CommitTree("t0:d,1:e,2:c Da:a,b:b,c:c4,d:d3,e:e4") // δc₄ δe₄
xat[t4.At] = "at4"
δF, err = δFtail.Update(t4.ΔZ); X(err)
// XXX assert δF
// load zfile via root['treegen/file']
// XXX dup
txn, ctx := transaction.New(context.Background())
......@@ -681,34 +697,36 @@ func TestΔFtailSliceUntrackedUniform(t_ *testing.T) {
return fmt.Sprintf("%s", s)
}
// track 1, but do not track 0.
// blktab[0] becomes tracked by δBtail because both 0 and 1 are in the same bucket.
xtrackBlk(1)
t2 := t.CommitTree("t0:a,1:c Da:a2,b:b,c:c") // 1: -b+c, δa₂
xat[t2.At] = "at2"
δF, err = δFtail.Update(t2.ΔZ); X(err)
// XXX assert δF
t3 := t.CommitTree("t0:a,1:c Da:a3,b:b,c:c") // δa₃
xat[t3.At] = "at3"
δF, err = δFtail.Update(t3.ΔZ); X(err)
// XXX assert δF
// track 0, but do not track 1 and 2.
// blktab[1] becomes noticed by δBtail because both 0 and 1 are in the same bucket and both are changed @at2.
// blktab[2] remains unnoticed because it is not changed past at1.
xtrackBlk(0)
lo := at0
hi := t3.At
// (at1, at4]
lo := t1.At
hi := t4.At
vδf := δFtail.SliceByFileRev(zfile, lo, hi)
_01 := setI64{}; _01.Add(0); _01.Add(1)
vδf_ok := []*ΔFile{
&ΔFile{Rev: t1.At, Blocks: _01, Size: true},
&ΔFile{Rev: t2.At, Blocks: _01, Size: true},
&ΔFile{Rev: t3.At, Blocks: _01, Size: false},
&ΔFile{Rev: t2.At, Blocks: b(0,1), Size: true},
&ΔFile{Rev: t3.At, Blocks: b(0,1), Size: false},
&ΔFile{Rev: t4.At, Blocks: b(1), Size: false},
}
if !reflect.DeepEqual(vδf, vδf_ok) {
t.Errorf("slice (@%s,@%s]:\nhave: %v\nwant: %v", xat[lo], xat[hi], vδfstr(vδf), vδfstr(vδf_ok))
}
return
// XXX vvv correct
// (at2, at4]
lo = t2.At
vδf = δFtail.SliceByFileRev(zfile, lo, hi)
vδf_ok = []*ΔFile{
&ΔFile{Rev: t3.At, Blocks: b(0,1), Size: false},
&ΔFile{Rev: t4.At, Blocks: b(1), Size: false},
}
}
......@@ -734,3 +752,13 @@ func dataTabTxt(dataTab map[string]string) string {
return strings.Join(sv, ",")
}
// b is shorthand to create setI64(blocks).
func b(blocks ...int64) setI64 {
s := setI64{}
for _, blk := range blocks {
s.Add(blk)
}
return s
}
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