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
2d71c2ed
Commit
2d71c2ed
authored
Sep 01, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
80bdf7e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
16 deletions
+51
-16
wcfs/δbtail.go
wcfs/δbtail.go
+9
-7
wcfs/δbtail_test.go
wcfs/δbtail_test.go
+42
-9
No files found.
wcfs/δbtail.go
View file @
2d71c2ed
...
@@ -126,7 +126,7 @@ type ΔValue struct {
...
@@ -126,7 +126,7 @@ type ΔValue struct {
//
//
// δB:
// δB:
// .rev↑
// .rev↑
// {} root -> {}(key,
value) XXX value -> δ
value
// {} root -> {}(key,
δvalue) XXX was
value
//
//
// and atTail keeps set of k/v @tail for keys changed in (tail, head]
// and atTail keeps set of k/v @tail for keys changed in (tail, head]
//
//
...
@@ -167,24 +167,26 @@ type ΔBtail struct {
...
@@ -167,24 +167,26 @@ type ΔBtail struct {
// δRtail []ΔRoots // which BTree were changed; Noted only by keys ∈ tracket subset
// δRtail []ΔRoots // which BTree were changed; Noted only by keys ∈ tracket subset
byRoot
map
[
zodb
.
Oid
]
*
ΔTtail
// {} root -> [] k/v change history; only for keys ∈ tracket subset
byRoot
map
[
zodb
.
Oid
]
*
ΔTtail
// {} root -> [] k/v change history; only for keys ∈ tracket subset
// XXX or ask client to provide db on every call?
// handle to make connections to access database.
// TODO allow client to optionally provide zconnOld/zconnNew on e.g. Update()
db
*
zodb
.
DB
// to open connections to load new/old tree|buckets
db
*
zodb
.
DB
// to open connections to load new/old tree|buckets
// tracked nodes index: node -> parent + accessed holes under this node XXX -> holeIdx
// tracked nodes index: node -> parent + accessed holes under this node XXX -> holeIdx
// we only allow single parent/root case and report "tree corrupt" otherwise.
// we only allow single parent/root case and report "tree corrupt" otherwise.
// trackIdx describes @head state
// trackIdx describes @head state
// XXX -> parentIdx
// XXX -> parentIdx
map[zodb.Oid]zodb.Oid ?
trackIdx
map
[
zodb
.
Oid
]
nodeTrack
trackIdx
map
[
zodb
.
Oid
]
nodeTrack
// XXX tracked holes
// XXX tracked holes
holeIdx
treeSetKey
holeIdx
treeSetKey
// tracked objects that are not yet taken into account in current δBtail
//
// tracked objects that are not yet taken into account in current δBtail
trackNew
SetOid
//
trackNew SetOid
}
}
// XXX place
// XXX place
// nodeTrack represents tracking information about a node.
// nodeTrack represents tracking information about a node.
// XXX kill (parentIdx is just {} oid -> oid)
type
nodeTrack
struct
{
type
nodeTrack
struct
{
parent
zodb
.
Oid
// parent node | InvalidOid for root
parent
zodb
.
Oid
// parent node | InvalidOid for root
/*
/*
...
@@ -283,7 +285,7 @@ func (δBtail *ΔBtail) Tail() zodb.Tid { return δBtail.δZtail.Tail() }
...
@@ -283,7 +285,7 @@ func (δBtail *ΔBtail) Tail() zodb.Tid { return δBtail.δZtail.Tail() }
// path[0] signifies tree root.
// path[0] signifies tree root.
// All path elements must be Tree except last one which must be Bucket.
// All path elements must be Tree except last one which must be Bucket.
//
//
//
XXX δBtail is rebuild to also include keys corresponding to added nodes.
//
δBtail will also track all keys corresponding to added bucket nodes. XXX
//
//
// XXX objects in path must be with .PJar().At() == .head
// XXX objects in path must be with .PJar().At() == .head
// XXX path -> []oid ?
// XXX path -> []oid ?
...
@@ -393,7 +395,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
...
@@ -393,7 +395,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) (_ ΔB, err error) {
}
}
// open ZODB connections corresponding to "old" and "new" states
// open ZODB connections corresponding to "old" and "new" states
// TODO caller should provide one of those (probably new)
// TODO caller should provide one of those (probably new)
as usually it has it
txn
,
ctx
:=
transaction
.
New
(
context
.
TODO
())
// XXX
txn
,
ctx
:=
transaction
.
New
(
context
.
TODO
())
// XXX
defer
txn
.
Abort
()
defer
txn
.
Abort
()
zconnOld
,
err
:=
δBtail
.
db
.
Open
(
ctx
,
&
zodb
.
ConnOptions
{
At
:
headOld
})
zconnOld
,
err
:=
δBtail
.
db
.
Open
(
ctx
,
&
zodb
.
ConnOptions
{
At
:
headOld
})
...
...
wcfs/δbtail_test.go
View file @
2d71c2ed
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
// See https://www.nexedi.com/licensing for rationale and options.
// See https://www.nexedi.com/licensing for rationale and options.
package
main
package
main
// tests for δbtail.go
// XXX doc (2 ways of testing: explicit + allstructs), treegen py helper
// XXX doc (2 ways of testing: explicit + allstructs), treegen py helper
// Adjacency matrix
// Adjacency matrix
...
@@ -272,6 +272,7 @@ func (tg *AllStructsSrv) AllStructs(kv1, kv2 map[Key]string, maxdepth, maxsplit,
...
@@ -272,6 +272,7 @@ func (tg *AllStructsSrv) AllStructs(kv1, kv2 map[Key]string, maxdepth, maxsplit,
// RBucket represents Bucket node covering [lo, hi) key range in its Tree.
// RBucket represents Bucket node covering [lo, hi) key range in its Tree.
type
RBucket
struct
{
type
RBucket
struct
{
// XXX +oid, +parent (RTree)
lo
,
hi
Key
lo
,
hi
Key
kv
map
[
Key
]
string
// bucket's k->v; values were ZBlk objects whose data is loaded instead.
kv
map
[
Key
]
string
// bucket's k->v; values were ZBlk objects whose data is loaded instead.
}
}
...
@@ -433,8 +434,6 @@ func xzgetBlkData(ctx context.Context, zconn *zodb.Connection, zblkOid zodb.Oid)
...
@@ -433,8 +434,6 @@ func xzgetBlkData(ctx context.Context, zconn *zodb.Connection, zblkOid zodb.Oid)
// kadjOK may be optionally provided. if kadjOK != nil computed adjacency
// kadjOK may be optionally provided. if kadjOK != nil computed adjacency
// matrix is verified against it.
// matrix is verified against it.
func
xverifyΔBTail
(
t
*
testing
.
T
,
subj
string
,
db
*
zodb
.
DB
,
treeRoot
zodb
.
Oid
,
at1
,
at2
zodb
.
Tid
,
xkv1
,
xkv2
RBucketSet
,
δZ
*
zodb
.
EventCommit
,
kadjOK
map
[
Key
]
SetKey
)
{
func
xverifyΔBTail
(
t
*
testing
.
T
,
subj
string
,
db
*
zodb
.
DB
,
treeRoot
zodb
.
Oid
,
at1
,
at2
zodb
.
Tid
,
xkv1
,
xkv2
RBucketSet
,
δZ
*
zodb
.
EventCommit
,
kadjOK
map
[
Key
]
SetKey
)
{
d12
:=
kvdiff
(
xkvFlatten
(
xkv1
),
xkvFlatten
(
xkv2
))
// verify transition at1->at2 for all initial states of tracked {keys} from kv1 + kv2 + ∞
// verify transition at1->at2 for all initial states of tracked {keys} from kv1 + kv2 + ∞
allKeys
:=
SetKey
{};
allKeys
.
Add
(
kInf
)
// ∞ simulating ZBigFile.Size() query
allKeys
:=
SetKey
{};
allKeys
.
Add
(
kInf
)
// ∞ simulating ZBigFile.Size() query
maxk1
:=
-
kInf
;
maxk2
:=
-
kInf
maxk1
:=
-
kInf
;
maxk2
:=
-
kInf
...
@@ -460,7 +459,7 @@ func xverifyΔBTail(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, a
...
@@ -460,7 +459,7 @@ func xverifyΔBTail(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, a
k1
:=
k
k1
:=
k
k2
:=
k
k2
:=
k
if
k
==
kInf
{
if
k
==
kInf
{
// XXX not needed? - kill?
k1
=
maxk1
k1
=
maxk1
k2
=
maxk2
k2
=
maxk2
}
}
...
@@ -470,8 +469,8 @@ func xverifyΔBTail(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, a
...
@@ -470,8 +469,8 @@ func xverifyΔBTail(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, a
//tracef("\n")
//tracef("\n")
for
len
(
q1
)
>
0
||
len
(
q2
)
>
0
{
for
len
(
q1
)
>
0
||
len
(
q2
)
>
0
{
//
fmt.Print
f("q1: %v\n", q1)
//
trace
f("q1: %v\n", q1)
//
fmt.Print
f("q2: %v\n", q2)
//
trace
f("q2: %v\n", q2)
if
l1
:=
len
(
q1
);
l1
>
0
{
if
l1
:=
len
(
q1
);
l1
>
0
{
k1
=
q1
[
l1
-
1
];
q1
=
q1
[
:
l1
-
1
]
k1
=
q1
[
l1
-
1
];
q1
=
q1
[
:
l1
-
1
]
if
!
adj1
.
Has
(
k1
)
{
if
!
adj1
.
Has
(
k1
)
{
...
@@ -517,16 +516,19 @@ func xverifyΔBTail(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, a
...
@@ -517,16 +516,19 @@ func xverifyΔBTail(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, a
keys
.
Add
(
allKeyv
[
idx
])
keys
.
Add
(
allKeyv
[
idx
])
}
}
xverifyΔBTail1
(
t
,
subj
,
db
,
treeRoot
,
at1
,
at2
,
d1
2
,
δZ
,
keys
,
kadj
)
xverifyΔBTail1
(
t
,
subj
,
db
,
treeRoot
,
at1
,
at2
,
xkv1
,
xkv
2
,
δZ
,
keys
,
kadj
)
}
}
}
}
// xverifyΔBTail1 verifies how ΔBTail handles ZODB update at1->at2 from initial
// xverifyΔBTail1 verifies how ΔBTail handles ZODB update at1->at2 from initial
// tracked state defined by initialTrackedKeys.
// tracked state defined by initialTrackedKeys.
func
xverifyΔBTail1
(
t
*
testing
.
T
,
subj
string
,
db
*
zodb
.
DB
,
treeRoot
zodb
.
Oid
,
at1
,
at2
zodb
.
Tid
,
d12
map
[
Key
]
Δstring
,
δZ
*
zodb
.
EventCommit
,
initialTrackedKeys
SetKey
,
kadj
map
[
Key
]
SetKey
)
{
// XXX initialTrackedKeys -> tracked1 ?
func
xverifyΔBTail1
(
t
*
testing
.
T
,
subj
string
,
db
*
zodb
.
DB
,
treeRoot
zodb
.
Oid
,
at1
,
at2
zodb
.
Tid
,
xkv1
,
xkv2
RBucketSet
,
δZ
*
zodb
.
EventCommit
,
initialTrackedKeys
SetKey
,
kadj
map
[
Key
]
SetKey
)
{
X
:=
exc
.
Raiseif
X
:=
exc
.
Raiseif
tracef
(
"
\n
>>> Track=%s
\n
"
,
initialTrackedKeys
)
tracef
(
"
\n
>>> Track=%s
\n
"
,
initialTrackedKeys
)
d12
:=
kvdiff
(
xkvFlatten
(
xkv1
),
xkvFlatten
(
xkv2
))
var
kadjTracked
SetKey
=
nil
var
kadjTracked
SetKey
=
nil
var
δT
,
δTok
map
[
Key
]
Δstring
=
nil
,
nil
var
δT
,
δTok
map
[
Key
]
Δstring
=
nil
,
nil
...
@@ -599,7 +601,25 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
...
@@ -599,7 +601,25 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
}
}
}
}
// XXX verify δbtail index consistency against @at1
// XXX verify δbtail trackIdx against @at1
// holes1 = tracked1 \ kv1
holes1
:=
SetKey
{}
for
k
:=
range
initialTrackedKeys
{
if
k
==
kInf
{
continue
// ∞ is translated to maxk1 XXX
}
_
,
keyin1
:=
xkv1
.
Get
(
k
)
.
kv
[
k
]
if
!
keyin1
{
holes1
.
Add
(
k
)
}
}
/*
if !reflect.DeepEqual(holes1, δbtail.holeIdx.SetKey) {
badf("δbtail.holeIdx1 wrong ; holeIdx=%v holeIdxOK=%v", δbtail.holeIdx, holes1)
}
*/
// XXX verify δbtail holeIdx against @at1
// δB <- δZ
// δB <- δZ
δB
,
err
:=
δbtail
.
Update
(
δZ
);
X
(
err
)
δB
,
err
:=
δbtail
.
Update
(
δZ
);
X
(
err
)
...
@@ -608,6 +628,19 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
...
@@ -608,6 +628,19 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
return
return
}
}
// holes2 = tracked2 \ kv2 ( = kadj[tracked1] \ kv2)
holes2
:=
SetKey
{}
for
k
:=
range
kadjTracked
{
if
k
==
kInf
{
continue
// ∞ is translated to maxk2
}
_
,
keyin2
:=
xkv2
.
Get
(
k
)
.
kv
[
k
]
if
!
keyin2
{
holes2
.
Add
(
k
)
}
}
// XXX verify
// XXX verify δbtail index consistency against @at2
// XXX verify δbtail index consistency against @at2
// XXX verify that removed keys remain in trackedIdx (holes), so that e.g.
// XXX verify that removed keys remain in trackedIdx (holes), so that e.g.
// track [k]; k:a->b; k:b->ø; k:ø->c is not missed
// track [k]; k:a->b; k:b->ø; k:ø->c is not missed
...
...
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