Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Joshua
wendelin.core
Commits
206b7ceb
Commit
206b7ceb
authored
Jun 23, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
2364d2c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
18 deletions
+18
-18
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+18
-18
No files found.
wcfs/wcfs_test.py
View file @
206b7ceb
...
...
@@ -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 Watch
e
Links.
# 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
, _p
inAt, .iter_revv, ...)
# There are various helpers to query history (_blkData
At, _needP
inAt, .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
.
_blkData
At
(
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
.
_blkRev
At
(
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
.
_
p
inAt
(
zf
,
at_prev
)
pin_prev
=
t
.
_
needP
inAt
(
zf
,
at_prev
)
assert
w
.
pinned
==
pin_prev
# XXX & blkHeadAccessedRev > w.at
pin
=
t
.
_
p
inAt
(
zf
,
at
)
pin
=
t
.
_
needP
inAt
(
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
.
_
p
inAt
(
zf
,
at
)
assert
w
.
pinned
==
t
.
_
needP
inAt
(
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.
# _blkData
At
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
_blkData
At
(
t
,
zf
,
blk
,
at
):
# -> (data, rev)
if
at
is
None
:
at
=
t
.
head
# XXX dup wrt _
p
inAt
# XXX dup wrt _
needP
inAt
# 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.
# _blkRev
At
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
_blkRev
At
(
t
,
zf
,
blk
,
at
):
# -> rev
_
,
rev
=
t
.
_blkData
At
(
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._blkRev
At
(zf, blk, t.head)
"""
# _
p
inAt returns which blocks needs to be pinned for zf@at compared to zf@head
# _
needP
inAt 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
_
p
inAt
(
t
,
zf
,
at
):
# -> pin = {} blk -> rev
# XXX dup in _blkData
def
_
needP
inAt
(
t
,
zf
,
at
):
# -> pin = {} blk -> rev
# XXX dup in _blkData
At
# all changes to zf
vdf
=
[
_
.
byfile
[
zf
]
for
_
in
t
.
dFtail
if
zf
in
_
.
byfile
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment