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
129fe522
Commit
129fe522
authored
Jun 01, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
831e5247
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
3 deletions
+37
-3
wcfs/δbtail_test.go
wcfs/δbtail_test.go
+37
-3
No files found.
wcfs/δbtail_test.go
View file @
129fe522
...
...
@@ -157,8 +157,8 @@ func XGetTree(db *zodb.DB, at zodb.Tid, root zodb.Oid) map[Key]string {
txn
,
ctx
:=
transaction
.
New
(
context
.
Background
())
defer
txn
.
Abort
()
zconn
,
err
:=
db
.
Open
(
ctx
,
&
zodb
.
ConnOptions
{
At
:
at
});
X
(
err
)
xztree
,
err
:=
zconn
.
Get
(
ctx
,
root
);
X
(
err
)
ztree
,
ok
:=
xztree
.
(
*
Tree
)
if
!
ok
{
...
...
@@ -194,6 +194,31 @@ func XGetTree(db *zodb.DB, at zodb.Tid, root zodb.Oid) map[Key]string {
return
kv
}
// XGetKV translates {k -> <oid>} to {k -> ZBlk(oid).data} according to db@at.
func
XGetKV
(
db
*
zodb
.
DB
,
at
zodb
.
Tid
,
kvOid
map
[
Key
]
Value
)
map
[
Key
]
string
{
defer
exc
.
Contextf
(
"%s: @%s: get kv %v"
,
db
.
Storage
()
.
URL
(),
at
,
kvOid
)
X
:=
exc
.
Raiseif
txn
,
ctx
:=
transaction
.
New
(
context
.
Background
())
defer
txn
.
Abort
()
zconn
,
err
:=
db
.
Open
(
ctx
,
&
zodb
.
ConnOptions
{
At
:
at
});
X
(
err
)
kv
:=
map
[
Key
]
string
{}
for
k
,
vOid
:=
range
kvOid
{
if
vOid
==
zodb
.
InvalidOid
{
kv
[
k
]
=
DEL
continue
}
xv
,
err
:=
zconn
.
Get
(
ctx
,
vOid
);
X
(
err
)
zv
:=
xv
.
(
zBlk
)
data
,
_
,
err
:=
zv
.
loadBlkData
(
ctx
);
X
(
err
)
kv
[
k
]
=
string
(
data
)
}
return
kv
}
// xverifyΔBTail verifies how ΔBTail handles ZODB update for a tree with changes in between at1->at2.
//
...
...
@@ -257,15 +282,24 @@ func xverifyΔBTail1(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, at1,at2 zodb.
return
}
// δB.ByRoot.keys() == [treeRoot]
roots
:=
[]
zodb
.
Oid
{}
for
root
:=
range
δB
.
ByRoot
{
roots
=
append
(
roots
,
root
)
}
assert
.
Equal
(
roots
,
[]
zodb
.
Oid
{
treeRoot
})
δT
:=
δB
.
ByRoot
[
treeRoot
]
_
=
δT
δT
:=
δB
.
ByRoot
[
treeRoot
]
// {} k -> oid
δTstr
:=
XGetKV
(
db
,
at2
,
δT
)
// {} k -> ZBlk(oid).data
fmt
.
Println
(
"d12:"
,
d12
)
fmt
.
Println
(
"δT: "
,
δTstr
)
// δT must be subset of d12.
// changed keys, that are
// - in tracked set -> must be present in δT
// - outside tracked set -> may be present in δT
//
// all keys from d12/tracked are present in δT
//for (k,v) in d12:
// if k in initialTrackedKeys:
...
...
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