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

.

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