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

.

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