Commit 948b0166 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 38fd7361
......@@ -174,7 +174,7 @@ class DFile:
# The database can be mutated (via !wcfs codepath) with .change + .commit .
# Current database head is represented by .head .
# The history of the changes is kept in .dFtail .
# There are various helpers to query history (_blkDataAt, _needPinAt, .iter_revv, ...)
# There are various helpers to query history (_blkDataAt, _pinnedAt, .iter_revv, ...)
#
# tDB must be explicitly closed once no longer used.
#
......@@ -856,12 +856,6 @@ class tSrvReq:
#
# The automatic computation of pinok is verified against explicitly provided
# pinok when it is present.
#
# Criteria for when blk must be pinned as of @at view:
#
# blk ∈ pinned(at) <=> ∃ r = rev(blk):
# 1) at < r ; blk was changed after at
# 2) r ≤ headOfAccess(blk) ; blk revision changed after at was accessed
@func(tWatchLink)
def watch(twlink, zf, at, pinok=None): # -> tWatch
t = twlink.tdb
......@@ -883,10 +877,10 @@ def watch(twlink, zf, at, pinok=None): # -> tWatch
pin_prev = {}
if at_prev is not None:
assert at_prev <= at, 'TODO %s -> %s' % (t.hat(at_prev), t.hat(at))
pin_prev = t._needPinAt(zf, at_prev) # XXX & headOfBlkAccess(blk) > w.at
pin_prev = t._pinnedAt(zf, at_prev)
assert w.pinned == pin_prev
pin = t._needPinAt(zf, at) # XXX & headOfBlkAccess > w.at
pin = t._pinnedAt(zf, at)
if at_prev != at and at_prev is not None:
print('# pin@old: %s\n# pin@new: %s' % (t.hpin(pin_prev), t.hpin(pin)))
......@@ -942,7 +936,7 @@ def watch(twlink, zf, at, pinok=None): # -> tWatch
w.at = at
# `watch ... -> at_i -> at_j` must be the same as `watch ø -> at_j`
assert w.pinned == t._needPinAt(zf, at) # XXX & headOfBlkAccess
assert w.pinned == t._pinnedAt(zf, at)
return w
......@@ -1090,7 +1084,7 @@ def _blkDataAt(t, zf, blk, at): # -> (data, rev)
if at is None:
at = t.head
# XXX dup wrt _needPinAt
# XXX dup wrt _pinnedAt
# all changes to zf
vdf = [_.byfile[zf] for _ in t.dFtail if zf in _.byfile]
......@@ -1115,35 +1109,17 @@ def _blkRevAt(t, zf, blk, at): # -> rev
_, rev = t._blkDataAt(zf, blk, at)
return rev
# XXX kill
# XXX vvv -> not what we need, think again
# _blkHeadAccessed returns whether block state corresponding to zf[blk] at
# current head was accessed.
#
# for example - if head/<zf>[blk] was accessed and later changed, the answer is "no".
# buf if head/<zf>[blk] was accessed again after change, and was no longer
# changed, the answer is "yes"
# XXX text
# XXX -> _blkLastRevAccessed ? _blkRevLastAccessed ? _blkHeadRevAccessed ?
"""
@func(tDB)
def _blkHeadAccessed(t, zf, blk):
zfAccessed = t._accessed.get(zf, {})
zfAccessed.get(blk) vs t._blkRevAt(zf, blk, t.head)
"""
# XXX -> _pinDeltaAt ?
# _needPinAt returns which blocks needs to be pinned for zf@at compared to zf@head
# _pinnedAt returns which blocks needs to be pinned for zf@at compared to zf@head
# according to wcfs invalidation protocol.
#
# It does not take into account whether blocks are in cache or not and computes
# pins as if all blocks @head were accesses - i.e. considering all file changes
# in (at, head] range.
# Criteria for when blk must be pinned as of @at view:
#
# The caller has to take accessed/not-accessed effect into account on its own
# (see tDB._accessed & friends)
# blk ∈ pinned(at) <=> ∃ r = rev(blk):
# 1) at < r ; blk was changed after at
# 2) r ≤ headOfAccess(blk) ; blk revision changed after at was accessed
@func(tDB)
def _needPinAt(t, zf, at): # -> pin = {} blk -> rev
def _pinnedAt(t, zf, at): # -> pin = {} blk -> rev
# XXX dup in _blkDataAt
# all changes to zf
......@@ -1162,7 +1138,7 @@ def _needPinAt(t, zf, at): # -> pin = {} blk -> rev
else:
pinrev = blkhistoryat[-1]
assert pinrev <= at
pin[blk] = pinrev
pin[blk] = pinrev # XXX headOfAccess >= ...
return pin
......
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