Commit 206b7ceb authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 2364d2c1
......@@ -167,14 +167,14 @@ class DFile:
#
# Database root and wcfs connection are represented by .root and .wc correspondingly.
#
# The primary way to access wcfs is by opening BigFiles and WatcheLinks.
# The primary way to access wcfs is by opening BigFiles and WatchLinks.
# A BigFile opened under tDB is represented as tFile - see .open for details.
# A WatchLink opened under tDB is represented as tWatchLink - see .openwatch for details.
#
# 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 (_blkData, _pinAt, .iter_revv, ...)
# There are various helpers to query history (_blkDataAt, _needPinAt, .iter_revv, ...)
#
# tDB must be explicitly closed once no longer used.
#
......@@ -473,7 +473,7 @@ class tFile:
if not isinstance(dataok, bytes):
dataok = dataok.encode('utf-8')
assert len(dataok) <= t.blksize
blkdata, blkrev = t.tdb._blkData(t.zf, blk, t.at)
blkdata, blkrev = t.tdb._blkDataAt(t.zf, blk, t.at)
assert blkdata == dataok, "computed vs explicit data"
dataok += b'\0'*(t.blksize - len(dataok)) # tailing zeros
assert blk < t._sizeinblk()
......@@ -508,7 +508,7 @@ class tFile:
# already pinned by setup watch
# XXX assert blkaccessed.rev > w.at => w.pinned
if blk not in w.pinned:
pinok = {blk: t.tdb._blkRev(t.zf, blk, w.at)}
pinok = {blk: t.tdb._blkRevAt(t.zf, blk, w.at)}
shouldPin = True
wpin[wlink] = pinok
......@@ -878,10 +878,10 @@ def watch(twlink, zf, at, pinok=None): # XXX -> 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._pinAt(zf, at_prev)
pin_prev = t._needPinAt(zf, at_prev)
assert w.pinned == pin_prev # XXX & blkHeadAccessedRev > w.at
pin = t._pinAt(zf, at)
pin = t._needPinAt(zf, at)
if at_prev != at and at_prev is not None:
print('# pin@old: %s\n# pin@new: %s' % (pinstr(pin_prev), pinstr(pin)))
......@@ -919,7 +919,7 @@ def watch(twlink, zf, at, pinok=None): # XXX -> tWatch ?
twlink._watch(zf, at, pinok, "ok")
w.at = at
assert w.pinned == t._pinAt(zf, at)
assert w.pinned == t._needPinAt(zf, at)
# stop_watch instructs wlink to stop watching the file.
......@@ -1056,16 +1056,16 @@ def _expectPin(twlink, ctx, zf, expect): # -> []tSrvReq
# ---- infrastructure: helpers to query dFtail/accessed history ----
# _blkData returns expected zf[blk] data and revision as of @at database state.
# _blkDataAt returns expected zf[blk] data and revision as of @at database state.
#
# If the block is hole - (b'', at0) is returned. XXX -> @z64?
# XXX ret for when the file did not existed at all? blk was after file size?
@func(tDB)
def _blkData(t, zf, blk, at): # -> (data, rev)
def _blkDataAt(t, zf, blk, at): # -> (data, rev)
if at is None:
at = t.head
# XXX dup wrt _pinAt
# XXX dup wrt _needPinAt
# all changes to zf
vdf = [_.byfile[zf] for _ in t.dFtail if zf in _.byfile]
......@@ -1084,10 +1084,10 @@ def _blkData(t, zf, blk, at): # -> (data, rev)
return data, rev
# _blkRev returns expected zf[blk] revision as of @at database state.
# _blkRevAt returns expected zf[blk] revision as of @at database state.
@func(tDB)
def _blkRev(t, zf, blk, at): # -> rev
_, rev = t._blkData(zf, blk, at)
def _blkRevAt(t, zf, blk, at): # -> rev
_, rev = t._blkDataAt(zf, blk, at)
return rev
# XXX vvv -> not what we need, think again
......@@ -1103,10 +1103,10 @@ def _blkRev(t, zf, blk, at): # -> rev
@func(tDB)
def _blkHeadAccessed(t, zf, blk):
zfAccessed = t._accessed.get(zf, {})
zfAccessed.get(blk) vs t._blkRev(zf, blk, t.head)
zfAccessed.get(blk) vs t._blkRevAt(zf, blk, t.head)
"""
# _pinAt 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.
#
# It does not take into account whether blocks are in cache or not and computes
......@@ -1114,10 +1114,10 @@ def _blkHeadAccessed(t, zf, blk):
# in (at, head] range.
#
# The caller has to take accessed/not-accessed effect into account on its own
# (see tDB._accessed & friends) XXX rework?
# (see tDB._accessed & friends)
@func(tDB)
def _pinAt(t, zf, at): # -> pin = {} blk -> rev
# XXX dup in _blkData
def _needPinAt(t, zf, at): # -> pin = {} blk -> rev
# XXX dup in _blkDataAt
# all changes to zf
vdf = [_.byfile[zf] for _ in t.dFtail if zf in _.byfile]
......
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