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
302c7fa6
Commit
302c7fa6
authored
Aug 07, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a0db1dd4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
8 deletions
+10
-8
go/zodb/btree/btree.go
go/zodb/btree/btree.go
+9
-8
go/zodb/persistent.go
go/zodb/persistent.go
+1
-0
No files found.
go/zodb/btree/btree.go
View file @
302c7fa6
...
...
@@ -50,8 +50,8 @@ type Bucket struct {
values
[]
interface
{}
// 'len' corresponding values
}
//
z
BTreeItem mimics BTreeItem from btree/py.
type
z
BTreeItem
struct
{
//
_
BTreeItem mimics BTreeItem from btree/py.
type
_
BTreeItem
struct
{
key
KEY
child
interface
{}
// BTree or Bucket
}
...
...
@@ -72,14 +72,15 @@ type BTree struct {
// array. There are len-1 keys in the 'key' fields, stored in increasing
// order. data[0].key is unused. For i in 0 .. len-1, all keys reachable
// from data[i].child are >= data[i].key and < data[i+1].key, at the
// endpoints pretending that data[0].key is minus infinity and
// data[len].key is positive infinity.
data
[]
zBTreeItem
// endpoints pretending that data[0].key is -∞ and data[len].key is +∞.
data
[]
_BTreeItem
}
// Get searches BTree by key.
//
// It loads intermediate BTree nodes from database on demand as needed.
//
// t need not be activated beforehand for Get to work.
func
(
t
*
BTree
)
Get
(
ctx
context
.
Context
,
key
KEY
)
(
_
interface
{},
_
bool
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"btree(%s): get %v"
,
t
.
POid
(),
key
)
// XXX + url?
err
=
t
.
PActivate
(
ctx
)
...
...
@@ -293,7 +294,7 @@ func (bt *btreeState) PySetState(pystate interface{}) (err error) {
}
bt
.
firstbucket
=
bucket
bt
.
data
=
[]
z
BTreeItem
{{
key
:
0
,
child
:
bucket
}}
bt
.
data
=
[]
_
BTreeItem
{{
key
:
0
,
child
:
bucket
}}
return
nil
}
...
...
@@ -312,7 +313,7 @@ func (bt *btreeState) PySetState(pystate interface{}) (err error) {
}
n
:=
(
len
(
t
)
+
1
)
/
2
bt
.
data
=
make
([]
z
BTreeItem
,
0
,
n
)
bt
.
data
=
make
([]
_
BTreeItem
,
0
,
n
)
for
i
,
idx
:=
0
,
0
;
i
<
n
;
i
++
{
key
:=
int64
(
0
)
if
i
>
0
{
...
...
@@ -334,7 +335,7 @@ func (bt *btreeState) PySetState(pystate interface{}) (err error) {
case
*
Bucket
:
// ok
}
bt
.
data
=
append
(
bt
.
data
,
z
BTreeItem
{
key
:
KEY
(
key
),
child
:
child
})
bt
.
data
=
append
(
bt
.
data
,
_
BTreeItem
{
key
:
KEY
(
key
),
child
:
child
})
}
return
nil
...
...
go/zodb/persistent.go
View file @
302c7fa6
...
...
@@ -231,6 +231,7 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) {
// do the loading outside of obj lock
state
,
serial
,
err
:=
obj
.
jar
.
load
(
ctx
,
obj
.
oid
)
xerr
.
Contextf
(
&
err
,
"%s(%s): load"
,
obj
.
zclass
.
class
,
obj
.
oid
)
// relock the object
obj
.
mu
.
Lock
()
...
...
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