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
115a4866
Commit
115a4866
authored
Jun 23, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
1dcd1f61
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
14 deletions
+57
-14
wcfs/δbtail.go
wcfs/δbtail.go
+57
-14
No files found.
wcfs/δbtail.go
View file @
115a4866
...
@@ -510,18 +510,27 @@ type nodeInRange struct {
...
@@ -510,18 +510,27 @@ type nodeInRange struct {
type
rangeSplit
[]
*
nodeInRange
// key↑
type
rangeSplit
[]
*
nodeInRange
// key↑
// Get returns node covering key k.
// Get returns node covering key k.
// Get panics if k is outside covered range.
// Get panics if k is not covered.
func
(
rs
rangeSplit
)
Get
(
k
Key
)
*
nodeInRange
{
// XXX -> Get_ -> rn, ok
func
(
rs
rangeSplit
)
Get
(
k
Key
)
*
nodeInRange
{
rnode
,
ok
:=
rs
.
Get_
(
k
)
if
ok
{
return
rnode
}
panicf
(
"key %v not covered"
,
k
)
}
// Get_ returns node covering key k.
func
(
rs
rangeSplit
)
Get_
(
k
Key
)
(
rnode
*
nodeInRange
,
ok
bool
)
{
i
:=
sort
.
Search
(
len
(
rs
),
func
(
i
int
)
bool
{
i
:=
sort
.
Search
(
len
(
rs
),
func
(
i
int
)
bool
{
return
k
<=
rs
[
i
]
.
hi_
return
k
<=
rs
[
i
]
.
hi_
})
})
if
i
==
len
(
rs
)
{
if
i
==
len
(
rs
)
{
panicf
(
"key %v not covered"
,
k
)
// XXX + coverage: ...
return
nil
,
false
// key not covered
}
}
rn
:
=
rs
[
i
]
rn
=
rs
[
i
]
if
!
(
rn
.
lo
<=
k
&&
k
<=
rn
.
hi_
)
{
if
!
(
rn
.
lo
<=
k
&&
k
<=
rn
.
hi_
)
{
panicf
(
"BUG: get(%v) ->
[%v, %v]"
,
k
,
rn
.
lo
,
rn
.
hi_
)
panicf
(
"BUG: get(%v) ->
%s"
,
k
,
rn
)
}
}
return
rn
return
rn
...
@@ -532,7 +541,9 @@ func (rs rangeSplit) Get(k Key) *nodeInRange { // XXX -> Get_ -> rn, ok
...
@@ -532,7 +541,9 @@ func (rs rangeSplit) Get(k Key) *nodeInRange { // XXX -> Get_ -> rn, ok
// rnode must be initially in *prs.
// rnode must be initially in *prs.
// rnode.node must be tree.
// rnode.node must be tree.
// rnode.node must be aleady activated.
// rnode.node must be aleady activated.
func
(
prs
*
rangeSplit
)
Expand
(
rnode
*
nodeInRange
)
[]
*
nodeInRange
{
//
// inserted children is also return for convenience.
func
(
prs
*
rangeSplit
)
Expand
(
rnode
*
nodeInRange
)
(
children
rangeSplit
)
{
rs
:=
*
prs
rs
:=
*
prs
i
:=
sort
.
Search
(
len
(
rs
),
func
(
i
int
)
bool
{
i
:=
sort
.
Search
(
len
(
rs
),
func
(
i
int
)
bool
{
return
rnode
.
hi_
<=
rs
[
i
]
.
hi_
return
rnode
.
hi_
<=
rs
[
i
]
.
hi_
...
@@ -547,7 +558,7 @@ func (prs *rangeSplit) Expand(rnode *nodeInRange) []*nodeInRange {
...
@@ -547,7 +558,7 @@ func (prs *rangeSplit) Expand(rnode *nodeInRange) []*nodeInRange {
// [len(ev)].Key = +∞ ; should be assumed so
// [len(ev)].Key = +∞ ; should be assumed so
tree
:=
rnode
.
node
.
(
*
Tree
)
tree
:=
rnode
.
node
.
(
*
Tree
)
treev
:=
tree
.
Entryv
()
treev
:=
tree
.
Entryv
()
children
:=
make
(
[]
*
nodeInRange
,
0
,
len
(
treev
)
+
1
)
children
:=
make
(
rangeSplit
,
0
,
len
(
treev
)
+
1
)
for
i
:=
range
treev
{
for
i
:=
range
treev
{
lo
:=
rnode
.
lo
lo
:=
rnode
.
lo
if
i
>
0
{
if
i
>
0
{
...
@@ -701,9 +712,10 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
...
@@ -701,9 +712,10 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
var
av
rangeSplit
var
av
rangeSplit
var
bv
rangeSplit
var
bv
rangeSplit
// initial phase: expand changed nodes in a till buckets
// initial phase: expand changed nodes in a till buckets
;
// XXX
maybe walk till a from root to get more precise initial range?
// XXX
changed buckets -> δ-
if
a
!=
nil
{
if
a
!=
nil
{
// XXX maybe walk till a from root to get more precise initial range?
atop
:=
&
nodeInRange
{
lo
:
KeyMin
,
hi_
:
KeyMax
,
node
:
a
}
// [-∞, ∞)
atop
:=
&
nodeInRange
{
lo
:
KeyMin
,
hi_
:
KeyMax
,
node
:
a
}
// [-∞, ∞)
av
=
rangeSplit
{
atop
}
av
=
rangeSplit
{
atop
}
aq
:=
[]
*
nodeInRange
{
atop
}
// stack
aq
:=
[]
*
nodeInRange
{
atop
}
// stack
...
@@ -712,16 +724,15 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
...
@@ -712,16 +724,15 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
arn
:=
aq
[
l
-
1
];
aq
=
aq
[
:
l
-
1
]
// arn=aq.pop()
arn
:=
aq
[
l
-
1
];
aq
=
aq
[
:
l
-
1
]
// arn=aq.pop()
err
:=
arn
.
node
.
PActivate
(
ctx
);
if
err
!=
nil
{
return
nil
,
err
}
err
:=
arn
.
node
.
PActivate
(
ctx
);
if
err
!=
nil
{
return
nil
,
err
}
defer
arn
.
node
.
PDeactivate
()
defer
arn
.
node
.
PDeactivate
()
children
:=
av
.
Expand
(
arn
)
for
_
,
rc
:=
range
children
{
for
_
,
rc
hild
:=
range
av
.
Expand
(
arn
)
{
if
!
δZTC
.
Has
(
rc
.
node
.
POid
())
{
if
!
δZTC
.
Has
(
rc
hild
.
node
.
POid
())
{
continue
continue
}
}
switch
rc
.
node
.
(
type
)
{
switch
rc
hild
.
node
.
(
type
)
{
case
*
Tree
:
case
*
Tree
:
aq
=
append
(
aq
,
rc
)
aq
=
append
(
aq
,
rc
hild
)
case
*
Bucket
:
case
*
Bucket
:
// XXX δ += -[k]v -[k]ø (for tracked DEL)
// XXX δ += -[k]v -[k]ø (for tracked DEL)
...
@@ -731,6 +742,38 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
...
@@ -731,6 +742,38 @@ func diffT(ctx context.Context, a, b *Tree, δZTC SetOid, trackIdx map[zodb.Oid]
}
}
// expand keys in new δA -> in B till buckets;
// process B buckets that cover new keys into δ+
if
b
!=
nil
{
// XXX precise range as for a ^^^ ?
btop
:=
&
nodeInRange
{
lo
:
KeyMin
,
hi_
:
KeyMax
,
node
:
b
}
// [-∞, ∞)
bv
=
rangeSplit
{
btop
}
}
bq
:=
[]
*
nodeInRange
{
...
}
for
k
:=
range
Bkeysq
{
bnode
,
ok
:=
bv
.
Get_
(
k
)
if
!
ok
{
continue
// key not covered
}
for
{
switch
bnode
.
node
.
(
type
)
{
case
*
Tree
:
err
:=
bnode
.
node
.
PActivate
(
ctx
);
X
(
err
)
defer
bnode
.
node
.
PDeactivate
()
case
*
Bucket
:
btree
,
ok
:=
bnode
.
node
.
(
*
Tree
}
}
// [i].Key ≤ [i].Child.*.Key < [i+1].Key i ∈ [0, len([]))
// [i].Key ≤ [i].Child.*.Key < [i+1].Key i ∈ [0, len([]))
//
//
...
...
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