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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
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
Show 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:
...
@@ -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 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 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
, _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.
# 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
.
_blkData
At
(
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
.
_blkRev
At
(
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
.
_
p
inAt
(
zf
,
at_prev
)
pin_prev
=
t
.
_
needP
inAt
(
zf
,
at_prev
)
assert
w
.
pinned
==
pin_prev
# XXX & blkHeadAccessedRev > w.at
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
:
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
.
_
p
inAt
(
zf
,
at
)
assert
w
.
pinned
==
t
.
_
needP
inAt
(
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.
# _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?
# 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
_blkData
At
(
t
,
zf
,
blk
,
at
):
# -> (data, rev)
if
at
is
None
:
if
at
is
None
:
at
=
t
.
head
at
=
t
.
head
# XXX dup wrt _
p
inAt
# XXX dup wrt _
needP
inAt
# 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.
# _blkRev
At
returns expected zf[blk] revision as of @at database state.
@
func
(
tDB
)
@
func
(
tDB
)
def
_blkRev
(
t
,
zf
,
blk
,
at
):
# -> rev
def
_blkRev
At
(
t
,
zf
,
blk
,
at
):
# -> rev
_
,
rev
=
t
.
_blkData
(
zf
,
blk
,
at
)
_
,
rev
=
t
.
_blkData
At
(
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._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.
# 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
_
p
inAt
(
t
,
zf
,
at
):
# -> pin = {} blk -> rev
def
_
needP
inAt
(
t
,
zf
,
at
):
# -> pin = {} blk -> rev
# XXX dup in _blkData
# XXX dup in _blkData
At
# 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
]
...
...
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