Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
b
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
b
Commits
232e9671
Commit
232e9671
authored
Apr 10, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a8edaa30
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
11 deletions
+20
-11
btree.go
btree.go
+20
-11
No files found.
btree.go
View file @
232e9671
...
...
@@ -415,12 +415,11 @@ func (t *Tree) find2(d *d, k interface{} /*K*/, l, h int) (i int, ok bool) {
return
l
,
false
}
// hit
Test
returns whether k belongs to previosly hit data page XXX text
// hit
Find
returns whether k belongs to previosly hit data page XXX text
// if no -1, false is returned
// if yes returned are:
// - i: index corresponding to data entry in t.hit with min(k' : k' >= k)
// - ok: whether k' == k
// XXX -> hitFind
func
(
t
*
Tree
)
hitFind
(
k
interface
{}
/*K*/
)
(
i
int
,
ok
bool
)
{
hit
:=
t
.
hit
if
hit
==
nil
{
...
...
@@ -502,7 +501,6 @@ func (t *Tree) Get(k interface{} /*K*/) (v interface{} /*V*/, ok bool) {
}
func
(
t
*
Tree
)
insert
(
q
*
d
,
i
int
,
k
interface
{}
/*K*/
,
v
interface
{}
/*V*/
)
*
d
{
// TODO update hit
t
.
ver
++
c
:=
q
.
c
if
i
<
c
{
...
...
@@ -512,6 +510,8 @@ func (t *Tree) insert(q *d, i int, k interface{} /*K*/, v interface{} /*V*/) *d
q
.
c
=
c
q
.
d
[
i
]
.
k
,
q
.
d
[
i
]
.
v
=
k
,
v
t
.
c
++
t
.
hit
=
d
t
.
hitIdx
=
i
return
q
}
...
...
@@ -532,12 +532,14 @@ func (t *Tree) Len() int {
func
(
t
*
Tree
)
overflow
(
p
*
x
,
q
*
d
,
pi
,
i
int
,
k
interface
{}
/*K*/
,
v
interface
{}
/*V*/
)
{
t
.
ver
++
t
.
hitP
=
p
l
,
r
:=
p
.
siblings
(
pi
)
if
l
!=
nil
&&
l
.
c
<
2
*
kd
&&
i
!=
0
{
l
.
mvL
(
q
,
1
)
t
.
insert
(
q
,
i
-
1
,
k
,
v
)
p
.
x
[
pi
-
1
]
.
k
=
q
.
d
[
0
]
.
k
t
.
hitPi
=
pi
return
}
...
...
@@ -546,11 +548,13 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{
q
.
mvR
(
r
,
1
)
t
.
insert
(
q
,
i
,
k
,
v
)
p
.
x
[
pi
]
.
k
=
r
.
d
[
0
]
.
k
t
.
hitPi
=
pi
return
}
t
.
insert
(
r
,
0
,
k
,
v
)
p
.
x
[
pi
]
.
k
=
k
t
.
hitPi
=
pi
+
1
return
}
...
...
@@ -660,15 +664,18 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
}
// data page found - perform the update
if
ok
{
switch
{
case
ok
:
dd
.
d
[
i
]
.
v
=
v
}
else
{
switch
{
case
dd
.
c
<
2
*
kd
:
t
.
insert
(
dd
,
i
,
k
,
v
)
default
:
t
.
overflow
(
p
,
dd
,
pi
,
i
,
k
,
v
)
}
t
.
hit
,
t
.
hitIdx
=
dd
,
i
t
.
hitP
,
t
.
hitPi
=
p
,
pi
case
dd
.
c
<
2
*
kd
:
t
.
insert
(
dd
,
i
,
k
,
v
)
t
.
hitP
,
t
.
hitPi
=
p
,
pi
default
:
t
.
overflow
(
p
,
dd
,
pi
,
i
,
k
,
v
)
}
}
...
...
@@ -778,6 +785,7 @@ func (t *Tree) split(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{} /
if
i
>
kd
{
done
=
true
t
.
insert
(
r
,
i
-
kd
,
k
,
v
)
t
.
hitPi
=
pi
+
1
}
if
pi
>=
0
{
p
.
insert
(
pi
,
r
.
d
[
0
]
.
k
,
r
)
...
...
@@ -789,6 +797,7 @@ func (t *Tree) split(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{} /
}
t
.
insert
(
q
,
i
,
k
,
v
)
t
.
hitPi
=
pi
}
func
(
t
*
Tree
)
splitX
(
p
*
x
,
q
*
x
,
pi
int
,
i
int
)
(
*
x
,
int
)
{
...
...
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