Commit 08da1d81 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 94f4471f
......@@ -331,14 +331,14 @@ package main
// 7.1) load blkdata for head/bigfile/file[blk] @zhead.at .
//
// while loading this also gives upper bound estimate of when the block
// was last changed: XXX kill upper bound -> populate and use δFtail
// was last changed:
//
// rev(blk) ≤ max(_.serial for _ in (ZBlk(#blk), all BTree/Bucket that lead to ZBlk))
//
// it is not exact because BTree/Bucket can change (e.g. rebalance)
// but still point to the same k->ZBlk.
//
// we also use file.δtail to find either exact blk revision: XXX just use δFtail
// we also use file.δtail to find either exact blk revision:
//
// rev(blk) = max(file.δtail.by(#blk) -> []rev↑)
//
......@@ -352,6 +352,9 @@ package main
// rev(blk) ≤ rev'(blk) rev'(blk) = min(^^^)
//
//
// XXX we delay recomputing δFtail.LastBlkRev(file, #blk, head) because
// just cheap revmax estimate can frequently result in all watches being skipped.
//
// 7.2) for all registered client@at watchers of head/bigfile/file:
//
// - rev'(blk) ≤ at: -> do nothing
......
......@@ -36,7 +36,7 @@ import (
//
// δF:
// .rev↑
// [](file, []blk)
// {} file -> {}blk
//
// Only files and blocks explicitly requested to be tracked are guaranteed to
// be present. In particular a block that was not explicitly requested to be
......@@ -52,6 +52,12 @@ import (
// .SliceByFileRev(file, lo, hi) -> []δfile - query for changes of file with rev ∈ (lo, hi]
// .LastBlkRev(file, #blk, at) - query for what is last revision that changed
// file[#blk] as of @at database state.
//
// XXX δfile:
// .rev↑
// []blk
//
// XXX concurrent use
type ΔFtail struct {
// ΔFtail merge btree.ΔTail with history of ZBlk
δBtail *xbtree.ΔTail
......@@ -88,6 +94,14 @@ func (δFtail *ΔFtail) Track(file *BigFile, path []btree.LONode) {
δFtail.fileIdx[root] = files
}
files.Add(file)
// XXX debug
/*
leaf := path[len(path)-1].(*btree.LOBucket)
for _, e := range leaf.Entryv() { // XXX activate
δFtail.tracked.Add(e.Key())
}
*/
}
// Update updates δFtail given raw ZODB changes.
......@@ -118,6 +132,8 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) ΔF {
return δF
}
// XXX ForgetPast
// 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.
......@@ -125,10 +141,11 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) ΔF {
// at must ∈ (tail, head] XXX [tail ?
// XXX blk must be tracked?
//
// XXX -> LastTrackedBlkRev ?
// XXX +ctx, error rebuild []δF here
func (f *BigFile) LastBlkRev(blk int64, at zodb.Tid) (_ zodb.Tid, exact bool) {
δFtail := f.head.bfdir.δFtail
// XXX tabRev -> treeRev ?
zblkOid, ok, tabRev, tabRevExact := δFtail.δBtail.Get(f.zfile.blktab, blk, at)
// block was removed
......@@ -148,3 +165,6 @@ func (f *BigFile) LastBlkRev(blk int64, at zodb.Tid) (_ zodb.Tid, exact bool) {
return tabRev, tabRevExact
}
}
// XXX SliceByRev
// XXX SliceByFileRev
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