Commit c63dbe30 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 441e3666
...@@ -99,8 +99,8 @@ type ΔBtail struct { ...@@ -99,8 +99,8 @@ type ΔBtail struct {
trackNew map[zodb.Oid]struct{} // XXX SetOid trackNew map[zodb.Oid]struct{} // XXX SetOid
} }
// Δ represents a change in BTrees space. // ΔB represents a change in BTrees space.
type Δ struct { type ΔB struct {
Rev zodb.Tid Rev zodb.Tid
Change map[*Tree]map[Key]Value // {} root -> {}(key, value) Change map[*Tree]map[Key]Value // {} root -> {}(key, value)
} }
...@@ -206,7 +206,7 @@ func (δBtail *ΔBtail) Track(path []Node) { // XXX Tree|Bucket; path[0] = root ...@@ -206,7 +206,7 @@ func (δBtail *ΔBtail) Track(path []Node) { // XXX Tree|Bucket; path[0] = root
// only those keys, that correspond to tracked subset of δZ. // only those keys, that correspond to tracked subset of δZ.
// //
// δZ should include all objects changed by ZODB transaction. // δZ should include all objects changed by ZODB transaction.
func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) Δ { func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) ΔB {
δBtail.δZtail.Append(δZ.Tid, δZ.Changev) δBtail.δZtail.Append(δZ.Tid, δZ.Changev)
// {} root -> []oid changed under that root // {} root -> []oid changed under that root
...@@ -221,7 +221,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) Δ { ...@@ -221,7 +221,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) Δ {
} }
} }
δB := Δ{Rev: δZ.Tid, Change: make(map[*Tree]map[Key]Value)} δB := ΔB{Rev: δZ.Tid, Change: make(map[*Tree]map[Key]Value)}
if len(δZByRoot) == 0 { if len(δZByRoot) == 0 {
return δB // tracked set not changed return δB // tracked set not changed
...@@ -335,10 +335,17 @@ func (δΒtail *ΔBtail) Get(ctx context.Context, root *Tree, key Key, at zodb.T ...@@ -335,10 +335,17 @@ func (δΒtail *ΔBtail) Get(ctx context.Context, root *Tree, key Key, at zodb.T
return return
} }
// XXX SliceByRev // XXX
func (δBtail *ΔBtail) SliceByRev(lo, hi zodb.Tid) /*readonly*/ []ΔB {
δassertSlice(δBtail, lo, hi)
panic("TODO")
}
// XXX // XXX
func (δBtail *ΔBtail) SliceByRootRev(root *Tree, lo, hi zodb.Tid) /*readonly*/[]ΔTree { func (δBtail *ΔBtail) SliceByRootRev(root *Tree, lo, hi zodb.Tid) /*readonly*/[]ΔTree {
δassertSlice(δBtail, lo, hi)
panic("TODO") panic("TODO")
} }
...@@ -388,3 +395,15 @@ func (δBtail *ΔBtail) SliceByRootRev(root *Tree, lo, hi zodb.Tid) /*readonly*/ ...@@ -388,3 +395,15 @@ func (δBtail *ΔBtail) SliceByRootRev(root *Tree, lo, hi zodb.Tid) /*readonly*/
// //
// . -k(blk) -> invalidate #blk // . -k(blk) -> invalidate #blk
// . +k(blk) -> invalidate #blk (e.g. if blk was previously read as hole) // . +k(blk) -> invalidate #blk (e.g. if blk was previously read as hole)
// misc
// δassertSlice asserts that δ.tail ≤ lo ≤ hi ≤ δ.head
func δassertSlice(δ interface { Head() zodb.Tid; Tail() zodb.Tid }, lo, hi zodb.Tid) {
tail := δ.Tail()
head := δ.Head()
if !(tail <= lo && lo <= hi && hi <= head) {
panicf("invalid slice: (%s, %s]; (tail, head] = (%s, %s]", lo, hi, tail, head)
}
}
...@@ -155,15 +155,16 @@ func (δFtail *ΔFtail) ForgetPast(revCut zodb.Tid) { ...@@ -155,15 +155,16 @@ func (δFtail *ΔFtail) ForgetPast(revCut zodb.Tid) {
panic("TODO") panic("TODO")
} }
// XXX SliceByRev // XXX
func (δFtail *ΔFtail) SliceByRev(lo, hi zodb.Tid) /*readonly*/ []ΔF {
δassertSlice(δFtail, lo, hi)
// XXX SliceByFileRev panic("TODO")
}
// XXX
func (δFtail *ΔFtail) SliceByFileRev(f *BigFile, lo, hi zodb.Tid) /*readonly*/[]Δfile { func (δFtail *ΔFtail) SliceByFileRev(f *BigFile, lo, hi zodb.Tid) /*readonly*/[]Δfile {
tail := δFtail.Tail() δassertSlice(δFtail, lo, hi)
head := δFtail.Head()
if !(tail <= lo && lo <= hi && hi <= head) {
panicf("δFtail.SliceByFileRev: invalid query: (%s, %s]; (tail, head] = (%s, %s]", lo, hi, tail, head)
}
// XXX activate zfile? // XXX activate zfile?
vδT := δFtail.δBtail.SliceByRootRev(f.zfile.blktab, lo, hi) vδT := δFtail.δBtail.SliceByRootRev(f.zfile.blktab, lo, hi)
......
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