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
9a51360f
Commit
9a51360f
authored
Aug 10, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
4d6e59f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
9 deletions
+35
-9
go/zodb/btree/btree.go
go/zodb/btree/btree.go
+35
-9
No files found.
go/zodb/btree/btree.go
View file @
9a51360f
...
...
@@ -71,6 +71,16 @@ type BTree struct {
data
[]
Entry
}
// Entry is one BTree node entry.
//
// It contains key and child, who is either BTree or Bucket.
//
// Key limits child's keys - see BTree.Entryv for details.
type
Entry
struct
{
key
KEY
child
interface
{}
// BTree or Bucket
}
// Bucket is a leaf node of a B⁺ tree.
//
// It mimics ?OBucket from btree/py, with ? being any integer.
...
...
@@ -90,23 +100,22 @@ type Bucket struct {
values
[]
interface
{}
// 'len' corresponding values
}
//
Entry is one BTree
node entry.
//
BucketEntry is one Bucket
node entry.
//
// It contains key and child, who is either BTree or Bucket.
//
// Key limits child's keys - see BTree.Entryv for details.
type
Entry
struct
{
// It contains key and value.
type
BucketEntry
struct
{
key
KEY
child
interface
{}
// BTree or Bucket
value
interface
{}
}
// Key returns BTree entry key.
func
(
i
*
Entry
)
Key
()
KEY
{
return
i
.
key
}
func
(
e
*
Entry
)
Key
()
KEY
{
return
e
.
key
}
// Child returns BTree entry child.
func
(
i
*
Entry
)
Child
()
interface
{}
{
return
i
.
child
}
func
(
e
*
Entry
)
Child
()
interface
{}
{
return
e
.
child
}
// Entryv returns entries of BTree node.
// Entryv returns entries of
a
BTree node.
//
// Entries keys limit the keys of all children reachable from an entry:
//
...
...
@@ -123,6 +132,23 @@ func (t *BTree) Entryv() []Entry {
return
t
.
data
}
// Key returns Bucket entry key.
func
(
e
*
BucketEntry
)
Key
()
KEY
{
return
e
.
key
}
// Value returns Bucket entry value.
func
(
e
*
BucketEntry
)
Value
()
interface
{}
{
return
e
.
value
}
// Entryv returns entries of a Bucket node.
//
// XXX
func
(
b
*
Bucket
)
Entryv
()
[]
BucketEntry
{
ev
:=
make
([]
BucketEntry
,
len
(
b
.
keys
))
for
i
,
k
:=
range
b
.
keys
{
ev
[
i
]
=
BucketEntry
{
k
,
b
.
values
[
i
]}
}
return
ev
}
// Get searches BTree by key.
//
...
...
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