Commit bb321bc9 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 1f35db44
......@@ -58,6 +58,8 @@ type Value = zodb.Oid // XXX assumes key points to IPersistent
//
// XXX which operations are provided.
//
// - GetAt(root, key, at)
//
// An example for tracked set is a set of visited BTree paths.
// There is no requirement that tracked set belongs to only one single BTree.
//
......@@ -67,7 +69,8 @@ type Value = zodb.Oid // XXX assumes key points to IPersistent
// XXX incremental; not full coverage
// XXX see also zodb.ΔTail .
//
// ΔTail is not safe for concurrent access. XXX -> is safe to use from multiple goroutines simultaneously.
// ΔTail is not safe for concurrent access.
// XXX -> multiple readers / single writer?
type ΔTail struct {
// XXX -> δZtail
ΔZtail *zodb.ΔTail // raw ZODB changes; Kept to rebuild δBtail/byRoot after new Track
......@@ -238,8 +241,6 @@ func (btail *ΔTail) Update(δZ *zodb.EventCommit) []ΔTree {
//
// XXX at must ∈ (tail, head] XXX [tail ?
// XXX key must be tracked?
//
// XXX -> meth of ΔTreeTail ?
func (btail *ΔTail) GetAt(root *Tree, key Key, at zodb.Tid) (value Value, ok bool, rev zodb.Tid, revExact bool) {
// XXX key not tracked -> panic
// XXX at not ∈ (tail, head] -> panic
......
......@@ -501,7 +501,7 @@ type BigFileDir struct {
// δ of tracked BTree nodes of all BigFiles + -> which file
// (used only for head/, not revX/)
δFmu sync.Mutex // XXX move into -> ΔFTail ?
δFmu sync.RWMutex
δFtail *ΔFTail
}
......@@ -1338,8 +1338,6 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T
// XXX wait wlink.head.zconn.At() ≥ at
// XXX <~> f.δtail.Head() ≥ at (?)
// XXX locking
if at < bfdir.δFtail.Tail() {
// XXX err += head.at?
return fmt.Errorf("at is too far away back from head/at")
......@@ -1347,6 +1345,10 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T
toPin := map[int64]zodb.Tid{} // blk -> @rev
// XXX locking ok?
bfdir.δFmu.RLock()
defer bfdir.δFmu.RUnlock()
/* XXX reenable
// FIXME (!!!) since f.δtail does not have all changes to f, here we
......
......@@ -94,39 +94,17 @@ func (δf *ΔFTail) Update(δZ *zodb.EventCommit) ΔFentry {
}
}
/* XXX kill
// LastRevOf return last_rev file[blk] @at XXX
//
// XXX -> merge into ZBigFile.LoadBlk?
// XXX ZBigFile.LoadBlk(blk) -> blkdata, rev
//
// XXX no - cannot merge - f.LastBlkRev is used for both @head (where we have
// zblk.rev) and for @w.at, where we don't have zblk.rev because we was not
// handling load and just need to pin watcher with the result.
func (δf *ΔFTail) LastRevOf(file *BigFile, blk int64, at zodb.Tid) (_ zodb.Tid, exact bool) {
// revision of when blktab[blk] entry changed last.
treeKeyRev, exact := δf.ΔTail.LastRevOf(file.zfile.blktab, blk, at) // XXX activate?
_ = treeKeyRev
// blktab[blk] is only a pointer (to ZBlk) and ZBlk could itself have
// been changing after treeKeyRev. We have to check for that.
panic("TODO")
}
*/
// LastBlkRev returns last revision that changed file[blk] as of @at database state.
//
// if exact=False - what is returned is only an upper bound for last block revision.
//
// at must ∈ (tail, head] XXX [tail ?
// XXX blk must be tracked?
//
// XXX -> LastTrackedBlkRev ?
func (f *BigFile) LastBlkRev(blk int64, at zodb.Tid) (_ zodb.Tid, exact bool) {
δf := f.head.bfdir.δFtail
// revision of when blktab[blk] entry changed last.
//treeKeyRev, exact := δf.ΔTail.LastRevOf(f.zfile.blktab, blk, at) // XXX activate?
zblkOid, ok, tabRev, tabRevExact := δf.ΔTail.GetAt(f.zfile.blktab, blk, at)
// block was removed
......@@ -137,6 +115,8 @@ func (f *BigFile) LastBlkRev(blk int64, at zodb.Tid) (_ zodb.Tid, exact bool) {
// blktab[blk] was changed to point to a zblk @rev.
// blk revision is max rev and when zblk changed last in (rev, at] range.
//
// XXX need to use full δZ, not only connected to tracked subset?
zblkRev, zblkRevExact := δf.ΔTail.ΔZtail.LastRevOf(zblkOid, at)
if zblkRev > tabRev {
return zblkRev, zblkRevExact
......
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