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
d0a62510
Commit
d0a62510
authored
Feb 18, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go/zodb/btree: Switch Entry.child to IPersistent
It is either BTree or Bucket.
parent
14dee52f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
33 deletions
+42
-33
go/zodb/btree/btree.go.in
go/zodb/btree/btree.go.in
+14
-11
go/zodb/btree/ziobtree.go
go/zodb/btree/ziobtree.go
+14
-11
go/zodb/btree/zlobtree.go
go/zodb/btree/zlobtree.go
+14
-11
No files found.
go/zodb/btree/btree.go.in
View file @
d0a62510
...
@@ -61,7 +61,7 @@ type BTree struct {
...
@@ -61,7 +61,7 @@ type BTree struct {
//
Key
limits
child
's keys - see BTree.Entryv for details.
//
Key
limits
child
's keys - see BTree.Entryv for details.
type Entry struct {
type Entry struct {
key KEY
key KEY
child
interface{}
// BTree or Bucket
child
zodb.IPersistent
// BTree or Bucket
}
}
// Bucket is a leaf node of a B⁺ tree.
// Bucket is a leaf node of a B⁺ tree.
...
@@ -99,7 +99,7 @@ type BucketEntry struct {
...
@@ -99,7 +99,7 @@ type BucketEntry struct {
func (e *Entry) Key() KEY { return e.key }
func (e *Entry) Key() KEY { return e.key }
// Child returns BTree entry child.
// Child returns BTree entry child.
func (e *Entry) Child()
interface{}
{ return e.child }
func (e *Entry) Child()
zodb.IPersistent
{ return e.child }
// Entryv returns entries of a BTree node.
// Entryv returns entries of a BTree node.
//
//
...
@@ -175,18 +175,21 @@ func (t *BTree) Get(ctx context.Context, key KEY) (_ interface{}, _ bool, err er
...
@@ -175,18 +175,21 @@ func (t *BTree) Get(ctx context.Context, key KEY) (_ interface{}, _ bool, err er
return key < t.data[j].key
return key < t.data[j].key
})
})
switch child := t.data[i].child.(type) {
child := t.data[i].child
t.PDeactivate()
err = child.PActivate(ctx)
if err != nil {
return nil, false, err
}
switch child := child.(type) {
case *BTree:
case *BTree:
t.PDeactivate()
t = child
t = child
err = t.PActivate(ctx)
if err != nil {
return nil, false, err
}
case *Bucket:
case *Bucket:
t.PDeactivate()
v, ok, err := child.Get(ctx, key)
return child.Get(ctx, key)
child.PDeactivate()
return v, ok, err
}
}
}
}
}
}
...
@@ -547,7 +550,7 @@ func (bt *btreeState) PySetState(pystate interface{}) (err error) {
...
@@ -547,7 +550,7 @@ func (bt *btreeState) PySetState(pystate interface{}) (err error) {
fmt.Errorf("data: [%d]: children must be of the same type", i)
fmt.Errorf("data: [%d]: children must be of the same type", i)
}
}
bt.data = append(bt.data, Entry{key: kkey, child: child})
bt.data = append(bt.data, Entry{key: kkey, child: child
.(zodb.IPersistent)
})
}
}
return nil
return nil
...
...
go/zodb/btree/ziobtree.go
View file @
d0a62510
...
@@ -63,7 +63,7 @@ type IOBTree struct {
...
@@ -63,7 +63,7 @@ type IOBTree struct {
// Key limits child's keys - see IOBTree.Entryv for details.
// Key limits child's keys - see IOBTree.Entryv for details.
type
IOEntry
struct
{
type
IOEntry
struct
{
key
int32
key
int32
child
interface
{}
// IOBTree or IOBucket
child
zodb
.
IPersistent
// IOBTree or IOBucket
}
}
// IOBucket is a leaf node of a B⁺ tree.
// IOBucket is a leaf node of a B⁺ tree.
...
@@ -101,7 +101,7 @@ type IOBucketEntry struct {
...
@@ -101,7 +101,7 @@ type IOBucketEntry struct {
func
(
e
*
IOEntry
)
Key
()
int32
{
return
e
.
key
}
func
(
e
*
IOEntry
)
Key
()
int32
{
return
e
.
key
}
// Child returns IOBTree entry child.
// Child returns IOBTree entry child.
func
(
e
*
IOEntry
)
Child
()
interface
{}
{
return
e
.
child
}
func
(
e
*
IOEntry
)
Child
()
zodb
.
IPersistent
{
return
e
.
child
}
// Entryv returns entries of a IOBTree node.
// Entryv returns entries of a IOBTree node.
//
//
...
@@ -177,18 +177,21 @@ func (t *IOBTree) Get(ctx context.Context, key int32) (_ interface{}, _ bool, er
...
@@ -177,18 +177,21 @@ func (t *IOBTree) Get(ctx context.Context, key int32) (_ interface{}, _ bool, er
return
key
<
t
.
data
[
j
]
.
key
return
key
<
t
.
data
[
j
]
.
key
})
})
switch
child
:=
t
.
data
[
i
]
.
child
.
(
type
)
{
child
:=
t
.
data
[
i
]
.
child
t
.
PDeactivate
()
err
=
child
.
PActivate
(
ctx
)
if
err
!=
nil
{
return
nil
,
false
,
err
}
switch
child
:=
child
.
(
type
)
{
case
*
IOBTree
:
case
*
IOBTree
:
t
.
PDeactivate
()
t
=
child
t
=
child
err
=
t
.
PActivate
(
ctx
)
if
err
!=
nil
{
return
nil
,
false
,
err
}
case
*
IOBucket
:
case
*
IOBucket
:
t
.
PDeactivate
()
v
,
ok
,
err
:=
child
.
Get
(
ctx
,
key
)
return
child
.
Get
(
ctx
,
key
)
child
.
PDeactivate
()
return
v
,
ok
,
err
}
}
}
}
}
}
...
@@ -549,7 +552,7 @@ func (bt *iobtreeState) PySetState(pystate interface{}) (err error) {
...
@@ -549,7 +552,7 @@ func (bt *iobtreeState) PySetState(pystate interface{}) (err error) {
fmt
.
Errorf
(
"data: [%d]: children must be of the same type"
,
i
)
fmt
.
Errorf
(
"data: [%d]: children must be of the same type"
,
i
)
}
}
bt
.
data
=
append
(
bt
.
data
,
IOEntry
{
key
:
kkey
,
child
:
child
})
bt
.
data
=
append
(
bt
.
data
,
IOEntry
{
key
:
kkey
,
child
:
child
.
(
zodb
.
IPersistent
)
})
}
}
return
nil
return
nil
...
...
go/zodb/btree/zlobtree.go
View file @
d0a62510
...
@@ -63,7 +63,7 @@ type LOBTree struct {
...
@@ -63,7 +63,7 @@ type LOBTree struct {
// Key limits child's keys - see LOBTree.Entryv for details.
// Key limits child's keys - see LOBTree.Entryv for details.
type
LOEntry
struct
{
type
LOEntry
struct
{
key
int64
key
int64
child
interface
{}
// LOBTree or LOBucket
child
zodb
.
IPersistent
// LOBTree or LOBucket
}
}
// LOBucket is a leaf node of a B⁺ tree.
// LOBucket is a leaf node of a B⁺ tree.
...
@@ -101,7 +101,7 @@ type LOBucketEntry struct {
...
@@ -101,7 +101,7 @@ type LOBucketEntry struct {
func
(
e
*
LOEntry
)
Key
()
int64
{
return
e
.
key
}
func
(
e
*
LOEntry
)
Key
()
int64
{
return
e
.
key
}
// Child returns LOBTree entry child.
// Child returns LOBTree entry child.
func
(
e
*
LOEntry
)
Child
()
interface
{}
{
return
e
.
child
}
func
(
e
*
LOEntry
)
Child
()
zodb
.
IPersistent
{
return
e
.
child
}
// Entryv returns entries of a LOBTree node.
// Entryv returns entries of a LOBTree node.
//
//
...
@@ -177,18 +177,21 @@ func (t *LOBTree) Get(ctx context.Context, key int64) (_ interface{}, _ bool, er
...
@@ -177,18 +177,21 @@ func (t *LOBTree) Get(ctx context.Context, key int64) (_ interface{}, _ bool, er
return
key
<
t
.
data
[
j
]
.
key
return
key
<
t
.
data
[
j
]
.
key
})
})
switch
child
:=
t
.
data
[
i
]
.
child
.
(
type
)
{
child
:=
t
.
data
[
i
]
.
child
t
.
PDeactivate
()
err
=
child
.
PActivate
(
ctx
)
if
err
!=
nil
{
return
nil
,
false
,
err
}
switch
child
:=
child
.
(
type
)
{
case
*
LOBTree
:
case
*
LOBTree
:
t
.
PDeactivate
()
t
=
child
t
=
child
err
=
t
.
PActivate
(
ctx
)
if
err
!=
nil
{
return
nil
,
false
,
err
}
case
*
LOBucket
:
case
*
LOBucket
:
t
.
PDeactivate
()
v
,
ok
,
err
:=
child
.
Get
(
ctx
,
key
)
return
child
.
Get
(
ctx
,
key
)
child
.
PDeactivate
()
return
v
,
ok
,
err
}
}
}
}
}
}
...
@@ -549,7 +552,7 @@ func (bt *lobtreeState) PySetState(pystate interface{}) (err error) {
...
@@ -549,7 +552,7 @@ func (bt *lobtreeState) PySetState(pystate interface{}) (err error) {
fmt
.
Errorf
(
"data: [%d]: children must be of the same type"
,
i
)
fmt
.
Errorf
(
"data: [%d]: children must be of the same type"
,
i
)
}
}
bt
.
data
=
append
(
bt
.
data
,
LOEntry
{
key
:
kkey
,
child
:
child
})
bt
.
data
=
append
(
bt
.
data
,
LOEntry
{
key
:
kkey
,
child
:
child
.
(
zodb
.
IPersistent
)
})
}
}
return
nil
return
nil
...
...
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