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
Hide 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 {
...
@@ -50,8 +50,8 @@ type Bucket struct {
values
[]
interface
{}
// 'len' corresponding values
values
[]
interface
{}
// 'len' corresponding values
}
}
//
z
BTreeItem mimics BTreeItem from btree/py.
//
_
BTreeItem mimics BTreeItem from btree/py.
type
z
BTreeItem
struct
{
type
_
BTreeItem
struct
{
key
KEY
key
KEY
child
interface
{}
// BTree or Bucket
child
interface
{}
// BTree or Bucket
}
}
...
@@ -72,14 +72,15 @@ type BTree struct {
...
@@ -72,14 +72,15 @@ type BTree struct {
// array. There are len-1 keys in the 'key' fields, stored in increasing
// 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
// 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
// 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
// endpoints pretending that data[0].key is -∞ and data[len].key is +∞.
// data[len].key is positive infinity.
data
[]
_BTreeItem
data
[]
zBTreeItem
}
}
// Get searches BTree by key.
// Get searches BTree by key.
//
//
// It loads intermediate BTree nodes from database on demand as needed.
// 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
)
{
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?
defer
xerr
.
Contextf
(
&
err
,
"btree(%s): get %v"
,
t
.
POid
(),
key
)
// XXX + url?
err
=
t
.
PActivate
(
ctx
)
err
=
t
.
PActivate
(
ctx
)
...
@@ -293,7 +294,7 @@ func (bt *btreeState) PySetState(pystate interface{}) (err error) {
...
@@ -293,7 +294,7 @@ func (bt *btreeState) PySetState(pystate interface{}) (err error) {
}
}
bt
.
firstbucket
=
bucket
bt
.
firstbucket
=
bucket
bt
.
data
=
[]
z
BTreeItem
{{
key
:
0
,
child
:
bucket
}}
bt
.
data
=
[]
_
BTreeItem
{{
key
:
0
,
child
:
bucket
}}
return
nil
return
nil
}
}
...
@@ -312,7 +313,7 @@ func (bt *btreeState) PySetState(pystate interface{}) (err error) {
...
@@ -312,7 +313,7 @@ func (bt *btreeState) PySetState(pystate interface{}) (err error) {
}
}
n
:=
(
len
(
t
)
+
1
)
/
2
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
++
{
for
i
,
idx
:=
0
,
0
;
i
<
n
;
i
++
{
key
:=
int64
(
0
)
key
:=
int64
(
0
)
if
i
>
0
{
if
i
>
0
{
...
@@ -334,7 +335,7 @@ func (bt *btreeState) PySetState(pystate interface{}) (err error) {
...
@@ -334,7 +335,7 @@ func (bt *btreeState) PySetState(pystate interface{}) (err error) {
case
*
Bucket
:
// ok
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
return
nil
...
...
go/zodb/persistent.go
View file @
302c7fa6
...
@@ -231,6 +231,7 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) {
...
@@ -231,6 +231,7 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) {
// do the loading outside of obj lock
// do the loading outside of obj lock
state
,
serial
,
err
:=
obj
.
jar
.
load
(
ctx
,
obj
.
oid
)
state
,
serial
,
err
:=
obj
.
jar
.
load
(
ctx
,
obj
.
oid
)
xerr
.
Contextf
(
&
err
,
"%s(%s): load"
,
obj
.
zclass
.
class
,
obj
.
oid
)
// relock the object
// relock the object
obj
.
mu
.
Lock
()
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