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
33317fd1
Commit
33317fd1
authored
Jan 14, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a0ed0fea
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
37 deletions
+68
-37
go/zodb/btree/btree.go
go/zodb/btree/btree.go
+2
-3
go/zodb/btree/btree.go.in
go/zodb/btree/btree.go.in
+22
-12
go/zodb/btree/ziobtree.go
go/zodb/btree/ziobtree.go
+22
-11
go/zodb/btree/zlobtree.go
go/zodb/btree/zlobtree.go
+22
-11
No files found.
go/zodb/btree/btree.go
View file @
33317fd1
// Copyright (C) 2018 Nexedi SA and Contributors.
// Copyright (C) 2018
-2019
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Kirill Smelkov <kirr@nexedi.com>
//
// Package btree provides B⁺ Trees for ZODB.
// Package btree provides B⁺ Trees for ZODB.
//
//
...
...
go/zodb/btree/btree.go.in
View file @
33317fd1
//
Copyright
(
c
)
2001
,
2002
Zope
Foundation
and
Contributors
.
//
Copyright
(
c
)
2001
,
2002
Zope
Foundation
and
Contributors
.
//
All
Rights
Reserved
.
//
All
Rights
Reserved
.
//
//
//
Copyright
(
C
)
2018
Nexedi
SA
and
Contributors
.
//
Copyright
(
C
)
2018
-
2019
Nexedi
SA
and
Contributors
.
//
Kirill
Smelkov
<
kirr
@
nexedi
.
com
>
//
Kirill
Smelkov
<
kirr
@
nexedi
.
com
>
//
//
//
This
software
is
subject
to
the
provisions
of
the
Zope
Public
License
,
//
This
software
is
subject
to
the
provisions
of
the
Zope
Public
License
,
...
@@ -224,12 +224,15 @@ func (b *Bucket) get(key KEY) (interface{}, bool) {
...
@@ -224,12 +224,15 @@ func (b *Bucket) get(key KEY) (interface{}, bool) {
// ---- min/max key ----
// ---- min/max key ----
// XXX
// MinKey returns minimum key in BTree.
func (t *BTree) MinKey(ctx context.Context) (_ KEY, _ bool, err error) {
//
// If the tree is empty, ok=false is returned.
// t does not need to be activated beforehand.
func (t *BTree) MinKey(ctx context.Context) (_ KEY, ok bool, err error) {
defer xerr.Contextf(&err, "btree(%s): minkey", t.POid())
defer xerr.Contextf(&err, "btree(%s): minkey", t.POid())
err = t.PActivate(ctx)
err = t.PActivate(ctx)
if err != nil {
if err != nil {
return 0, false, err
// XXX 0 ok?
return 0, false, err
}
}
if len(t.data) == 0 {
if len(t.data) == 0 {
...
@@ -238,7 +241,7 @@ func (t *BTree) MinKey(ctx context.Context) (_ KEY, _ bool, err error) {
...
@@ -238,7 +241,7 @@ func (t *BTree) MinKey(ctx context.Context) (_ KEY, _ bool, err error) {
return 0, false, nil
return 0, false, nil
}
}
//
XXX -> just
use t.firstBucket
//
NOTE -> can also
use t.firstBucket
for {
for {
child := t.data[0].child.(zodb.IPersistent)
child := t.data[0].child.(zodb.IPersistent)
t.PDeactivate()
t.PDeactivate()
...
@@ -259,12 +262,15 @@ func (t *BTree) MinKey(ctx context.Context) (_ KEY, _ bool, err error) {
...
@@ -259,12 +262,15 @@ func (t *BTree) MinKey(ctx context.Context) (_ KEY, _ bool, err error) {
}
}
}
}
// XXX
// MaxKey returns maximum key in BTree.
//
// If the tree is empty, ok=false is returned.
// t does not need to be activated beforehand.
func (t *BTree) MaxKey(ctx context.Context) (_ KEY, _ bool, err error) {
func (t *BTree) MaxKey(ctx context.Context) (_ KEY, _ bool, err error) {
defer xerr.Contextf(&err, "btree(%s): maxkey", t.POid())
defer xerr.Contextf(&err, "btree(%s): maxkey", t.POid())
err = t.PActivate(ctx)
err = t.PActivate(ctx)
if err != nil {
if err != nil {
return 0, false, err
// XXX 0 ok?
return 0, false, err
}
}
l := len(t.data)
l := len(t.data)
...
@@ -294,16 +300,20 @@ func (t *BTree) MaxKey(ctx context.Context) (_ KEY, _ bool, err error) {
...
@@ -294,16 +300,20 @@ func (t *BTree) MaxKey(ctx context.Context) (_ KEY, _ bool, err error) {
}
}
}
}
// XXX
// MinKey returns minimum key in Bucket.
func (b *Bucket) MinKey() (KEY, bool) {
//
// If the bucket is empty, ok=false is returned.
func (b *Bucket) MinKey() (_ KEY, ok bool) {
if len(b.keys) == 0 {
if len(b.keys) == 0 {
return 0, false
return 0, false
}
}
return b.keys[0], true
return b.keys[0], true
}
}
// XXX
// MaxKey returns maximum key in Bucket.
func (b *Bucket) MaxKey() (KEY, bool) {
//
// If the bucket is empty, ok=false is returned.
func (b *Bucket) MaxKey() (_ KEY, ok bool) {
l := len(b.keys)
l := len(b.keys)
if l == 0 {
if l == 0 {
return 0, false
return 0, false
...
...
go/zodb/btree/ziobtree.go
View file @
33317fd1
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
// Copyright (c) 2001, 2002 Zope Foundation and Contributors.
// Copyright (c) 2001, 2002 Zope Foundation and Contributors.
// All Rights Reserved.
// All Rights Reserved.
//
//
// Copyright (C) 2018 Nexedi SA and Contributors.
// Copyright (C) 2018
-2019
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Kirill Smelkov <kirr@nexedi.com>
//
//
// This software is subject to the provisions of the Zope Public License,
// This software is subject to the provisions of the Zope Public License,
...
@@ -226,12 +226,15 @@ func (b *IOBucket) get(key int32) (interface{}, bool) {
...
@@ -226,12 +226,15 @@ func (b *IOBucket) get(key int32) (interface{}, bool) {
// ---- min/max key ----
// ---- min/max key ----
// XXX
// MinKey returns minimum key in IOBTree.
func
(
t
*
IOBTree
)
MinKey
(
ctx
context
.
Context
)
(
_
int32
,
_
bool
,
err
error
)
{
//
// If the tree is empty, ok=false is returned.
// t does not need to be activated beforehand.
func
(
t
*
IOBTree
)
MinKey
(
ctx
context
.
Context
)
(
_
int32
,
ok
bool
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"btree(%s): minkey"
,
t
.
POid
())
defer
xerr
.
Contextf
(
&
err
,
"btree(%s): minkey"
,
t
.
POid
())
err
=
t
.
PActivate
(
ctx
)
err
=
t
.
PActivate
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
false
,
err
// XXX 0 ok?
return
0
,
false
,
err
}
}
if
len
(
t
.
data
)
==
0
{
if
len
(
t
.
data
)
==
0
{
...
@@ -240,6 +243,7 @@ func (t *IOBTree) MinKey(ctx context.Context) (_ int32, _ bool, err error) {
...
@@ -240,6 +243,7 @@ func (t *IOBTree) MinKey(ctx context.Context) (_ int32, _ bool, err error) {
return
0
,
false
,
nil
return
0
,
false
,
nil
}
}
// NOTE -> can also use t.firstBucket
for
{
for
{
child
:=
t
.
data
[
0
]
.
child
.
(
zodb
.
IPersistent
)
child
:=
t
.
data
[
0
]
.
child
.
(
zodb
.
IPersistent
)
t
.
PDeactivate
()
t
.
PDeactivate
()
...
@@ -260,12 +264,15 @@ func (t *IOBTree) MinKey(ctx context.Context) (_ int32, _ bool, err error) {
...
@@ -260,12 +264,15 @@ func (t *IOBTree) MinKey(ctx context.Context) (_ int32, _ bool, err error) {
}
}
}
}
// XXX
// MaxKey returns maximum key in IOBTree.
//
// If the tree is empty, ok=false is returned.
// t does not need to be activated beforehand.
func
(
t
*
IOBTree
)
MaxKey
(
ctx
context
.
Context
)
(
_
int32
,
_
bool
,
err
error
)
{
func
(
t
*
IOBTree
)
MaxKey
(
ctx
context
.
Context
)
(
_
int32
,
_
bool
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"btree(%s): maxkey"
,
t
.
POid
())
defer
xerr
.
Contextf
(
&
err
,
"btree(%s): maxkey"
,
t
.
POid
())
err
=
t
.
PActivate
(
ctx
)
err
=
t
.
PActivate
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
false
,
err
// XXX 0 ok?
return
0
,
false
,
err
}
}
l
:=
len
(
t
.
data
)
l
:=
len
(
t
.
data
)
...
@@ -295,16 +302,20 @@ func (t *IOBTree) MaxKey(ctx context.Context) (_ int32, _ bool, err error) {
...
@@ -295,16 +302,20 @@ func (t *IOBTree) MaxKey(ctx context.Context) (_ int32, _ bool, err error) {
}
}
}
}
// XXX
// MinKey returns minimum key in IOBucket.
func
(
b
*
IOBucket
)
MinKey
()
(
int32
,
bool
)
{
//
// If the bucket is empty, ok=false is returned.
func
(
b
*
IOBucket
)
MinKey
()
(
_
int32
,
ok
bool
)
{
if
len
(
b
.
keys
)
==
0
{
if
len
(
b
.
keys
)
==
0
{
return
0
,
false
return
0
,
false
}
}
return
b
.
keys
[
0
],
true
return
b
.
keys
[
0
],
true
}
}
// XXX
// MaxKey returns maximum key in IOBucket.
func
(
b
*
IOBucket
)
MaxKey
()
(
int32
,
bool
)
{
//
// If the bucket is empty, ok=false is returned.
func
(
b
*
IOBucket
)
MaxKey
()
(
_
int32
,
ok
bool
)
{
l
:=
len
(
b
.
keys
)
l
:=
len
(
b
.
keys
)
if
l
==
0
{
if
l
==
0
{
return
0
,
false
return
0
,
false
...
...
go/zodb/btree/zlobtree.go
View file @
33317fd1
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
// Copyright (c) 2001, 2002 Zope Foundation and Contributors.
// Copyright (c) 2001, 2002 Zope Foundation and Contributors.
// All Rights Reserved.
// All Rights Reserved.
//
//
// Copyright (C) 2018 Nexedi SA and Contributors.
// Copyright (C) 2018
-2019
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Kirill Smelkov <kirr@nexedi.com>
//
//
// This software is subject to the provisions of the Zope Public License,
// This software is subject to the provisions of the Zope Public License,
...
@@ -226,12 +226,15 @@ func (b *LOBucket) get(key int64) (interface{}, bool) {
...
@@ -226,12 +226,15 @@ func (b *LOBucket) get(key int64) (interface{}, bool) {
// ---- min/max key ----
// ---- min/max key ----
// XXX
// MinKey returns minimum key in LOBTree.
func
(
t
*
LOBTree
)
MinKey
(
ctx
context
.
Context
)
(
_
int64
,
_
bool
,
err
error
)
{
//
// If the tree is empty, ok=false is returned.
// t does not need to be activated beforehand.
func
(
t
*
LOBTree
)
MinKey
(
ctx
context
.
Context
)
(
_
int64
,
ok
bool
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"btree(%s): minkey"
,
t
.
POid
())
defer
xerr
.
Contextf
(
&
err
,
"btree(%s): minkey"
,
t
.
POid
())
err
=
t
.
PActivate
(
ctx
)
err
=
t
.
PActivate
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
false
,
err
// XXX 0 ok?
return
0
,
false
,
err
}
}
if
len
(
t
.
data
)
==
0
{
if
len
(
t
.
data
)
==
0
{
...
@@ -240,6 +243,7 @@ func (t *LOBTree) MinKey(ctx context.Context) (_ int64, _ bool, err error) {
...
@@ -240,6 +243,7 @@ func (t *LOBTree) MinKey(ctx context.Context) (_ int64, _ bool, err error) {
return
0
,
false
,
nil
return
0
,
false
,
nil
}
}
// NOTE -> can also use t.firstBucket
for
{
for
{
child
:=
t
.
data
[
0
]
.
child
.
(
zodb
.
IPersistent
)
child
:=
t
.
data
[
0
]
.
child
.
(
zodb
.
IPersistent
)
t
.
PDeactivate
()
t
.
PDeactivate
()
...
@@ -260,12 +264,15 @@ func (t *LOBTree) MinKey(ctx context.Context) (_ int64, _ bool, err error) {
...
@@ -260,12 +264,15 @@ func (t *LOBTree) MinKey(ctx context.Context) (_ int64, _ bool, err error) {
}
}
}
}
// XXX
// MaxKey returns maximum key in LOBTree.
//
// If the tree is empty, ok=false is returned.
// t does not need to be activated beforehand.
func
(
t
*
LOBTree
)
MaxKey
(
ctx
context
.
Context
)
(
_
int64
,
_
bool
,
err
error
)
{
func
(
t
*
LOBTree
)
MaxKey
(
ctx
context
.
Context
)
(
_
int64
,
_
bool
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"btree(%s): maxkey"
,
t
.
POid
())
defer
xerr
.
Contextf
(
&
err
,
"btree(%s): maxkey"
,
t
.
POid
())
err
=
t
.
PActivate
(
ctx
)
err
=
t
.
PActivate
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
false
,
err
// XXX 0 ok?
return
0
,
false
,
err
}
}
l
:=
len
(
t
.
data
)
l
:=
len
(
t
.
data
)
...
@@ -295,16 +302,20 @@ func (t *LOBTree) MaxKey(ctx context.Context) (_ int64, _ bool, err error) {
...
@@ -295,16 +302,20 @@ func (t *LOBTree) MaxKey(ctx context.Context) (_ int64, _ bool, err error) {
}
}
}
}
// XXX
// MinKey returns minimum key in LOBucket.
func
(
b
*
LOBucket
)
MinKey
()
(
int64
,
bool
)
{
//
// If the bucket is empty, ok=false is returned.
func
(
b
*
LOBucket
)
MinKey
()
(
_
int64
,
ok
bool
)
{
if
len
(
b
.
keys
)
==
0
{
if
len
(
b
.
keys
)
==
0
{
return
0
,
false
return
0
,
false
}
}
return
b
.
keys
[
0
],
true
return
b
.
keys
[
0
],
true
}
}
// XXX
// MaxKey returns maximum key in LOBucket.
func
(
b
*
LOBucket
)
MaxKey
()
(
int64
,
bool
)
{
//
// If the bucket is empty, ok=false is returned.
func
(
b
*
LOBucket
)
MaxKey
()
(
_
int64
,
ok
bool
)
{
l
:=
len
(
b
.
keys
)
l
:=
len
(
b
.
keys
)
if
l
==
0
{
if
l
==
0
{
return
0
,
false
return
0
,
false
...
...
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