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
899ca815
Commit
899ca815
authored
May 10, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
dd6ce1db
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
40 deletions
+24
-40
wcfs/δbtail.go
wcfs/δbtail.go
+2
-2
wcfs/δbtail_test.go
wcfs/δbtail_test.go
+22
-38
No files found.
wcfs/δbtail.go
View file @
899ca815
...
...
@@ -1507,8 +1507,8 @@ func (δBtail *ΔBtail) ForgetPast(revCut zodb.Tid) {
//
// if revExact=False - rev is upper estimate for the revision.
//
//
XXX at must ∈ (tail, head]
//
XXX key must be tracked
//
key must be tracked
//
at must ∈ (tail, head]
//
// XXX naming -> GetAt ?
func
(
δBtail
*
ΔBtail
)
Get
(
ctx
context
.
Context
,
root
*
Tree
,
key
Key
,
at
zodb
.
Tid
)
(
value
Value
,
ok
bool
,
rev
zodb
.
Tid
,
revExact
bool
,
err
error
)
{
...
...
wcfs/δbtail_test.go
View file @
899ca815
...
...
@@ -648,7 +648,7 @@ func xverifyΔBTail_Update(t *testing.T, subj string, db *zodb.DB, treeRoot zodb
}
t
.
Run
(
fmt
.
Sprintf
(
" track=%s"
,
keys
),
func
(
t
*
testing
.
T
)
{
xverifyΔBTail_Update1
(
t
,
subj
,
db
,
treeRoot
,
t1
.
at
,
t2
.
at
,
t1
.
xkv
,
t2
.
xkv
,
t2
.
δZ
,
keys
,
kadj12
)
xverifyΔBTail_Update1
(
t
,
subj
,
db
,
treeRoot
,
t1
.
at
,
t2
.
at
,
t1
.
xkv
,
t2
.
xkv
,
t2
.
δZ
,
t2
.
δkv
,
keys
,
kadj12
)
})
}
})
...
...
@@ -656,12 +656,10 @@ func xverifyΔBTail_Update(t *testing.T, subj string, db *zodb.DB, treeRoot zodb
// xverifyΔBTail_Update1 verifies how ΔBTail handles ZODB update at1->at2 from initial
// tracked state defined by initialTrackedKeys.
func
xverifyΔBTail_Update1
(
t
*
testing
.
T
,
subj
string
,
db
*
zodb
.
DB
,
treeRoot
zodb
.
Oid
,
at1
,
at2
zodb
.
Tid
,
xkv1
,
xkv2
RBucketSet
,
δZ
*
zodb
.
EventCommit
,
initialTrackedKeys
SetKey
,
kadj
KAdjMatrix
)
{
func
xverifyΔBTail_Update1
(
t
*
testing
.
T
,
subj
string
,
db
*
zodb
.
DB
,
treeRoot
zodb
.
Oid
,
at1
,
at2
zodb
.
Tid
,
xkv1
,
xkv2
RBucketSet
,
δZ
*
zodb
.
EventCommit
,
d12
map
[
Key
]
Δstring
,
initialTrackedKeys
SetKey
,
kadj
KAdjMatrix
)
{
X
:=
exc
.
Raiseif
tracef
(
"
\n
>>> Track=%s
\n
"
,
initialTrackedKeys
)
d12
:=
kvdiff
(
xkvFlatten
(
xkv1
),
xkvFlatten
(
xkv2
))
var
kadjTracked
SetKey
=
nil
var
δT
,
δTok
map
[
Key
]
Δstring
=
nil
,
nil
...
...
@@ -880,24 +878,17 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
t2
.
at
:
"at2"
,
}
fmt
.
Printf
(
"@%s: %v
\n
"
,
xat
[
t0
.
at
],
xkvFlatten
(
t0
.
xkv
))
fmt
.
Printf
(
"@%s: %v
\n
"
,
xat
[
t1
.
at
],
xkvFlatten
(
t1
.
xkv
))
fmt
.
Printf
(
"@%s: %v
\n
"
,
xat
[
t2
.
at
],
xkvFlatten
(
t2
.
xkv
))
d01
:=
kvdiff
(
xkvFlatten
(
t0
.
xkv
),
xkvFlatten
(
t1
.
xkv
))
d12
:=
kvdiff
(
xkvFlatten
(
t1
.
xkv
),
xkvFlatten
(
t2
.
xkv
))
_
=
d01
_
=
d12
fmt
.
Printf
(
"@%s: %v
\n
"
,
xat
[
t0
.
at
],
t0
.
xkv
.
Flatten
())
fmt
.
Printf
(
"@%s: %v
\n
"
,
xat
[
t1
.
at
],
t1
.
xkv
.
Flatten
())
fmt
.
Printf
(
"@%s: %v
\n
"
,
xat
[
t2
.
at
],
t2
.
xkv
.
Flatten
())
kadj01
:=
KAdj
(
t0
,
t1
,
allTestKeys
(
t0
,
t1
,
t2
))
kadj12
:=
KAdj
(
t1
,
t2
,
allTestKeys
(
t0
,
t1
,
t2
))
_
=
kadj01
_
=
kadj12
//ø := SetKey{}
ø
:=
trackIndex
{}
// verify t0 -> t1 Track(keys1)
-> t2 Track(keys2)
// verify t0 -> t1 Track(keys1)
Rebuild -> t2 Track(keys2) Rebuild
// for all combinations of keys1 and keys2
for
k1idx
:=
range
IntSets
(
len
(
tAllKeyv
))
{
keys1
:=
SetKey
{}
...
...
@@ -967,7 +958,6 @@ func xverifyΔBTail_rebuild_U(t *testing.T, δbtail *ΔBtail, ti, tj *tTreeCommi
δB
,
err
:=
δbtail
.
Update
(
tj
.
δZ
);
X
(
err
)
// XXX assert δB.Rev = tj.at; δB = δ(ti,tj)/initially tracked
δbtail
.
assertTrack
(
t
,
fmt
.
Sprintf
(
"after Update(@%s→@%s)"
,
xat
[
ti
.
at
],
xat
[
tj
.
at
]),
trackIdx
,
ø
)
// XXX vδB=[ø]
_
=
δB
}
...
...
@@ -997,6 +987,7 @@ func xverifyΔBTail_rebuild_TR(t *testing.T, db *zodb.DB, δbtail *ΔBtail, tj *
// XXX assert vδB=[δ1/T(keys)]
// XXX verify Get
// XXX verify SliceByRootRev
}
...
...
@@ -1015,7 +1006,7 @@ func ___xverifyΔBTail_Get(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, vt ...*
for
i
:=
range
vt
{
xat
[
vt
[
i
]
.
at
]
=
fmt
.
Sprintf
(
"at%d"
,
i
)
fmt
.
Printf
(
"@%s: %v
\n
"
,
xat
[
vt
[
i
]
.
at
],
xkvFlatten
(
vt
[
i
]
.
xkv
))
fmt
.
Printf
(
"@%s: %v
\n
"
,
xat
[
vt
[
i
]
.
at
],
vt
[
i
]
.
xkv
.
Flatten
(
))
}
tkeys
:=
allTestKeys
(
vt
...
)
...
...
@@ -1112,13 +1103,14 @@ func ΔBTest(xtest interface{}) ΔBTestEntry {
return
test
}
// ΔBCommit represent test commit changing a tree
XXX
// ΔBCommit represent test commit changing a tree
.
type
tTreeCommit
struct
{
tree
string
at
zodb
.
Tid
δZ
*
zodb
.
EventCommit
// δZ.tid == at
// XXX +parent *tTreeCommit?
tree
string
// the tree in toplogy-encoding
at
zodb
.
Tid
// commit revision
δZ
*
zodb
.
EventCommit
// raw ZODB changes; δZ.tid == at
xkv
RBucketSet
// full tree state as of @at
// XXX do we also need δkv ?
δkv
map
[
Key
]
Δstring
// full tree-diff against parent
}
// tZODBCacheEverything is workaround for ZODB/go not implementing real
...
...
@@ -1192,13 +1184,15 @@ func testΔBTail(t *testing.T, testq chan ΔBTestEntry) {
var
t0
*
tTreeCommit
t1
:=
&
tTreeCommit
{
tree
:
"ø"
,
// initial
tree
:
"ø"
,
// initial XXX ok?
at
:
tg
.
head
,
δZ
:
nil
,
// XXX ok?
xkv
:
XGetTree
(
db
,
tg
.
head
,
tg
.
treeRoot
),
δZ
:
nil
,
// XXX ok?
δkv
:
nil
,
// XXX ok?
}
for
test
:=
range
testq
{
t2
:=
XCommitTree
(
test
.
tree
)
t2
.
δkv
=
kvdiff
(
t1
.
xkv
.
Flatten
(),
t2
.
xkv
.
Flatten
())
subj
:=
fmt
.
Sprintf
(
"%s -> %s"
,
t1
.
tree
,
t2
.
tree
)
tracef
(
"
\n\n\n
**** %s ****
\n\n
"
,
subj
)
...
...
@@ -1221,16 +1215,6 @@ func testΔBTail(t *testing.T, testq chan ΔBTestEntry) {
xverifyΔBTail_rebuild
(
t
,
db
,
tg
.
treeRoot
,
t0
,
t1
,
t2
)
}
/* XXX kill
xverifyΔBTail_Get(t, db, tg.treeRoot, t2)
xverifyΔBTail_Get(t, db, tg.treeRoot, t1, t2)
if t0 != nil {
xverifyΔBTail_Get(t, db, tg.treeRoot, t0, t1, t2)
}
// XXX ΔBTail.SliceByRootRev
*/
t0
,
t1
=
t1
,
t2
}
}
...
...
@@ -1458,8 +1442,8 @@ func TestΔBTail(t *testing.T) {
}
// TestΔBT
ree
AllStructs verifies ΔBtail on tree topologies generated by AllStructs.
func
TestΔBT
ree
AllStructs
(
t
*
testing
.
T
)
{
// TestΔBT
ail
AllStructs verifies ΔBtail on tree topologies generated by AllStructs.
func
TestΔBT
ail
AllStructs
(
t
*
testing
.
T
)
{
X
:=
exc
.
Raiseif
// considerations:
...
...
@@ -1663,8 +1647,8 @@ func TestKVTxt(t *testing.T) {
}
}
//
xkv
Flatten converts xkv with bucket structure into regular dict.
func
xkvFlatten
(
xkv
RBucketSet
)
map
[
Key
]
string
{
// Flatten converts xkv with bucket structure into regular dict.
func
(
xkv
RBucketSet
)
Flatten
(
)
map
[
Key
]
string
{
kv
:=
make
(
map
[
Key
]
string
)
for
_
,
b
:=
range
xkv
{
for
k
,
v
:=
range
b
.
kv
{
...
...
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