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
38715d34
Commit
38715d34
authored
Jun 02, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
1cbb2749
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
11 deletions
+42
-11
wcfs/internal/xbtree/rangeset.go
wcfs/internal/xbtree/rangeset.go
+41
-10
wcfs/internal/xbtree/δbtail.go
wcfs/internal/xbtree/δbtail.go
+1
-1
No files found.
wcfs/internal/xbtree/rangeset.go
View file @
38715d34
...
...
@@ -32,7 +32,8 @@ type Range struct {
// RangeSet is set of non-overlapping Key ranges.
type
RangeSet
struct
{
// TODO use BTree lo->hi_ instead
// TODO rework to use BTree lo->hi_ instead if performance turns out to
// be not acceptable
rangev
[]
Range
// lo↑
}
...
...
@@ -95,6 +96,39 @@ func (A *RangeSet) DifferenceInplace(B *RangeSet) {
// --------
// verify check RangeSet for internal consistency:
// - ranges must be not overlapping and ↑
func
(
S
*
RangeSet
)
verify
()
{
// XXX !debug -> return ?
var
badv
[]
string
badf
:=
func
(
format
string
,
argv
...
interface
{})
{
badv
=
append
(
badv
,
fmt
.
Sprintf
(
format
,
argv
...
))
}
defer
func
()
{
if
badv
!=
nil
{
emsg
:=
fmt
.
Sprintf
(
"S.verify: fail:
\n\n
"
)
for
_
,
bad
:=
range
badv
{
emsg
+=
fmt
.
Sprintf
(
"- %s
\n
"
,
bad
)
}
emsg
+=
fmt
.
Sprintf
(
"
\n
S: %s
\n
"
,
S
)
panic
(
emsg
)
}
}()
hi_Prev
:=
KeyMin
for
i
,
r
:=
range
S
.
rangev
{
if
!
(
r
.
hi_
>=
r
.
lo
)
{
badf
(
"[%d]: hi_ < lo"
,
i
)
}
if
!
(
r
.
lo
>=
hi_Prev
)
{
badf
(
"[%d]: lo < hi_Prev"
,
i
)
}
hi_Prev
=
r
.
hi_
}
}
// Clone returns copy of the set.
func
(
orig
*
RangeSet
)
Clone
()
*
RangeSet
{
klon
:=
&
RangeSet
{}
...
...
@@ -102,15 +136,6 @@ func (orig *RangeSet) Clone() *RangeSet {
return
klon
}
// XXX RangeSet.verify to check ranges are not overlapping and ↑
func
(
r
Range
)
String
()
string
{
slo
:=
"-∞"
;
if
r
.
lo
>
KeyMin
{
slo
=
fmt
.
Sprintf
(
"%v"
,
r
.
lo
)
}
shi
:=
"∞"
;
if
r
.
hi_
<
KeyMax
{
shi
=
fmt
.
Sprintf
(
"%v"
,
r
.
hi_
+
1
)
}
return
fmt
.
Sprintf
(
"[%s,%s)"
,
slo
,
shi
)
}
func
(
S
RangeSet
)
String
()
string
{
s
:=
"{"
for
i
,
r
:=
range
S
.
rangev
{
...
...
@@ -122,3 +147,9 @@ func (S RangeSet) String() string {
s
+=
"}"
return
s
}
func
(
r
Range
)
String
()
string
{
slo
:=
"-∞"
;
if
r
.
lo
>
KeyMin
{
slo
=
fmt
.
Sprintf
(
"%v"
,
r
.
lo
)
}
shi
:=
"∞"
;
if
r
.
hi_
<
KeyMax
{
shi
=
fmt
.
Sprintf
(
"%v"
,
r
.
hi_
+
1
)
}
return
fmt
.
Sprintf
(
"[%s,%s)"
,
slo
,
shi
)
}
wcfs/internal/xbtree/δbtail.go
View file @
38715d34
...
...
@@ -172,7 +172,7 @@ func (orig *ΔBtail) clone() *ΔBtail {
klon
.
byRoot
=
make
(
map
[
zodb
.
Oid
]
*
ΔTtail
,
len
(
orig
.
byRoot
))
for
root
,
origΔTtail
:=
range
orig
.
byRoot
{
klonΔTtail
:=
&
ΔTtail
{}
klonΔTtail
.
vδT
=
append
(
nil
,
origΔTtail
.
vδT
...
)
klonΔTtail
.
vδT
=
append
(
klonΔTtail
.
vδT
,
origΔTtail
.
vδT
...
)
klonΔTtail
.
KVAtTail
=
make
(
map
[
Key
]
Value
,
len
(
origΔTtail
.
KVAtTail
))
for
k
,
v
:=
range
origΔTtail
.
KVAtTail
{
klonΔTtail
.
KVAtTail
[
k
]
=
v
...
...
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