Commit 53148c8e authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 55d3f53c
...@@ -616,6 +616,7 @@ type BigFile struct { ...@@ -616,6 +616,7 @@ type BigFile struct {
// δtail *ΔTailI64 // [](rev↑, []#blk) // δtail *ΔTailI64 // [](rev↑, []#blk)
// blocks that were ever read-accessed (head/ only) XXX locking by bfdir.δFmu ? // blocks that were ever read-accessed (head/ only) XXX locking by bfdir.δFmu ?
// XXX = δFtail.Tracked(f) ?
accessed SetI64 accessed SetI64
// inflight loadings of ZBigFile from ZODB. // inflight loadings of ZBigFile from ZODB.
...@@ -1275,9 +1276,9 @@ func (f *BigFile) readBlk(ctx context.Context, blk int64, dest []byte) (err erro ...@@ -1275,9 +1276,9 @@ func (f *BigFile) readBlk(ctx context.Context, blk int64, dest []byte) (err erro
// into missing both kernel pagecache (if not yet updated) and empty .loading[blk], // into missing both kernel pagecache (if not yet updated) and empty .loading[blk],
// and thus would trigger DB access again. // and thus would trigger DB access again.
// //
// XXX if direct-io: don't touch pagecache // TODO if direct-io: don't touch pagecache
// XXX upload parts only not covered by currrent read (not to e.g. wait for page lock) // TODO upload parts only not covered by currrent read (not to e.g. wait for page lock)
// XXX skip upload completely if read is wide to cover whole blksize // TODO skip upload completely if read is wide to cover whole blksize
go f.uploadBlk(blk, loading) go f.uploadBlk(blk, loading)
return nil return nil
......
...@@ -165,7 +165,7 @@ type ΔBtail struct { ...@@ -165,7 +165,7 @@ type ΔBtail struct {
δZtail *zodb.ΔTail δZtail *zodb.ΔTail
// XXX vvv keys ∈ tracked -> keys ∈ kadj[tracked] ? // XXX vvv keys ∈ tracked -> keys ∈ kadj[tracked] ?
// δRtail []ΔRoots // which BTree were changed; Noted only by keys ∈ tracked subset // vδB []ΔB // data with δB changes; Noted only by keys ∈ tracked subset
byRoot map[zodb.Oid]*ΔTtail // {} root -> [] k/v change history; only for keys ∈ tracked subset byRoot map[zodb.Oid]*ΔTtail // {} root -> [] k/v change history; only for keys ∈ tracked subset
// handle to make connections to access database. // handle to make connections to access database.
...@@ -184,6 +184,34 @@ type ΔBtail struct { ...@@ -184,6 +184,34 @@ type ΔBtail struct {
// trackNew SetOid // trackNew SetOid
} }
// ΔB represents a change in BTrees space.
type ΔB struct {
Rev zodb.Tid
ByRoot map[zodb.Oid]map[Key]ΔValue // {} root -> {}(key, δvalue)
}
// ΔTtail represent tail of revisional changes to one BTree.
//
// See ΔBtail documentation for details.
type ΔTtail struct {
vδT []ΔTree // changes to tree keys; rev↑. covers keys ∈ tracked subset
// {}k/v @tail for keys that are changed in (tail, head].
KVAtTail map[Key]Value // XXX not needed since vδT has ΔValue ?
// index for LastRevOf queries
lastRevOf map[Key]zodb.Tid // {} key -> last
}
// ΔTree describes changes to one BTree in one revision.
// XXX -> ΔT ?
type ΔTree struct {
Rev zodb.Tid
KV map[Key]Value // XXX Value -> ΔValue ?
}
// XXX place // XXX place
type trackIndex map[zodb.Oid]*nodeTrack type trackIndex map[zodb.Oid]*nodeTrack
...@@ -309,40 +337,6 @@ func (hi treeSetKey) GetInRange(lo, hi_ Key) SetKey { ...@@ -309,40 +337,6 @@ func (hi treeSetKey) GetInRange(lo, hi_ Key) SetKey {
return ret return ret
} }
// ΔB represents a change in BTrees space.
type ΔB struct {
Rev zodb.Tid
ByRoot map[zodb.Oid]map[Key]ΔValue // {} root -> {}(key, δvalue)
}
/*
// ΔRoots describes which BTrees were change in one revision.
type ΔRoots struct {
Rev zodb.Tid
Roots []*Tree // root XXX -> Oid? XXX -> SetTree?
}
*/
// ΔTtail represent tail of revisional changes to one BTree.
//
// See ΔBtail documentation for details.
type ΔTtail struct {
vδT []ΔTree // changes to tree keys; rev↑. covers keys ∈ tracked subset
// {}k/v @tail for keys that are changed in (tail, head].
KVAtTail map[Key]Value // XXX not needed since vδT has ΔValue ?
// index for LastRevOf queries
lastRevOf map[Key]zodb.Tid // {} key -> last
}
// ΔTree describes changes to one BTree in one revision.
// XXX -> ΔT ?
type ΔTree struct {
Rev zodb.Tid
KV map[Key]Value // XXX Value -> ΔValue ?
}
// NewΔBtail creates new empty ΔBtail object. // NewΔBtail creates new empty ΔBtail object.
// //
// Initial tracked set is empty. // Initial tracked set is empty.
...@@ -1348,13 +1342,16 @@ func (δBtail *ΔBtail) ForgetPast(revCut zodb.Tid) { ...@@ -1348,13 +1342,16 @@ func (δBtail *ΔBtail) ForgetPast(revCut zodb.Tid) {
// entries in .δZtail into account. // entries in .δZtail into account.
// func (δBtail *ΔBtail) update() // func (δBtail *ΔBtail) update()
// Get returns root[key] as of @at database state plus revision that changed it. // Get returns root[key] as of @at database state plus revision that changed it.
// //
// if revExact=False - rev is upper estimate for the revision. // if revExact=False - rev is upper estimate for the revision.
// //
// XXX at must ∈ (tail, head] XXX [tail ? // XXX at must ∈ (tail, head] XXX [tail ?
// XXX key must be tracked // XXX key must be tracked
func (δΒtail *ΔBtail) Get(ctx context.Context, root *Tree, key Key, at zodb.Tid) (value Value, ok bool, rev zodb.Tid, revExact bool, err error) { //
// XXX naming -> GetAt ?
func (δBtail *ΔBtail) Get(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) defer xerr.Contextf(&err, "δBtail: root<%s>: get %d @%s", root.POid(), key, at)
// XXX key not tracked -> panic // XXX key not tracked -> panic
// XXX at not ∈ (tail, head] -> panic // XXX at not ∈ (tail, head] -> panic
...@@ -1367,7 +1364,7 @@ func (δΒtail *ΔBtail) Get(ctx context.Context, root *Tree, key Key, at zodb.T ...@@ -1367,7 +1364,7 @@ func (δΒtail *ΔBtail) Get(ctx context.Context, root *Tree, key Key, at zodb.T
// XXX dirty -> rebuild // XXX dirty -> rebuild
// XXX -> index lastXXXOf(key) | linear scan ↓ looking for change <= at // XXX -> index lastXXXOf(key) | linear scan ↓ looking for change <= at
δTtail := δΒtail.byRoot[root.POid()] δTtail := δBtail.byRoot[root.POid()]
if δTtail == nil { if δTtail == nil {
panicf("δBtail: root<%s> not tracked", root.POid()) panicf("δBtail: root<%s> not tracked", root.POid())
} }
...@@ -1391,13 +1388,15 @@ func (δΒtail *ΔBtail) Get(ctx context.Context, root *Tree, key Key, at zodb.T ...@@ -1391,13 +1388,15 @@ func (δΒtail *ΔBtail) Get(ctx context.Context, root *Tree, key Key, at zodb.T
} }
// key not in history tail. // key not in history tail.
// either use @tail[key], if it is present, or @head[key] // either use @tail[key], if it is present, or @head[key] FIXME tail[key] must be present
rev = δΒtail.Tail() rev = δBtail.Tail()
revExact = false revExact = false
value, ok = δTtail.KVAtTail[key] value, ok = δTtail.KVAtTail[key]
if ok { if ok {
return return
} }
// FIXME this should go away (tail[key] must be present)
// @tail[key] is not present - key was not changing in (tail, head]. // @tail[key] is not present - key was not changing in (tail, head].
// since at ∈ (tail, head] we can use @head[key] as the result // since at ∈ (tail, head] we can use @head[key] as the result
xvalue, ok, err := root.Get(ctx, key) xvalue, ok, err := root.Get(ctx, key)
......
...@@ -853,6 +853,8 @@ func testΔBTail(t *testing.T, testq chan ΔBTestEntry) { ...@@ -853,6 +853,8 @@ func testΔBTail(t *testing.T, testq chan ΔBTestEntry) {
tracef("\n\n\n**** %s ****\n\n", subj) tracef("\n\n\n**** %s ****\n\n", subj)
xverifyΔBTail(t, subj, db, tg.treeRoot, at1,at2, xkv1,xkv2, δZ, test.kadjOK) xverifyΔBTail(t, subj, db, tg.treeRoot, at1,at2, xkv1,xkv2, δZ, test.kadjOK)
// XXX also verify ΔBtail.Get + ...
at1 = at2 at1 = at2
xkv1 = xkv2 xkv1 = xkv2
tree1 = tree2 tree1 = tree2
......
...@@ -476,7 +476,7 @@ func (δFtail *ΔFtail) LastBlkRev(ctx context.Context, f *BigFile, blk int64, a ...@@ -476,7 +476,7 @@ func (δFtail *ΔFtail) LastBlkRev(ctx context.Context, f *BigFile, blk int64, a
// XXX activate zfile? // XXX activate zfile?
zblkOid, ok, tabRev, tabRevExact, err := δFtail.δBtail.Get(ctx, f.zfile.blktab, blk, at) zblkOid, ok, tabRev, tabRevExact, err := δFtail.δBtail.Get(ctx, f.zfile.blktab, blk, at)
if err != nil { if err != nil {
panic(err) panic(err) // XXX
} }
// block was removed // block was removed
......
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