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
4f1846bc
Commit
4f1846bc
authored
May 10, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
899ca815
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
20 deletions
+80
-20
wcfs/δbtail.go
wcfs/δbtail.go
+5
-5
wcfs/δbtail_test.go
wcfs/δbtail_test.go
+74
-14
wcfs/δftail.go
wcfs/δftail.go
+1
-1
No files found.
wcfs/δbtail.go
View file @
4f1846bc
...
...
@@ -213,7 +213,7 @@ type ΔTtail struct {
// XXX -> ΔT ?
type
ΔTree
struct
{
Rev
zodb
.
Tid
KV
map
[
Key
]
Value
// XXX Value -> ΔValue ?
ΔKV
map
[
Key
]
ΔValue
}
...
...
@@ -1509,9 +1509,7 @@ func (δBtail *ΔBtail) ForgetPast(revCut zodb.Tid) {
//
// 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
)
{
func
(
δBtail
*
ΔBtail
)
GetAt
(
ctx
context
.
Context
,
root
*
Tree
,
key
Key
,
at
zodb
.
Tid
)
(
value
Value
,
ok
bool
,
rev
zodb
.
Tid
,
revExact
bool
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"δBtail: root<%s>: get %d @%s"
,
root
.
POid
(),
key
,
at
)
// XXX key not tracked -> panic
// XXX at not ∈ (tail, head] -> panic
...
...
@@ -1534,8 +1532,10 @@ func (δBtail *ΔBtail) Get(ctx context.Context, root *Tree, key Key, at zodb.Ti
if
at
<
δT
.
Rev
{
continue
}
value
,
ok
=
δT
.
KV
[
key
]
var
δvalue
ΔValue
δvalue
,
ok
=
δT
.
ΔKV
[
key
]
if
ok
{
value
=
δvalue
.
New
rev
=
δT
.
Rev
revExact
=
true
break
...
...
wcfs/δbtail_test.go
View file @
4f1846bc
...
...
@@ -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
,
t2
.
δkv
,
keys
,
kadj12
)
xverifyΔBTail_Update1
(
t
,
subj
,
db
,
treeRoot
,
t1
.
at
,
t2
.
at
,
t1
.
xkv
,
t2
.
xkv
,
t2
.
δZ
,
t2
.
δ
x
kv
,
keys
,
kadj12
)
})
}
})
...
...
@@ -867,6 +867,8 @@ func (δbtail *ΔBtail) assertTrack(t *testing.T, subj string, trackIdxOK, track
// t0->t1 exercises from-scratch rebuild,
// t1->t2 further exercises incremental rebuild.
func
xverifyΔBTail_rebuild
(
t
*
testing
.
T
,
db
*
zodb
.
DB
,
treeRoot
zodb
.
Oid
,
t0
,
t1
,
t2
*
tTreeCommit
)
{
// t1 := t2.prev
// t0 := t1.prev
t
.
Run
(
fmt
.
Sprintf
(
"rebuild/%s→%s"
,
t0
.
tree
,
t1
.
tree
),
func
(
t
*
testing
.
T
)
{
tAllKeys
:=
allTestKeys
(
t0
,
t1
,
t2
)
tAllKeyv
:=
tAllKeys
.
SortedElements
()
...
...
@@ -883,7 +885,9 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
fmt
.
Printf
(
"@%s: %v
\n
"
,
xat
[
t2
.
at
],
t2
.
xkv
.
Flatten
())
kadj01
:=
KAdj
(
t0
,
t1
,
allTestKeys
(
t0
,
t1
,
t2
))
kadj11
:=
KAdj
(
t1
,
t1
,
allTestKeys
(
t0
,
t1
,
t2
))
kadj12
:=
KAdj
(
t1
,
t2
,
allTestKeys
(
t0
,
t1
,
t2
))
kadj22
:=
KAdj
(
t2
,
t2
,
allTestKeys
(
t0
,
t1
,
t2
))
_
=
kadj01
ø
:=
trackIndex
{}
...
...
@@ -896,6 +900,16 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
keys1
.
Add
(
tAllKeyv
[
idx1
])
}
// δkv1_1 = t1.δxkv / kadj11(keys1)
keys1_1
:=
kadj11
.
Map
(
keys1
)
δkv1_1
:=
map
[
Key
]
Δstring
{}
for
k
:=
range
keys1_1
{
δv
,
ok
:=
t1
.
δxkv
[
k
]
if
ok
{
δkv1_1
[
k
]
=
δv
}
}
t
.
Run
(
fmt
.
Sprintf
(
" T%s;R"
,
keys1
),
func
(
t
*
testing
.
T
)
{
δbtail
:=
NewΔBtail
(
t0
.
at
,
db
)
...
...
@@ -911,7 +925,7 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
// after rebuild
/*trackIdx=*/
t1
.
xkv
.
trackIdx
(
keys1
),
/*vδ
B=*/
/*XXX temp*/
nil
/*[δ1/Tadj(keys1)*/
)
/*vδ
T=*/
δkv1_1
)
t
.
Run
((
" →"
+
t2
.
tree
),
func
(
t
*
testing
.
T
)
{
// tracked keys1 becomes tracked keys1_2 after Update(t1->t2)
...
...
@@ -927,6 +941,23 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
keys2
.
Add
(
tRestKeyv2
[
idx2
])
}
// δkv1_2 = t1.δxkv / (kadj12(keys1) | kadj22(keys2))
// δkv2_2 = t2.δxkv / (kadj12(keys1) | kadj22(keys2))
keys2_2
:=
kadj22
.
Map
(
keys2
)
keys12_2
:=
keys1_2
.
Union
(
keys2_2
)
δkv1_2
:=
map
[
Key
]
Δstring
{}
δkv2_2
:=
map
[
Key
]
Δstring
{}
for
k
:=
range
keys12_2
{
δv1
,
ok
:=
t1
.
δxkv
[
k
]
if
ok
{
δkv1_2
[
k
]
=
δv1
}
δv2
,
ok
:=
t2
.
δxkv
[
k
]
if
ok
{
δkv2_2
[
k
]
=
δv2
}
}
// t.Run is expensive at this level of nest
// t.Run(" T"+keys2.String()+";R", func(t *testing.T) {
δbtail_
:=
δbtail
.
clone
()
...
...
@@ -939,7 +970,7 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
// after rebuild
/* trackIdx=*/
t2
.
xkv
.
trackIdx
(
keys1_2
.
Union
(
keys2
)),
/*vδ
B=*/
/*XXX temp*/
nil
/*[δ1/keys1+keys2, δ2/keys1+keys2]*/
)
/*vδ
T=*/
δkv1_2
,
δkv2_2
)
// })
}
})
...
...
@@ -962,7 +993,7 @@ func xverifyΔBTail_rebuild_U(t *testing.T, δbtail *ΔBtail, ti, tj *tTreeCommi
}
// xverifyΔBTail_rebuild_TR verifies ΔBTree state after Track(keys) + rebuild.
func
xverifyΔBTail_rebuild_TR
(
t
*
testing
.
T
,
db
*
zodb
.
DB
,
δbtail
*
ΔBtail
,
tj
*
tTreeCommit
,
treeRoot
zodb
.
Oid
,
xat
map
[
zodb
.
Tid
]
string
,
keys
SetKey
,
trackIdx
trackIndex
,
trackNew
,
trackIdxAfterRebuild
trackIndex
,
vδ
Bok
[]
ΔB
)
{
func
xverifyΔBTail_rebuild_TR
(
t
*
testing
.
T
,
db
*
zodb
.
DB
,
δbtail
*
ΔBtail
,
tj
*
tTreeCommit
,
treeRoot
zodb
.
Oid
,
xat
map
[
zodb
.
Tid
]
string
,
keys
SetKey
,
trackIdx
trackIndex
,
trackNew
,
trackIdxAfterRebuild
trackIndex
,
vδ
Tok
...
map
[
Key
]
Δstring
)
{
t
.
Helper
()
X
:=
exc
.
Raiseif
ø
:=
trackIndex
{}
...
...
@@ -988,13 +1019,40 @@ func xverifyΔBTail_rebuild_TR(t *testing.T, db *zodb.DB, δbtail *ΔBtail, tj *
// XXX verify Get
// XXX verify SliceByRootRev
// verify SliceByRootRev
l
:=
len
(
vδTok
)
vatOK
:=
make
([]
zodb
.
Tid
,
l
)
t0
:=
tj
for
i
:=
0
;
i
<
l
;
i
++
{
vatOK
[
l
-
i
-
1
]
=
t0
.
at
t0
=
t0
.
prev
}
lo
:=
t0
.
prev
.
at
hi
:=
vatOK
[
l
-
1
]
vδToid
:=
δbtail
.
SliceByRootRev
(
treeRoot
,
lo
,
hi
)
l
=
len
(
vδToid
)
vat
:=
make
([]
zodb
.
Tid
,
l
)
vδT
:=
[]
map
[
Key
]
Δstring
{}
atPrev
:=
lo
for
i
,
δToid
:=
range
vδToid
{
vat
[
i
]
=
δToid
.
Rev
δT
:=
XGetδKV
(
db
,
atPrev
,
δToid
.
Rev
,
δToid
.
ΔKV
)
// {} k -> δ(ZBlk(oid).data)
vδT
=
append
(
vδT
,
δT
)
atPrev
=
δToid
.
Rev
}
if
!
(
reflect
.
DeepEqual
(
vat
,
vatOK
)
&&
reflect
.
DeepEqual
(
vδT
,
vδTok
))
{
t
.
Errorf
(
"@%s: after rebuild: SliceByRootRev:
\n
vat:
\n\t
have: %v
\n\t
want: %v
\n\n
"
+
"vδT:
\n\t
have: %v
\n\t
want: %v"
,
xat
[
tj
.
at
],
vat
,
vatOK
,
vδT
,
vδTok
)
}
}
// xverifyΔBTail_Get verifies δBtail.Get on series of vt ZODB changes.
// xverifyΔBTail_Get
At
verifies δBtail.Get on series of vt ZODB changes.
// XXX
// XXX kill
func
___xverifyΔBTail_Get
(
t
*
testing
.
T
,
db
*
zodb
.
DB
,
treeRoot
zodb
.
Oid
,
vt
...*
tTreeCommit
)
{
func
___xverifyΔBTail_Get
At
(
t
*
testing
.
T
,
db
*
zodb
.
DB
,
treeRoot
zodb
.
Oid
,
vt
...*
tTreeCommit
)
{
subj
:=
vt
[
0
]
.
tree
for
_
,
t
:=
range
vt
[
1
:
]
{
subj
+=
"→"
+
t
.
tree
...
...
@@ -1027,7 +1085,7 @@ func ___xverifyΔBTail_Get(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, vt ...*
})
}
func
xverifyΔBTail_Get1
(
t
*
testing
.
T
,
db
*
zodb
.
DB
,
treeRoot
zodb
.
Oid
,
vt
[]
*
tTreeCommit
,
xat
map
[
zodb
.
Tid
]
string
,
keys
SetKey
)
{
func
xverifyΔBTail_Get
At
1
(
t
*
testing
.
T
,
db
*
zodb
.
DB
,
treeRoot
zodb
.
Oid
,
vt
[]
*
tTreeCommit
,
xat
map
[
zodb
.
Tid
]
string
,
keys
SetKey
)
{
X
:=
exc
.
Raiseif
// t1->t2-> ... -> tn
...
...
@@ -1048,11 +1106,11 @@ func xverifyΔBTail_Get1(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, vt []*tTr
err
=
δbtail
.
Track
(
k
,
ok
,
path
);
X
(
err
)
}
// verify Get(k, @at) for all keys and @at
// verify Get
At
(k, @at) for all keys and @at
for
i
:=
1
;
i
<
len
(
vt
);
i
++
{
at
:=
vt
[
i
]
.
at
for
_
,
k
:=
range
keys
.
SortedElements
()
{
vOid
,
ok
,
rev
,
revExact
,
err
:=
δbtail
.
Get
(
ctx
,
ztree
,
k
,
at
);
X
(
err
)
vOid
,
ok
,
rev
,
revExact
,
err
:=
δbtail
.
Get
At
(
ctx
,
ztree
,
k
,
at
);
X
(
err
)
v
:=
xzgetBlkDataAt
(
db
,
vOid
,
rev
)
v_
,
ok_
:=
vt
[
i
]
.
xkv
.
Get
(
k
)
.
kv
[
k
]
...
...
@@ -1105,12 +1163,12 @@ func ΔBTest(xtest interface{}) ΔBTestEntry {
// ΔBCommit represent test commit changing a tree.
type
tTreeCommit
struct
{
// XXX +parent *tTreeCommit?
tree
string
// the tree in toplogy-encoding
prev
*
tTreeCommit
// previous commit
at
zodb
.
Tid
// commit revision
δZ
*
zodb
.
EventCommit
// raw ZODB changes; δZ.tid == at
xkv
RBucketSet
// full tree state as of @at
δ
kv
map
[
Key
]
Δstring
// full tree-diff against parent
δ
xkv
map
[
Key
]
Δstring
// full tree-diff against parent
}
// tZODBCacheEverything is workaround for ZODB/go not implementing real
...
...
@@ -1185,14 +1243,16 @@ func testΔBTail(t *testing.T, testq chan ΔBTestEntry) {
var
t0
*
tTreeCommit
t1
:=
&
tTreeCommit
{
tree
:
"ø"
,
// initial XXX ok?
prev
:
nil
,
// XXX ok?
at
:
tg
.
head
,
xkv
:
XGetTree
(
db
,
tg
.
head
,
tg
.
treeRoot
),
δZ
:
nil
,
// XXX ok?
δ
kv
:
nil
,
// XXX ok?
δ
xkv
:
nil
,
// XXX ok?
}
for
test
:=
range
testq
{
t2
:=
XCommitTree
(
test
.
tree
)
t2
.
δkv
=
kvdiff
(
t1
.
xkv
.
Flatten
(),
t2
.
xkv
.
Flatten
())
t2
.
δxkv
=
kvdiff
(
t1
.
xkv
.
Flatten
(),
t2
.
xkv
.
Flatten
())
// XXX move to XCommitTree?
t2
.
prev
=
t1
// XXX ----//----
subj
:=
fmt
.
Sprintf
(
"%s -> %s"
,
t1
.
tree
,
t2
.
tree
)
tracef
(
"
\n\n\n
**** %s ****
\n\n
"
,
subj
)
...
...
wcfs/δftail.go
View file @
4f1846bc
...
...
@@ -479,7 +479,7 @@ func (δFtail *ΔFtail) LastBlkRev(ctx context.Context, f *BigFile, blk int64, a
// XXX tabRev -> treeRev ?
// XXX activate zfile?
zblkOid
,
ok
,
tabRev
,
tabRevExact
,
err
:=
δFtail
.
δBtail
.
Get
(
ctx
,
f
.
zfile
.
blktab
,
blk
,
at
)
zblkOid
,
ok
,
tabRev
,
tabRevExact
,
err
:=
δFtail
.
δBtail
.
Get
At
(
ctx
,
f
.
zfile
.
blktab
,
blk
,
at
)
if
err
!=
nil
{
panic
(
err
)
// XXX
}
...
...
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