Commit 190617f5 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e072a39f
...@@ -43,18 +43,12 @@ const debugΔBtail = false ...@@ -43,18 +43,12 @@ const debugΔBtail = false
// It semantically consists of // It semantically consists of
// //
// []δB ; rev ∈ (tail, head] // []δB ; rev ∈ (tail, head]
// atTail XXX no need (see vvv)
// //
// where δB represents a change in BTrees space // where δB represents a change in BTrees space
// //
// δB: // δB:
// .rev↑ // .rev↑
// {} root -> {}(key, δvalue) XXX was value // {} root -> {}(key, δvalue)
//
// and atTail keeps set of k/v @tail for keys changed in (tail, head]
//
// atTail: XXX no need for atTail as we have δvalue.Old
// {} root -> {}(key, value)
// //
// It covers only changes to keys from tracked subset of BTrees parts. // It covers only changes to keys from tracked subset of BTrees parts.
// In particular a key that was not explicitly requested to be tracked, even if // In particular a key that was not explicitly requested to be tracked, even if
...@@ -62,7 +56,7 @@ const debugΔBtail = false ...@@ -62,7 +56,7 @@ const debugΔBtail = false
// //
// ΔBtail provides the following operations: // ΔBtail provides the following operations:
// //
// .Track(path) - start tracking tree nodes and keys; root=path[0], keys=path[-1].keys XXX keys not correct - e.g. track missing key // .Track(path) - start tracking tree nodes and keys; root=path[0], keys=path[-1].(lo,hi]
// //
// .Update(δZ) -> δB - update BTree δ tail given raw ZODB changes // .Update(δZ) -> δB - update BTree δ tail given raw ZODB changes
// .ForgetPast(revCut) - forget changes past revCut // .ForgetPast(revCut) - forget changes past revCut
...@@ -80,7 +74,7 @@ const debugΔBtail = false ...@@ -80,7 +74,7 @@ const debugΔBtail = false
// //
// XXX incremental; not full coverage // XXX incremental; not full coverage
// //
// ΔBtail is not safe for concurrent access. // ΔBtail is not safe for concurrent access. XXX rework
// XXX -> multiple readers / single writer? // XXX -> multiple readers / single writer?
// //
// See also zodb.ΔTail // See also zodb.ΔTail
...@@ -775,7 +769,8 @@ func (δTtail *ΔTtail) forgetPast(revCut zodb.Tid) { ...@@ -775,7 +769,8 @@ func (δTtail *ΔTtail) forgetPast(revCut zodb.Tid) {
// //
// XXX root -> Oid ? // XXX root -> Oid ?
func (δBtail *ΔBtail) GetAt(ctx context.Context, root *Tree, key Key, at zodb.Tid) (value Value, ok bool, rev zodb.Tid, revExact bool, err error) { func (δBtail *ΔBtail) GetAt(ctx context.Context, root *Tree, key Key, at zodb.Tid) (value Value, ok bool, rev zodb.Tid, revExact bool, err error) {
defer xerr.Contextf(&err, "δBtail: root<%s>: get %d @%s", root.POid(), key, at) rootOid := root.POid()
defer xerr.Contextf(&err, "δBtail: root<%s>: get %d @%s", rootOid, key, at)
// XXX key not tracked -> panic // XXX key not tracked -> panic
// XXX at not ∈ (tail, head] -> panic // XXX at not ∈ (tail, head] -> panic
...@@ -786,14 +781,14 @@ func (δBtail *ΔBtail) GetAt(ctx context.Context, root *Tree, key Key, at zodb. ...@@ -786,14 +781,14 @@ func (δBtail *ΔBtail) GetAt(ctx context.Context, root *Tree, key Key, at zodb.
panicf("δBtail: root.at (@%s) != head (@%s)", rootAt, δBtail.Head()) panicf("δBtail: root.at (@%s) != head (@%s)", rootAt, δBtail.Head())
} }
err = δBtail.rebuild1IfNeeded(root.POid()) err = δBtail.rebuild1IfNeeded(rootOid)
if err != nil { if err != nil {
return return
} }
δTtail := δBtail.vδTbyRoot[root.POid()] δTtail := δBtail.vδTbyRoot[rootOid]
if δTtail == nil { if δTtail == nil {
panicf("δBtail: root<%s> not tracked", root.POid()) panicf("δBtail: root<%s> not tracked", rootOid)
} }
// XXX -> index lastXXXOf(key) | linear scan ↓ looking for change <= at // XXX -> index lastXXXOf(key) | linear scan ↓ looking for change <= at
...@@ -823,12 +818,12 @@ func (δBtail *ΔBtail) GetAt(ctx context.Context, root *Tree, key Key, at zodb. ...@@ -823,12 +818,12 @@ func (δBtail *ΔBtail) GetAt(ctx context.Context, root *Tree, key Key, at zodb.
return return
} }
// key not in history tail at all. // δBtail[key] is not present - key was not changing in (tail, head].
// use @head[key] // since at ∈ (tail, head] as the result we can use @rev[key] for any
// rev ∈ (tail, head].
// XXX can we avoid requiring live root? //
// @tail[key] is not present - key was not changing in (tail, head]. // XXX can we avoid requiring live root? (think again afresh)
// since at ∈ (tail, head] we can use @head[key] as the result // XXX -> move handling of "key not in δBtail -> to δFtail.LastBlkRev"
xvalue, ok, err := root.Get(ctx, key) xvalue, ok, err := root.Get(ctx, key)
if !ok { if !ok {
value = VDEL value = VDEL
......
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