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
c3964151
Commit
c3964151
authored
Jan 23, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
8f53b1a6
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
27 additions
and
14 deletions
+27
-14
go/internal/xtesting/xtesting.go
go/internal/xtesting/xtesting.go
+2
-2
go/zodb/btree/btree.go.in
go/zodb/btree/btree.go.in
+1
-1
go/zodb/btree/ziobtree.go
go/zodb/btree/ziobtree.go
+1
-1
go/zodb/btree/zlobtree.go
go/zodb/btree/zlobtree.go
+1
-1
go/zodb/import_x_test.go
go/zodb/import_x_test.go
+7
-2
go/zodb/persistent.go
go/zodb/persistent.go
+9
-4
go/zodb/persistent_api.go
go/zodb/persistent_api.go
+3
-2
go/zodb/zodbpy.go
go/zodb/zodbpy.go
+3
-1
No files found.
go/internal/xtesting/xtesting.go
View file @
c3964151
...
@@ -90,7 +90,7 @@ func NeedPy(t testing.TB, modules ...string) {
...
@@ -90,7 +90,7 @@ func NeedPy(t testing.TB, modules ...string) {
// ZRawObject represents raw ZODB object state.
// ZRawObject represents raw ZODB object state.
type
ZRawObject
struct
{
type
ZRawObject
struct
{
Oid
zodb
.
Oid
Oid
zodb
.
Oid
Data
string
// raw serialized zodb data
Data
[]
byte
// raw serialized zodb data
}
}
// ZPyCommitRaw commits new transaction into database @ zurl with raw data specified by objv.
// ZPyCommitRaw commits new transaction into database @ zurl with raw data specified by objv.
...
@@ -106,7 +106,7 @@ func ZPyCommitRaw(zurl string, at zodb.Tid, objv ...ZRawObject) (_ zodb.Tid, err
...
@@ -106,7 +106,7 @@ func ZPyCommitRaw(zurl string, at zodb.Tid, objv ...ZRawObject) (_ zodb.Tid, err
fmt
.
Fprintf
(
zin
,
"extension %q
\n
"
,
""
)
fmt
.
Fprintf
(
zin
,
"extension %q
\n
"
,
""
)
for
_
,
obj
:=
range
objv
{
for
_
,
obj
:=
range
objv
{
fmt
.
Fprintf
(
zin
,
"obj %s %d null:00
\n
"
,
obj
.
Oid
,
len
(
obj
.
Data
))
fmt
.
Fprintf
(
zin
,
"obj %s %d null:00
\n
"
,
obj
.
Oid
,
len
(
obj
.
Data
))
zin
.
Write
String
(
obj
.
Data
)
zin
.
Write
(
obj
.
Data
)
zin
.
WriteString
(
"
\n
"
)
zin
.
WriteString
(
"
\n
"
)
}
}
zin
.
WriteString
(
"
\n
"
)
zin
.
WriteString
(
"
\n
"
)
...
...
go/zodb/btree/btree.go.in
View file @
c3964151
...
@@ -467,7 +467,7 @@ func (bt *btreeState) PyGetState() interface{} {
...
@@ -467,7 +467,7 @@ func (bt *btreeState) PyGetState() interface{} {
// btree with 1 child bucket without oid
// btree with 1 child bucket without oid
if len(bt.data) == 1 {
if len(bt.data) == 1 {
bucket, ok := bt.data[0].child.(*Bucket)
bucket, ok := bt.data[0].child.(*Bucket)
if ok && bucket.POid() == zodb.InvalidOid {
// XXX recheck vs "NULL oid"
if ok && bucket.POid() == zodb.InvalidOid {
return pickle.Tuple{pickle.Tuple{((*bucketState)(bucket)).PyGetState()}}
return pickle.Tuple{pickle.Tuple{((*bucketState)(bucket)).PyGetState()}}
}
}
}
}
...
...
go/zodb/btree/ziobtree.go
View file @
c3964151
...
@@ -469,7 +469,7 @@ func (bt *iobtreeState) PyGetState() interface{} {
...
@@ -469,7 +469,7 @@ func (bt *iobtreeState) PyGetState() interface{} {
// btree with 1 child bucket without oid
// btree with 1 child bucket without oid
if
len
(
bt
.
data
)
==
1
{
if
len
(
bt
.
data
)
==
1
{
bucket
,
ok
:=
bt
.
data
[
0
]
.
child
.
(
*
IOBucket
)
bucket
,
ok
:=
bt
.
data
[
0
]
.
child
.
(
*
IOBucket
)
if
ok
&&
bucket
.
POid
()
==
zodb
.
InvalidOid
{
// XXX recheck vs "NULL oid"
if
ok
&&
bucket
.
POid
()
==
zodb
.
InvalidOid
{
return
pickle
.
Tuple
{
pickle
.
Tuple
{((
*
iobucketState
)(
bucket
))
.
PyGetState
()}}
return
pickle
.
Tuple
{
pickle
.
Tuple
{((
*
iobucketState
)(
bucket
))
.
PyGetState
()}}
}
}
}
}
...
...
go/zodb/btree/zlobtree.go
View file @
c3964151
...
@@ -469,7 +469,7 @@ func (bt *lobtreeState) PyGetState() interface{} {
...
@@ -469,7 +469,7 @@ func (bt *lobtreeState) PyGetState() interface{} {
// btree with 1 child bucket without oid
// btree with 1 child bucket without oid
if
len
(
bt
.
data
)
==
1
{
if
len
(
bt
.
data
)
==
1
{
bucket
,
ok
:=
bt
.
data
[
0
]
.
child
.
(
*
LOBucket
)
bucket
,
ok
:=
bt
.
data
[
0
]
.
child
.
(
*
LOBucket
)
if
ok
&&
bucket
.
POid
()
==
zodb
.
InvalidOid
{
// XXX recheck vs "NULL oid"
if
ok
&&
bucket
.
POid
()
==
zodb
.
InvalidOid
{
return
pickle
.
Tuple
{
pickle
.
Tuple
{((
*
lobucketState
)(
bucket
))
.
PyGetState
()}}
return
pickle
.
Tuple
{
pickle
.
Tuple
{((
*
lobucketState
)(
bucket
))
.
PyGetState
()}}
}
}
}
}
...
...
go/zodb/import_x_test.go
View file @
c3964151
...
@@ -27,18 +27,23 @@ import (
...
@@ -27,18 +27,23 @@ import (
_
"lab.nexedi.com/kirr/neo/go/zodb/wks"
_
"lab.nexedi.com/kirr/neo/go/zodb/wks"
)
)
// import at runtime few things into zodb, that zodb cannot import itself due to cyclic dependency.
// import at runtime few things into zodb tests, that zodb cannot import itself
// due to cyclic dependency.
func
init
()
{
func
init
()
{
zodb
.
ZPyCommit
=
ZPyCommit
zodb
.
ZPyCommit
=
ZPyCommit
}
}
// ZPyCommit commits new transaction with specified objects.
//
// The objects need to be alive, but do not need to be marked as changed.
// The commit is performed via zodb/py.
func
ZPyCommit
(
zurl
string
,
at
zodb
.
Tid
,
objv
...
zodb
.
IPersistent
)
(
zodb
.
Tid
,
error
)
{
func
ZPyCommit
(
zurl
string
,
at
zodb
.
Tid
,
objv
...
zodb
.
IPersistent
)
(
zodb
.
Tid
,
error
)
{
var
rawobjv
[]
xtesting
.
ZRawObject
// raw zodb objects data to commit
var
rawobjv
[]
xtesting
.
ZRawObject
// raw zodb objects data to commit
for
_
,
obj
:=
range
objv
{
for
_
,
obj
:=
range
objv
{
rawobj
:=
xtesting
.
ZRawObject
{
rawobj
:=
xtesting
.
ZRawObject
{
Oid
:
obj
.
POid
(),
Oid
:
obj
.
POid
(),
Data
:
string
(
zodb
.
PSerialize
(
obj
)
.
XData
()),
Data
:
zodb
.
PSerialize
(
obj
)
.
XData
(),
// not releasing buf, but its ok
}
}
rawobjv
=
append
(
rawobjv
,
rawobj
)
rawobjv
=
append
(
rawobjv
,
rawobj
)
}
}
...
...
go/zodb/persistent.go
View file @
c3964151
...
@@ -116,8 +116,10 @@ type Stateful interface {
...
@@ -116,8 +116,10 @@ type Stateful interface {
// GetState should return state of the in-RAM object as raw data.
// GetState should return state of the in-RAM object as raw data.
//
//
// XXX called only when state is not dropped.
// GetState is called only by persistent machinery and only when object
// XXX buf ownership.
// has its state - in other words only on non-ghost objects.
//
// XXX buf ownership?
GetState
()
*
mem
.
Buf
GetState
()
*
mem
.
Buf
}
}
...
@@ -125,8 +127,11 @@ type Stateful interface {
...
@@ -125,8 +127,11 @@ type Stateful interface {
// pSerialize implements IPersistent.
// pSerialize implements IPersistent.
func
(
obj
*
Persistent
)
pSerialize
()
*
mem
.
Buf
{
func
(
obj
*
Persistent
)
pSerialize
()
*
mem
.
Buf
{
// XXX locking
obj
.
mu
.
Lock
()
// XXX panic on state == GHOST
defer
obj
.
mu
.
Unlock
()
if
obj
.
state
==
GHOST
{
panic
(
obj
.
badf
(
"serialize: ghost object"
))
}
switch
istate
:=
obj
.
istate
()
.
(
type
)
{
switch
istate
:=
obj
.
istate
()
.
(
type
)
{
case
Stateful
:
case
Stateful
:
...
...
go/zodb/persistent_api.go
View file @
c3964151
...
@@ -100,14 +100,15 @@ type IPersistent interface {
...
@@ -100,14 +100,15 @@ type IPersistent interface {
// XXX probably don't need this.
// XXX probably don't need this.
//PState() ObjectState // in-RAM object state.
//PState() ObjectState // in-RAM object state.
// XXX move vvv -> iPersistent?
// XXX move vvv -> iPersistent? (-> into persistent.go)
// XXX do we need to put vvv into IPersistent at all?
// pSerialize returns object in serialized form to be saved in the database.
// pSerialize returns object in serialized form to be saved in the database.
//
//
// pSerialize is non-public method that is exposed and used only by ZODB internally.
// pSerialize is non-public method that is exposed and used only by ZODB internally.
// pSerialize is called only on non-ghost objects.
//
//
// XXX more text.
// XXX more text.
// XXX when called? invariants?
pSerialize
()
*
mem
.
Buf
pSerialize
()
*
mem
.
Buf
}
}
...
...
go/zodb/zodbpy.go
View file @
c3964151
...
@@ -40,7 +40,9 @@ type PyStateful interface {
...
@@ -40,7 +40,9 @@ type PyStateful interface {
// PyGetState should return state of the in-RAM object as Python data.
// PyGetState should return state of the in-RAM object as Python data.
// Analog of __getstate__() in Python.
// Analog of __getstate__() in Python.
//
//
// XXX called only when state is not dropped.
// PyGetState is called only by persistent machinery and only when
// object has its state - in other words only on non-ghost objects.
//
// XXX state ownership?
// XXX state ownership?
PyGetState
()
interface
{}
PyGetState
()
interface
{}
}
}
...
...
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