Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
a452276d
Commit
a452276d
authored
Apr 18, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X storage/fs1/fsb: regenerate @x/refill
parent
fe0f712e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
8 deletions
+78
-8
t/neo/storage/fs1/fsb/fsbtree.go
t/neo/storage/fs1/fsb/fsbtree.go
+77
-7
t/neo/storage/fs1/fsb/fsbtree_util.go
t/neo/storage/fs1/fsb/fsbtree_util.go
+1
-1
No files found.
t/neo/storage/fs1/fsb/fsbtree.go
View file @
a452276d
// DO NOT EDIT - AUTOGENERATED (by gen-fsbtree from github.com/cznic/b
4efd872
)
// DO NOT EDIT - AUTOGENERATED (by gen-fsbtree from github.com/cznic/b
93348d0
)
// KEY=zodb.Oid VALUE=int64
// ---- 8< ----
...
...
@@ -370,6 +370,12 @@ func (t *Tree) Delete(k zodb.Oid) (ok bool) {
}
}
// don't leave previously active data page with < 50% load
if
t
.
hitD
!=
nil
&&
t
.
hitD
.
c
<
kd
&&
t
.
hitP
!=
nil
{
//println("refill")
t
.
refill
(
t
.
hitP
,
t
.
hitD
,
t
.
hitPi
)
}
// data page not quickly found - search and descent from root
pi
:=
-
1
var
p
*
x
...
...
@@ -748,6 +754,12 @@ func (t *Tree) Set(k zodb.Oid, v int64) {
}
}
// don't leave previously active data page with < 50% load
if
t
.
hitD
!=
nil
&&
t
.
hitD
.
c
<
kd
&&
t
.
hitP
!=
nil
{
//println("refill")
t
.
refill
(
t
.
hitP
,
t
.
hitD
,
t
.
hitPi
)
}
// data page not quickly found - search and descent from root
pi
:=
-
1
var
p
*
x
...
...
@@ -899,6 +911,12 @@ func (t *Tree) Put(k zodb.Oid, upd func(oldV int64, exists bool) (newV int64, wr
}
}
// don't leave previously active data page with < 50% load
if
t
.
hitD
!=
nil
&&
t
.
hitD
.
c
<
kd
&&
t
.
hitP
!=
nil
{
//println("refill")
t
.
refill
(
t
.
hitP
,
t
.
hitD
,
t
.
hitPi
)
}
// data page not quickly found - search and descent from root
t
.
hitKminSet
,
t
.
hitKmaxSet
=
false
,
false
// initially [-∞, +∞)
t
.
hitPKminSet
,
t
.
hitPKmaxSet
=
false
,
false
...
...
@@ -988,13 +1006,19 @@ func (t *Tree) split(p *x, q *d, pi, i int, k zodb.Oid, v int64) {
q
.
n
=
r
r
.
p
=
q
copy
(
r
.
d
[
:
],
q
.
d
[
kd
:
2
*
kd
])
for
i
:=
range
q
.
d
[
kd
:
]
{
q
.
d
[
kd
+
i
]
=
zde
// don't copy on sequential bulk-set pattern
if
i
==
2
*
kd
{
t
.
insert
(
r
,
0
,
k
,
v
)
}
else
{
copy
(
r
.
d
[
:
],
q
.
d
[
kd
:
2
*
kd
])
for
i
:=
range
q
.
d
[
kd
:
]
{
q
.
d
[
kd
+
i
]
=
zde
}
q
.
c
=
kd
r
.
c
=
kd
}
q
.
c
=
kd
r
.
c
=
kd
// XXX vs ^^^ (not adding elements)
if
pi
>=
0
{
p
.
insert
(
pi
,
r
.
d
[
0
]
.
k
,
r
)
}
else
{
...
...
@@ -1006,7 +1030,10 @@ func (t *Tree) split(p *x, q *d, pi, i int, k zodb.Oid, v int64) {
}
if
i
>
kd
{
t
.
insert
(
r
,
i
-
kd
,
k
,
v
)
// XXX vvv try to merge with ^^^ t.insert(r, 0, k, v)
if
i
<
2
*
kd
{
t
.
insert
(
r
,
i
-
kd
,
k
,
v
)
}
t
.
setHitKmin
(
p
.
x
[
pi
]
.
k
)
if
pi
+
1
<
p
.
c
{
// k=+∞ @p.c
t
.
setHitKmax
(
p
.
x
[
pi
+
1
]
.
k
)
...
...
@@ -1061,6 +1088,8 @@ func (t *Tree) underflow(p *x, q *d, pi int) {
t
.
ver
++
l
,
r
:=
p
.
siblings
(
pi
)
// TODO don't move 1 elements for bulk-delete patterb (see split for bulk-set case)
if
l
!=
nil
&&
l
.
c
+
q
.
c
>=
2
*
kd
{
l
.
mvR
(
q
,
1
)
p
.
x
[
pi
-
1
]
.
k
=
q
.
d
[
0
]
.
k
...
...
@@ -1181,6 +1210,47 @@ func (t *Tree) underflowX(p *x, q *x, pi int, i int) (*x, int) {
return
q
,
i
}
// refill refills data page to have >= 50% load taking data entries from siblings
// if siblings have not enough entries for such refill, the data page in question is concatenated into one of them.
// XXX naming -> fillup ?
func
(
t
*
Tree
)
refill
(
p
*
x
,
q
*
d
,
pi
int
)
{
t
.
ver
++
l
,
r
:=
p
.
siblings
(
pi
)
δl
:=
0
δr
:=
0
if
l
!=
nil
{
δl
=
l
.
c
-
kd
}
if
r
!=
nil
{
δr
=
r
.
c
-
kd
}
if
q
.
c
+
δl
+
δr
<
kd
{
// cannot refill - concatenate into l or r
if
l
!=
nil
{
t
.
cat
(
p
,
l
,
q
,
pi
-
1
)
}
else
{
t
.
cat
(
p
,
q
,
r
,
pi
)
}
return
}
// refill from siblings
δ
:=
kd
-
q
.
c
δl
=
δ
*
δl
/
(
δl
+
δr
)
δr
=
δ
-
δl
if
δl
!=
0
{
l
.
mvR
(
q
,
δl
)
p
.
x
[
pi
-
1
]
.
k
=
q
.
d
[
0
]
.
k
}
if
δr
!=
0
{
q
.
mvL
(
r
,
δr
)
p
.
x
[
pi
]
.
k
=
r
.
d
[
0
]
.
k
}
}
// ----------------------------------------------------------------- Enumerator
// Close recycles e to a pool for possible later reuse. No references to e
...
...
t/neo/storage/fs1/fsb/fsbtree_util.go
View file @
a452276d
// DO NOT EDIT - AUTOGENERATED (by gen-fsbtree from github.com/cznic/b
4efd872
)
// DO NOT EDIT - AUTOGENERATED (by gen-fsbtree from github.com/cznic/b
93348d0
)
// ---- 8< ----
package
fsb
import
(
...
...
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