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
b862634c
Commit
b862634c
authored
Jun 15, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
e9902c4a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
9 deletions
+41
-9
wcfs/zblk.go
wcfs/zblk.go
+1
-1
wcfs/δbtail.go
wcfs/δbtail.go
+12
-2
wcfs/δbtail_test.go
wcfs/δbtail_test.go
+23
-5
wcfs/δftail.go
wcfs/δftail.go
+5
-1
No files found.
wcfs/zblk.go
View file @
b862634c
...
...
@@ -526,7 +526,7 @@ func (bf *ZBigFile) Size(ctx context.Context) (_ int64, treePath []btree.LONode,
tailblk
,
ok
,
err
:=
bf
.
blktab
.
VMaxKey
(
ctx
,
func
(
node
btree
.
LONode
)
{
treePath
=
append
(
treePath
,
node
)
})
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
nil
,
err
}
if
!
ok
{
...
...
wcfs/δbtail.go
View file @
b862634c
...
...
@@ -98,6 +98,7 @@ type ΔBtail struct {
db
*
zodb
.
DB
// to open connections to load new/old tree|buckets
// tracked index: BTree|Bucket -> top tree element.
// XXX allow only single root (else it is "tree corrupt") ?
trackIdx
map
[
zodb
.
Oid
]
SetTree
// oid -> {} roots XXX root -> oid
// tracked objects that are not yet taken into account in current δBtail
...
...
@@ -165,7 +166,7 @@ func (δBtail *ΔBtail) Tail() zodb.Tid { return δBtail.δZtail.Tail() }
// Track adds tree path to tracked set.
//
// path[0] signifies tree root.
// All path elemens must be Tree except last one which must be Bucket.
// All path elemen
t
s must be Tree except last one which must be Bucket.
//
// XXX δBtail is rebuild to also include keys corresponding to added nodes.
//
...
...
@@ -173,7 +174,16 @@ func (δBtail *ΔBtail) Tail() zodb.Tid { return δBtail.δZtail.Tail() }
// XXX path -> []oid ?
//
// XXX catch cycles on add?
func
(
δBtail
*
ΔBtail
)
Track
(
path
[]
Node
)
{
// XXX Tree|Bucket; path[0] = root
type
TrackFlags
int
const
(
// TrackMaxKey
// - indicates that provided path is currently the rightmost arm of the tree, and
// - requests that changes to max key of the tree to be covered by δBtail from now on.
TrackMaxKey
TrackFlags
=
1
<<
iota
// XXX TrackMinKey (we don't need it in WCFS)
)
func
(
δBtail
*
ΔBtail
)
Track
(
path
[]
Node
,
flags
TrackFlags
)
{
// XXX Tree|Bucket; path[0] = root
l
:=
len
(
path
)
if
l
==
0
{
panic
(
"empty path"
)
...
...
wcfs/δbtail_test.go
View file @
b862634c
...
...
@@ -46,6 +46,8 @@ import (
"github.com/stretchr/testify/require"
)
const
kInf
Key
=
10000
// inf key (TeX hack)
// XXX move infrastructure -> δbtail_treegen_test.go ?
// TreeGenSrv represents connection to running `treegen ...` server.
...
...
@@ -328,7 +330,7 @@ func xverifyΔBTail(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, a
d12
:=
kvdiff
(
kv1
,
kv2
)
// verify transition at1->at2 for all initial states of tracked {keys} from kv1 + kv2 + ∞
allKeys
:=
SetKey
{};
allKeys
.
Add
(
10000
)
// inf, simulating ZBigFile.Size() query
allKeys
:=
SetKey
{};
allKeys
.
Add
(
kInf
)
// inf, simulating ZBigFile.Size() query
for
k
:=
range
kv1
{
allKeys
.
Add
(
k
)
}
for
k
:=
range
kv2
{
allKeys
.
Add
(
k
)
}
allKeyv
:=
allKeys
.
Elements
()
...
...
@@ -336,19 +338,26 @@ func xverifyΔBTail(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, a
return
allKeyv
[
i
]
<
allKeyv
[
j
]
})
// maxkey among kv1+kv2
// it must be present in δB if maxkey tracking is requested.
maxKey
:=
-
kInf
if
l
:=
len
(
allKeyv
);
l
>
0
{
maxKey
=
allKeyv
[
l
-
1
]
}
for
kidx
:=
range
IntSets
(
len
(
allKeyv
))
{
keys
:=
SetKey
{}
for
_
,
idx
:=
range
kidx
{
keys
.
Add
(
allKeyv
[
idx
])
}
xverifyΔBTail1
(
t
,
subj
,
db
,
treeRoot
,
at1
,
at2
,
d12
,
δZ
,
keys
)
xverifyΔBTail1
(
t
,
subj
,
db
,
treeRoot
,
at1
,
at2
,
d12
,
maxKey
,
δZ
,
keys
)
}
}
// xverifyΔBTail1 verifies how ΔBTail handles ZODB update at1->at2 from initial
// 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
)
{
func
xverifyΔBTail1
(
t
*
testing
.
T
,
subj
string
,
db
*
zodb
.
DB
,
treeRoot
zodb
.
Oid
,
at1
,
at2
zodb
.
Tid
,
d12
map
[
Key
]
string
,
maxKey
Key
,
δZ
*
zodb
.
EventCommit
,
initialTrackedKeys
SetKey
)
{
X
:=
exc
.
Raiseif
assert
:=
require
.
New
(
t
)
...
...
@@ -368,13 +377,20 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
xtree
,
err
:=
zconn
.
Get
(
ctx
,
treeRoot
);
X
(
err
)
ztree
:=
xtree
.
(
*
Tree
)
trackingMaxKey
:=
false
for
k
:=
range
initialTrackedKeys
{
path
:=
[]
Node
{}
_
,
_
,
err
=
ztree
.
VGet
(
ctx
,
k
,
func
(
node
Node
)
{
path
=
append
(
path
,
node
)
});
X
(
err
)
δbtail
.
Track
(
path
)
// kInf imitates ZBigFile.Size() request, which enables maxkey tracking.
trackFlags
:=
TrackFlags
(
0
)
if
k
==
kInf
{
trackFlags
=
TrackMaxKey
trackingMaxKey
=
true
}
δbtail
.
Track
(
path
,
trackFlags
)
}
// δbtail <- δZ
...
...
@@ -409,6 +425,7 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
// changed keys, that are
// - in tracked set -> must be present in δT
// - outside tracked set -> may be present in δT
// - maxkey -> must be present in δT if trackingMaxKey
// δT is subset of d12
for
k
:=
range
δT
{
...
...
@@ -420,9 +437,10 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
// k ∈ tracked set -> must be present in δT
// k ∉ tracked set -> may be present in δT
// k==max && tracking maxKey -> k must be present in δT
for
k
:=
range
d12
{
_
,
inδT
:=
δT
[
k
]
if
initialTrackedKeys
.
Has
(
k
)
{
if
initialTrackedKeys
.
Has
(
k
)
||
(
k
==
maxKey
&&
trackingMaxKey
)
{
if
!
inδT
{
badf
(
"δT: [%v] is missing"
,
k
)
}
...
...
wcfs/δftail.go
View file @
b862634c
...
...
@@ -134,7 +134,11 @@ func (δFtail *ΔFtail) Tail() zodb.Tid { return δFtail.δBtail.Tail() }
//
// A root can be associated with several files (each provided on different Track call).
func
(
δFtail
*
ΔFtail
)
Track
(
file
*
BigFile
,
blk
int64
,
path
[]
btree
.
LONode
,
zblk
zBlk
)
{
δFtail
.
δBtail
.
Track
(
path
)
δbTrackFlags
:=
TrackFlags
(
0
)
if
blk
==
-
1
{
δbTrackFlags
=
TrackMaxKey
}
δFtail
.
δBtail
.
Track
(
path
,
δbTrackFlags
)
root
:=
path
[
0
]
.
(
*
btree
.
LOBTree
)
files
,
ok
:=
δFtail
.
fileIdx
[
root
.
POid
()]
if
!
ok
{
...
...
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