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
96c28df2
Commit
96c28df2
authored
Jun 23, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
ccc251b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
18 deletions
+19
-18
wcfs/δbtail.go
wcfs/δbtail.go
+19
-18
No files found.
wcfs/δbtail.go
View file @
96c28df2
...
...
@@ -505,22 +505,21 @@ type nodeInRange struct {
node
Node
}
// rangeCover represents set of nodes covering a range.
// nodes come with key↑ and not intersection [lo,hi)
// XXX -> nodeSet? nodeSetInRange?
type
rangeCover
[]
*
nodeInRange
// key↑
// rangeSplit represents set of nodes covering a range.
// nodes come with key↑ and no intersection in between their [lo,hi)
type
rangeSplit
[]
*
nodeInRange
// key↑
// Get returns node covering key k.
// Get panics if k is outside covered range.
func
(
r
c
rangeCover
)
Get
(
k
Key
)
*
nodeInRange
{
// XXX -> Get_ -> rn, ok
i
:=
sort
.
Search
(
len
(
r
c
),
func
(
i
int
)
bool
{
return
k
<=
r
c
[
i
]
.
hi_
func
(
r
s
rangeSplit
)
Get
(
k
Key
)
*
nodeInRange
{
// XXX -> Get_ -> rn, ok
i
:=
sort
.
Search
(
len
(
r
s
),
func
(
i
int
)
bool
{
return
k
<=
r
s
[
i
]
.
hi_
})
if
i
==
len
(
r
c
)
{
if
i
==
len
(
r
s
)
{
panicf
(
"key %v not covered"
,
k
)
// XXX + coverage: ...
}
rn
:=
r
c
[
i
]
rn
:=
r
s
[
i
]
if
!
(
rn
.
lo
<=
k
&&
k
<=
rn
.
hi_
)
{
panicf
(
"BUG: get(%v) -> [%v, %v]"
,
k
,
rn
.
lo
,
rn
.
hi_
)
}
...
...
@@ -530,15 +529,15 @@ func (rc rangeCover) Get(k Key) *nodeInRange { // XXX -> Get_ -> rn, ok
// Expand replaces rnode with its children.
//
// rnode must be initially in
rc
.
// rnode must be initially in
*prs
.
// rnode.node must be tree.
// rnode.node must be aleady activated.
func
(
pr
c
*
rangeCover
)
Expand
(
rnode
*
nodeInRange
)
[]
*
nodeInRange
{
r
c
:=
*
prc
i
:=
sort
.
Search
(
len
(
r
c
),
func
(
i
int
)
bool
{
return
rnode
.
hi_
<=
r
c
[
i
]
.
hi_
func
(
pr
s
*
rangeCover
)
Expand
(
rnode
*
nodeInRange
)
[]
*
nodeInRange
{
r
s
:=
*
prs
i
:=
sort
.
Search
(
len
(
r
s
),
func
(
i
int
)
bool
{
return
rnode
.
hi_
<=
r
s
[
i
]
.
hi_
})
if
i
==
len
(
r
c
)
||
rc
[
i
]
!=
rnode
{
if
i
==
len
(
r
s
)
||
rs
[
i
]
!=
rnode
{
panicf
(
"%s not in rangeCover"
,
rnode
)
}
...
...
@@ -563,7 +562,7 @@ func (prc *rangeCover) Expand(rnode *nodeInRange) []*nodeInRange {
}
// del[i]; insert(@i, children)
*
pr
c
=
append
(
rc
[
:
i
],
append
(
children
,
rc
[
i
+
1
:
]
...
)
...
)
*
pr
s
=
append
(
rs
[
:
i
],
append
(
children
,
rs
[
i
+
1
:
]
...
)
...
)
return
children
}
...
...
@@ -573,7 +572,7 @@ func (rc rangeCover) String() string {
if
s
!=
""
{
s
+=
" "
}
s
+=
fmt
.
Sprintf
(
"
[%v,%v]%s"
,
rn
.
lo
,
rn
.
hi_
,
vnode
(
rn
.
node
)
)
s
+=
fmt
.
Sprintf
(
"
%s"
,
rn
)
}
return
s
}
...
...
@@ -1335,7 +1334,9 @@ func vnode(node Node) string {
}
func
(
rn
nodeInRange
)
String
()
string
{
return
fmt
.
Sprintf
(
"[%v,%v]%s"
,
rn
.
lo
,
rn
.
hi_
,
vnode
(
rn
.
node
))
slo
:=
"-∞"
;
if
rn
.
lo
>
KeyMin
{
slo
=
fmt
.
Sprintf
(
"%v"
,
rn
.
lo
)
}
shi
:=
"∞"
;
if
rn
.
hi_
<
KeyMax
{
shi
=
fmt
.
Sprintf
(
"%v"
,
rn
.
hi_
+
1
)
}
return
fmt
.
Sprintf
(
"[%s,%s)%s"
,
slo
,
shi
,
vnode
(
rn
.
node
))
}
func
(
track
nodeTrack
)
String
()
string
{
...
...
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