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

.

parent 55d3f53c
......@@ -616,6 +616,7 @@ type BigFile struct {
// δtail *ΔTailI64 // [](rev↑, []#blk)
// blocks that were ever read-accessed (head/ only) XXX locking by bfdir.δFmu ?
// XXX = δFtail.Tracked(f) ?
accessed SetI64
// inflight loadings of ZBigFile from ZODB.
......@@ -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],
// and thus would trigger DB access again.
//
// XXX if direct-io: don't touch pagecache
// XXX 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 if direct-io: don't touch pagecache
// TODO upload parts only not covered by currrent read (not to e.g. wait for page lock)
// TODO skip upload completely if read is wide to cover whole blksize
go f.uploadBlk(blk, loading)
return nil
......
......@@ -165,7 +165,7 @@ type ΔBtail struct {
δZtail *zodb.ΔTail
// 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
// handle to make connections to access database.
......@@ -184,6 +184,34 @@ type ΔBtail struct {
// 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
type trackIndex map[zodb.Oid]*nodeTrack
......@@ -309,40 +337,6 @@ func (hi treeSetKey) GetInRange(lo, hi_ Key) SetKey {
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.
//
// Initial tracked set is empty.
......@@ -1348,13 +1342,16 @@ func (δBtail *ΔBtail) ForgetPast(revCut zodb.Tid) {
// entries in .δZtail into account.
// func (δBtail *ΔBtail) update()
// Get returns root[key] as of @at database state plus revision that changed it.
//
// if revExact=False - rev is upper estimate for the revision.
//
// XXX at must ∈ (tail, head] XXX [tail ?
// 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)
// XXX key not tracked -> 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
// XXX dirty -> rebuild
// XXX -> index lastXXXOf(key) | linear scan ↓ looking for change <= at
δTtail := δΒtail.byRoot[root.POid()]
δTtail := δBtail.byRoot[root.POid()]
if δTtail == nil {
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
}
// key not in history tail.
// either use @tail[key], if it is present, or @head[key]
rev = δΒtail.Tail()
// either use @tail[key], if it is present, or @head[key] FIXME tail[key] must be present
rev = δBtail.Tail()
revExact = false
value, ok = δTtail.KVAtTail[key]
if ok {
return
}
// FIXME this should go away (tail[key] must be present)
// @tail[key] is not present - key was not changing in (tail, head].
// since at ∈ (tail, head] we can use @head[key] as the result
xvalue, ok, err := root.Get(ctx, key)
......
......@@ -853,6 +853,8 @@ func testΔBTail(t *testing.T, testq chan ΔBTestEntry) {
tracef("\n\n\n**** %s ****\n\n", subj)
xverifyΔBTail(t, subj, db, tg.treeRoot, at1,at2, xkv1,xkv2, δZ, test.kadjOK)
// XXX also verify ΔBtail.Get + ...
at1 = at2
xkv1 = xkv2
tree1 = tree2
......
......@@ -476,7 +476,7 @@ func (δFtail *ΔFtail) LastBlkRev(ctx context.Context, f *BigFile, blk int64, a
// XXX activate zfile?
zblkOid, ok, tabRev, tabRevExact, err := δFtail.δBtail.Get(ctx, f.zfile.blktab, blk, at)
if err != nil {
panic(err)
panic(err) // XXX
}
// 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