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
50f570c8
Commit
50f570c8
authored
Oct 08, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go/zodb/btree: Verify that BTree/Bucket keys come in sorted order
This is one of BTree invariants - check it on load.
parent
c1ba9a90
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
3 deletions
+36
-3
go/zodb/btree/btree.go.in
go/zodb/btree/btree.go.in
+12
-1
go/zodb/btree/ziobtree.go
go/zodb/btree/ziobtree.go
+12
-1
go/zodb/btree/zlobtree.go
go/zodb/btree/zlobtree.go
+12
-1
No files found.
go/zodb/btree/btree.go.in
View file @
50f570c8
...
...
@@ -215,6 +215,7 @@ func (b *bucketState) PySetState(pystate interface{}) (err error) {
b
.
keys
=
make
([]
KEY
,
0
,
n
)
b
.
values
=
make
([]
interface
{},
0
,
n
)
var
kprev
int64
for
i
:=
0
;
i
<
n
;
i
++
{
xk
:=
t
[
2
*
i
]
v
:=
t
[
2
*
i
+
1
]
...
...
@@ -229,7 +230,11 @@ func (b *bucketState) PySetState(pystate interface{}) (err error) {
return
fmt
.
Errorf
(
"data: [%d]: key overflows %T"
,
i
,
kk
)
}
//
XXX
check
keys
are
sorted
?
if
i
>
0
&&
!(k > kprev) {
return
fmt
.
Errorf
(
"data: [%d]: key not ↑"
,
i
)
}
kprev
=
k
b
.
keys
=
append
(
b
.
keys
,
kk
)
b
.
values
=
append
(
b
.
values
,
v
)
}
...
...
@@ -325,6 +330,7 @@ func (bt *btreeState) PySetState(pystate interface{}) (err error) {
n
:=
(
len
(
t
)
+
1
)
/
2
bt
.
data
=
make
([]
_BTreeItem
,
0
,
n
)
var
kprev
int64
for
i
,
idx
:=
0
,
0
;
i
<
n
;
i
++
{
key
:=
int64
(
math
.
Min
<
Key
>)
//
KEY
(-
∞
)
(
qualifies
for
≤
)
if
i
>
0
{
...
...
@@ -343,6 +349,11 @@ func (bt *btreeState) PySetState(pystate interface{}) (err error) {
return
fmt
.
Errorf
(
"data: [%d]: key overflows %T"
,
i
,
kkey
)
}
if
i
>
1
&&
!(key > kprev) {
fmt
.
Errorf
(
"data: [%d]: key not ↑"
,
i
)
}
kprev
=
key
switch
child
.(
type
)
{
default
:
return
fmt
.
Errorf
(
"data: [%d]: child must be BTree|Bucket; got %T"
,
i
,
child
)
...
...
go/zodb/btree/ziobtree.go
View file @
50f570c8
...
...
@@ -217,6 +217,7 @@ func (b *iobucketState) PySetState(pystate interface{}) (err error) {
b
.
keys
=
make
([]
int32
,
0
,
n
)
b
.
values
=
make
([]
interface
{},
0
,
n
)
var
kprev
int64
for
i
:=
0
;
i
<
n
;
i
++
{
xk
:=
t
[
2
*
i
]
v
:=
t
[
2
*
i
+
1
]
...
...
@@ -231,7 +232,11 @@ func (b *iobucketState) PySetState(pystate interface{}) (err error) {
return
fmt
.
Errorf
(
"data: [%d]: key overflows %T"
,
i
,
kk
)
}
// XXX check keys are sorted?
if
i
>
0
&&
!
(
k
>
kprev
)
{
return
fmt
.
Errorf
(
"data: [%d]: key not ↑"
,
i
)
}
kprev
=
k
b
.
keys
=
append
(
b
.
keys
,
kk
)
b
.
values
=
append
(
b
.
values
,
v
)
}
...
...
@@ -327,6 +332,7 @@ func (bt *iobtreeState) PySetState(pystate interface{}) (err error) {
n
:=
(
len
(
t
)
+
1
)
/
2
bt
.
data
=
make
([]
_IOBTreeItem
,
0
,
n
)
var
kprev
int64
for
i
,
idx
:=
0
,
0
;
i
<
n
;
i
++
{
key
:=
int64
(
math
.
MinInt32
)
// int32(-∞) (qualifies for ≤)
if
i
>
0
{
...
...
@@ -345,6 +351,11 @@ func (bt *iobtreeState) PySetState(pystate interface{}) (err error) {
return
fmt
.
Errorf
(
"data: [%d]: key overflows %T"
,
i
,
kkey
)
}
if
i
>
1
&&
!
(
key
>
kprev
)
{
fmt
.
Errorf
(
"data: [%d]: key not ↑"
,
i
)
}
kprev
=
key
switch
child
.
(
type
)
{
default
:
return
fmt
.
Errorf
(
"data: [%d]: child must be IOBTree|IOBucket; got %T"
,
i
,
child
)
...
...
go/zodb/btree/zlobtree.go
View file @
50f570c8
...
...
@@ -217,6 +217,7 @@ func (b *lobucketState) PySetState(pystate interface{}) (err error) {
b
.
keys
=
make
([]
int64
,
0
,
n
)
b
.
values
=
make
([]
interface
{},
0
,
n
)
var
kprev
int64
for
i
:=
0
;
i
<
n
;
i
++
{
xk
:=
t
[
2
*
i
]
v
:=
t
[
2
*
i
+
1
]
...
...
@@ -231,7 +232,11 @@ func (b *lobucketState) PySetState(pystate interface{}) (err error) {
return
fmt
.
Errorf
(
"data: [%d]: key overflows %T"
,
i
,
kk
)
}
// XXX check keys are sorted?
if
i
>
0
&&
!
(
k
>
kprev
)
{
return
fmt
.
Errorf
(
"data: [%d]: key not ↑"
,
i
)
}
kprev
=
k
b
.
keys
=
append
(
b
.
keys
,
kk
)
b
.
values
=
append
(
b
.
values
,
v
)
}
...
...
@@ -327,6 +332,7 @@ func (bt *lobtreeState) PySetState(pystate interface{}) (err error) {
n
:=
(
len
(
t
)
+
1
)
/
2
bt
.
data
=
make
([]
_LOBTreeItem
,
0
,
n
)
var
kprev
int64
for
i
,
idx
:=
0
,
0
;
i
<
n
;
i
++
{
key
:=
int64
(
math
.
MinInt64
)
// int64(-∞) (qualifies for ≤)
if
i
>
0
{
...
...
@@ -345,6 +351,11 @@ func (bt *lobtreeState) PySetState(pystate interface{}) (err error) {
return
fmt
.
Errorf
(
"data: [%d]: key overflows %T"
,
i
,
kkey
)
}
if
i
>
1
&&
!
(
key
>
kprev
)
{
fmt
.
Errorf
(
"data: [%d]: key not ↑"
,
i
)
}
kprev
=
key
switch
child
.
(
type
)
{
default
:
return
fmt
.
Errorf
(
"data: [%d]: child must be LOBTree|LOBucket; got %T"
,
i
,
child
)
...
...
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