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
21bd85f5
Commit
21bd85f5
authored
Jun 03, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
9b023909
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
61 deletions
+89
-61
wcfs/internal/xbtree/rangeset.go
wcfs/internal/xbtree/rangeset.go
+6
-0
wcfs/internal/xbtree/rangeset_test.go
wcfs/internal/xbtree/rangeset_test.go
+9
-9
wcfs/internal/xbtree/treediff.go
wcfs/internal/xbtree/treediff.go
+74
-52
No files found.
wcfs/internal/xbtree/rangeset.go
View file @
21bd85f5
...
...
@@ -377,6 +377,12 @@ func (S *RangedKeySet) Clear() {
S
.
rangev
=
nil
}
// AllRanges returns slice of all key ranges in the set.
// XXX -> iter?
func
(
S
*
RangedKeySet
)
AllRanges
()
/*readonly*/
[]
KeyRange
{
return
S
.
rangev
}
func
(
S
RangedKeySet
)
String
()
string
{
s
:=
"{"
for
i
,
r
:=
range
S
.
rangev
{
...
...
wcfs/internal/xbtree/rangeset_test.go
View file @
21bd85f5
...
...
@@ -129,18 +129,18 @@ func TestRangedKeySet(t *testing.T) {
t
.
Errorf
(
"Difference:
\n
A: %s
\n
B: %s
\n
->d: %s
\n
okD: %s
\n
"
,
tt
.
A
,
tt
.
B
,
D
,
tt
.
Difference
)
}
// HasRange
XXX use AllRanges instead of direct .rangev access
assertHasRange
(
t
,
A
.
rangev
,
A
,
true
)
assertHasRange
(
t
,
B
.
rangev
,
B
,
true
)
assertHasRange
(
t
,
A
.
rangev
,
U
,
true
)
assertHasRange
(
t
,
B
.
rangev
,
U
,
true
)
// HasRange
assertHasRange
(
t
,
A
.
AllRanges
()
,
A
,
true
)
assertHasRange
(
t
,
B
.
AllRanges
()
,
B
,
true
)
assertHasRange
(
t
,
A
.
AllRanges
()
,
U
,
true
)
assertHasRange
(
t
,
B
.
AllRanges
()
,
U
,
true
)
Dab
:=
D
Dba
:=
B
.
Difference
(
A
)
assertHasRange
(
t
,
Dab
.
rangev
,
A
,
true
)
assertHasRange
(
t
,
Dab
.
rangev
,
B
,
false
)
assertHasRange
(
t
,
Dba
.
rangev
,
B
,
true
)
assertHasRange
(
t
,
Dba
.
rangev
,
A
,
false
)
assertHasRange
(
t
,
Dab
.
AllRanges
()
,
A
,
true
)
assertHasRange
(
t
,
Dab
.
AllRanges
()
,
B
,
false
)
assertHasRange
(
t
,
Dba
.
AllRanges
()
,
B
,
true
)
assertHasRange
(
t
,
Dba
.
AllRanges
()
,
A
,
false
)
}
}
...
...
wcfs/internal/xbtree/treediff.go
View file @
21bd85f5
...
...
@@ -714,33 +714,44 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackSet PPTreeSubSet)
break
}
for
k
:=
range
Bkqueue
{
b
,
err
:=
Bv
.
GetToLeaf
(
ctx
,
k
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
tracef
(
" B k%d -> %s
\n
"
,
k
,
b
)
// +bucket if that bucket is reached for the first time
if
!
b
.
done
{
var
δB
map
[
Key
]
ΔValue
bbucket
,
ok
:=
b
.
node
.
(
*
Bucket
)
if
ok
{
// !ok means ø tree
δB
,
err
=
diffB
(
ctx
,
nil
,
bbucket
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
}
// for k := range Bkqueue {
for
_
,
r
:=
range
Bkqueue
.
AllRanges
()
{
lo
:=
r
.
lo
for
{
b
,
err
:=
Bv
.
GetToLeaf
(
ctx
,
lo
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
tracef
(
" B k%d -> %s
\n
"
,
lo
,
b
)
// +bucket if that bucket is reached for the first time
if
!
b
.
done
{
var
δB
map
[
Key
]
ΔValue
bbucket
,
ok
:=
b
.
node
.
(
*
Bucket
)
if
ok
{
// !ok means ø tree
δB
,
err
=
diffB
(
ctx
,
nil
,
bbucket
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
}
// δ <- δB
err
=
δMerge
(
δ
,
δB
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
δtrack
.
Add
.
AddPath
(
b
.
Path
())
// Akqueue <- δB
br
:=
KeyRange
{
b
.
lo
,
b
.
hi_
}
Bkdone
.
AddRange
(
br
)
Aktodo
(
br
)
/*
for k_ := range δB {
Bkdone.Add(k_)
Aktodo(k_)
}
*/
// δ <- δB
err
=
δMerge
(
δ
,
δB
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
δtrack
.
Add
.
AddPath
(
b
.
Path
())
// Akqueue <- δB
br
:=
KeyRange
{
b
.
lo
,
b
.
hi_
}
Bkdone
.
AddRange
(
br
)
Aktodo
(
br
)
/*
for k_ := range δB {
Bkdone.Add(k_)
Aktodo(k_)
b
.
done
=
true
}
*/
b
.
done
=
true
// stop if r coverage is complete
if
r
.
hi_
<=
b
.
hi_
{
break
}
// continue with next right bucket
lo
=
b
.
hi_
+
1
}
// XXX k is not there -> hole XXX test XXX <- kill?
...
...
@@ -749,38 +760,49 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackSet PPTreeSubSet)
tracef
(
"
\n
"
)
tracef
(
" Akq: %s
\n
"
,
Akqueue
)
for
k
:=
range
Akqueue
{
a
,
err
:=
Av
.
GetToLeaf
(
ctx
,
k
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
tracef
(
" A k%d -> %s
\n
"
,
k
,
a
)
// -bucket if that bucket is reached for the first time
if
!
a
.
done
{
var
δA
map
[
Key
]
ΔValue
abucket
,
ok
:=
a
.
node
.
(
*
Bucket
)
if
ok
{
// !ok means ø tree
δA
,
err
=
diffB
(
ctx
,
abucket
,
nil
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
}
// for k := range Akqueue {
for
_
,
r
:=
range
Akqueue
.
AllRanges
()
{
lo
:=
r
.
lo
for
{
a
,
err
:=
Av
.
GetToLeaf
(
ctx
,
lo
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
tracef
(
" A k%d -> %s
\n
"
,
lo
,
a
)
// -bucket if that bucket is reached for the first time
if
!
a
.
done
{
var
δA
map
[
Key
]
ΔValue
abucket
,
ok
:=
a
.
node
.
(
*
Bucket
)
if
ok
{
// !ok means ø tree
δA
,
err
=
diffB
(
ctx
,
abucket
,
nil
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
}
// δ <- δA
err
=
δMerge
(
δ
,
δA
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
δtrack
.
Del
.
AddPath
(
a
.
Path
())
// δ <- δA
err
=
δMerge
(
δ
,
δA
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
err
}
δtrack
.
Del
.
AddPath
(
a
.
Path
())
// Bkqueue <- a.range
ar
:=
KeyRange
{
a
.
lo
,
a
.
hi_
}
Akdone
.
AddRange
(
ar
)
Bktodo
(
ar
)
/* XXX kill
// Bkqueue <- δA
for k_ := range δA {
Akdone.Add(k_)
Bktodo(k_)
}
// Bkqueue <- holes(a.range)
for k_ := range holeIdx.GetInRange(a.lo, a.hi_) {
Bktodo(k_)
}
*/
// Bkqueue <- a.range
ar
:=
KeyRange
{
a
.
lo
,
a
.
hi_
}
Akdone
.
AddRange
(
ar
)
Bktodo
(
ar
)
/* XXX kill
// Bkqueue <- δA
for k_ := range δA {
Akdone.Add(k_)
Bktodo(k_)
a
.
done
=
true
}
// Bkqueue <- holes(a.range)
for k_ := range holeIdx.GetInRange(a.lo, a.hi_) {
Bktodo(k_)
}
*/
a
.
done
=
true
// stop if r coverage is complete
if
r
.
hi_
<=
a
.
hi_
{
break
}
// continue with next right bucket
lo
=
a
.
hi_
+
1
}
}
Akqueue
.
Clear
()
...
...
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