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
348288f6
Commit
348288f6
authored
Jun 03, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a9a791c5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
9 deletions
+18
-9
wcfs/internal/xbtree/pptreesubset.go
wcfs/internal/xbtree/pptreesubset.go
+4
-4
wcfs/internal/xbtree/rangeset.go
wcfs/internal/xbtree/rangeset.go
+11
-4
wcfs/internal/xbtree/rangeset_test.go
wcfs/internal/xbtree/rangeset_test.go
+3
-1
No files found.
wcfs/internal/xbtree/pptreesubset.go
View file @
348288f6
...
@@ -147,7 +147,7 @@ func (A PPTreeSubSet) Union(B PPTreeSubSet) PPTreeSubSet {
...
@@ -147,7 +147,7 @@ func (A PPTreeSubSet) Union(B PPTreeSubSet) PPTreeSubSet {
// In other words it adds B nodes to A.
// In other words it adds B nodes to A.
func
(
A
PPTreeSubSet
)
UnionInplace
(
B
PPTreeSubSet
)
{
func
(
A
PPTreeSubSet
)
UnionInplace
(
B
PPTreeSubSet
)
{
if
debugPPSet
{
if
debugPPSet
{
fmt
.
Printf
(
"
\n\n
Union
Inplace
:
\n
"
)
fmt
.
Printf
(
"
\n\n
Union:
\n
"
)
fmt
.
Printf
(
" A: %s
\n
"
,
A
)
fmt
.
Printf
(
" A: %s
\n
"
,
A
)
fmt
.
Printf
(
" B: %s
\n
"
,
B
)
fmt
.
Printf
(
" B: %s
\n
"
,
B
)
defer
fmt
.
Printf
(
"->U: %s
\n
"
,
A
)
defer
fmt
.
Printf
(
"->U: %s
\n
"
,
A
)
...
@@ -175,7 +175,7 @@ func (A PPTreeSubSet) Difference(B PPTreeSubSet) PPTreeSubSet {
...
@@ -175,7 +175,7 @@ func (A PPTreeSubSet) Difference(B PPTreeSubSet) PPTreeSubSet {
// In other words it removes B nodes from A while still maintaining A as PP-connected.
// In other words it removes B nodes from A while still maintaining A as PP-connected.
func
(
A
PPTreeSubSet
)
DifferenceInplace
(
B
PPTreeSubSet
)
{
func
(
A
PPTreeSubSet
)
DifferenceInplace
(
B
PPTreeSubSet
)
{
if
debugPPSet
{
if
debugPPSet
{
fmt
.
Printf
(
"
\n\n
Difference
Inplace
:
\n
"
)
fmt
.
Printf
(
"
\n\n
Difference:
\n
"
)
fmt
.
Printf
(
" A: %s
\n
"
,
A
)
fmt
.
Printf
(
" A: %s
\n
"
,
A
)
fmt
.
Printf
(
" B: %s
\n
"
,
B
)
fmt
.
Printf
(
" B: %s
\n
"
,
B
)
defer
fmt
.
Printf
(
"->D: %s
\n
"
,
A
)
defer
fmt
.
Printf
(
"->D: %s
\n
"
,
A
)
...
@@ -192,7 +192,7 @@ func (A PPTreeSubSet) DifferenceInplace(B PPTreeSubSet) {
...
@@ -192,7 +192,7 @@ func (A PPTreeSubSet) DifferenceInplace(B PPTreeSubSet) {
func
(
A
PPTreeSubSet
)
xUnionInplace
(
B
PPTreeSubSet
)
{
func
(
A
PPTreeSubSet
)
xUnionInplace
(
B
PPTreeSubSet
)
{
if
debugPPSet
{
if
debugPPSet
{
fmt
.
Printf
(
"
\n\n
xUnion
Inplace
:
\n
"
)
fmt
.
Printf
(
"
\n\n
xUnion:
\n
"
)
fmt
.
Printf
(
" a: %s
\n
"
,
A
)
fmt
.
Printf
(
" a: %s
\n
"
,
A
)
fmt
.
Printf
(
" b: %s
\n
"
,
B
)
fmt
.
Printf
(
" b: %s
\n
"
,
B
)
defer
fmt
.
Printf
(
" ->u: %s
\n
"
,
A
)
defer
fmt
.
Printf
(
" ->u: %s
\n
"
,
A
)
...
@@ -226,7 +226,7 @@ func (A PPTreeSubSet) xUnionInplace(B PPTreeSubSet) {
...
@@ -226,7 +226,7 @@ func (A PPTreeSubSet) xUnionInplace(B PPTreeSubSet) {
func
(
A
PPTreeSubSet
)
xDifferenceInplace
(
B
PPTreeSubSet
)
{
func
(
A
PPTreeSubSet
)
xDifferenceInplace
(
B
PPTreeSubSet
)
{
if
debugPPSet
{
if
debugPPSet
{
fmt
.
Printf
(
"
\n\n
xDifference
Inplace
:
\n
"
)
fmt
.
Printf
(
"
\n\n
xDifference:
\n
"
)
fmt
.
Printf
(
" a: %s
\n
"
,
A
)
fmt
.
Printf
(
" a: %s
\n
"
,
A
)
fmt
.
Printf
(
" b: %s
\n
"
,
B
)
fmt
.
Printf
(
" b: %s
\n
"
,
B
)
defer
fmt
.
Printf
(
" ->d: %s
\n
"
,
A
)
defer
fmt
.
Printf
(
" ->d: %s
\n
"
,
A
)
...
...
wcfs/internal/xbtree/rangeset.go
View file @
348288f6
...
@@ -31,18 +31,25 @@ type Range struct {
...
@@ -31,18 +31,25 @@ type Range struct {
}
}
// RangeSet is set of non-overlapping Key ranges.
// RangeSet is set of non-overlapping Key ranges.
// XXX RangeSet is set of Keys with adjacent keys coaleced into Ranges.
// XXX -> RangedSet ?
type
RangeSet
struct
{
type
RangeSet
struct
{
// TODO rework to use BTree lo->hi_ instead if performance turns out to
// TODO rework to use BTree lo->hi_ instead if performance turns out to
// be not acceptable
// be not acceptable
rangev
[]
Range
// lo↑
rangev
[]
Range
// lo↑
}
}
// XXX Add/Del - just add/del key
// Add adds Range r to the set of keys. // XXX -> UnionInplace1 ?
// Add adds Range r to the set of keys. // XXX -> UnionInplace1 ?
// XXX -> AddRange ?
func
(
S
*
RangeSet
)
Add
(
r
Range
)
{
func
(
S
*
RangeSet
)
Add
(
r
Range
)
{
panic
(
"TODO"
)
// XXX
panic
(
"TODO"
)
// XXX
}
}
// Del removes Range r from the set of keys. // XXX -> DifferenceInplace1 ?
// Del removes Range r from the set of keys. // XXX -> DifferenceInplace1 ?
// XXX -> DelRange?
func
(
S
*
RangeSet
)
Del
(
r
Range
)
{
func
(
S
*
RangeSet
)
Del
(
r
Range
)
{
panic
(
"TODO"
)
// XXX
panic
(
"TODO"
)
// XXX
}
}
...
@@ -118,12 +125,12 @@ func (S *RangeSet) verify() {
...
@@ -118,12 +125,12 @@ func (S *RangeSet) verify() {
hi_Prev
:=
KeyMin
hi_Prev
:=
KeyMin
for
i
,
r
:=
range
S
.
rangev
{
for
i
,
r
:=
range
S
.
rangev
{
if
!
(
r
.
hi_
>=
r
.
lo
)
{
if
!
(
hi_Prev
<=
r
.
lo
)
{
badf
(
"[%d]: hi_ < lo"
,
i
)
}
if
!
(
r
.
lo
>=
hi_Prev
)
{
badf
(
"[%d]: lo < hi_Prev"
,
i
)
badf
(
"[%d]: lo < hi_Prev"
,
i
)
}
}
if
!
(
r
.
lo
<
r
.
hi_
)
{
badf
(
"[%d]: lo >= hi_"
,
i
)
}
hi_Prev
=
r
.
hi_
hi_Prev
=
r
.
hi_
}
}
}
}
...
...
wcfs/internal/xbtree/rangeset_test.go
View file @
348288f6
...
@@ -64,7 +64,9 @@ func TestRangeSet(t *testing.T) {
...
@@ -64,7 +64,9 @@ func TestRangeSet(t *testing.T) {
S
(
1
,
2
),
// U
S
(
1
,
2
),
// U
S
()),
// D
S
()),
// D
// XXX
// XXX Add -> merge
// XXX Del -> split
// XXX several ranges -> Del(-oo, oo) -> ø
}
}
for
_
,
tt
:=
range
testv
{
for
_
,
tt
:=
range
testv
{
...
...
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