Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
02828321
Commit
02828321
authored
Jul 31, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
d4ff5502
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
7 deletions
+40
-7
go/zodb/btree/btree.go
go/zodb/btree/btree.go
+1
-1
go/zodb/btree/btree_test.go
go/zodb/btree/btree_test.go
+2
-2
go/zodb/btree/testdata/1.fs
go/zodb/btree/testdata/1.fs
+0
-0
go/zodb/btree/testdata/1.fs.index
go/zodb/btree/testdata/1.fs.index
+0
-0
go/zodb/persistent.go
go/zodb/persistent.go
+29
-2
go/zodb/zodb.go
go/zodb/zodb.go
+8
-2
No files found.
go/zodb/btree/btree.go
View file @
02828321
...
...
@@ -267,7 +267,7 @@ func (bt *btreeState) PySetState(pystate interface{}) error {
// btree with 1 child bucket without oid
if
len
(
t
)
==
1
{
bucket
:=
&
Bucket
{
/* FIXME */
}
bucket
:=
zodb
.
NewPersistent
(
reflect
.
TypeOf
(
Bucket
{}),
bt
.
PJar
())
.
(
*
Bucket
)
err
:=
(
*
bucketState
)(
bucket
)
.
PySetState
(
t
[
0
])
if
err
!=
nil
{
// XXX
...
...
go/zodb/btree/btree_test.go
View file @
02828321
...
...
@@ -107,12 +107,12 @@ func TestBucket(t *testing.T) {
}
if
!
ok
{
t
.
Errorf
(
"
get %v -> ø; want %v"
,
kv
.
key
,
kv
.
value
)
t
.
Errorf
(
"
%s: get %v -> ø; want %v"
,
tt
.
oid
,
kv
.
key
,
kv
.
value
)
continue
}
if
value
!=
kv
.
value
{
t
.
Errorf
(
"
get %v -> %v; want %v"
,
kv
.
key
,
value
,
kv
.
value
)
t
.
Errorf
(
"
%s: get %v -> %v; want %v"
,
tt
.
oid
,
kv
.
key
,
value
,
kv
.
value
)
}
// XXX .next == nil
...
...
go/zodb/btree/testdata/1.fs
View file @
02828321
No preview for this file type
go/zodb/btree/testdata/1.fs.index
View file @
02828321
No preview for this file type
go/zodb/persistent.go
View file @
02828321
...
...
@@ -403,6 +403,21 @@ func RegisterClass(class string, typ, stateType reflect.Type) {
typeTab
[
typ
]
=
zc
}
// NewPersistent creates new instance of persistent type.
//
// typ must embed Persistent and must be registered with RegisterClass.
//
// Created instance will be associated with jar, but will have no oid assigned
// until transaction commit.
func
NewPersistent
(
typ
reflect
.
Type
,
jar
*
Connection
)
IPersistent
{
zc
:=
typeTab
[
typ
]
if
zc
==
nil
{
panic
(
fmt
.
Sprintf
(
"new persistent: type %s not registered"
,
typ
))
}
xpobj
:=
reflect
.
New
(
zc
.
typ
)
return
persistentInit
(
xpobj
,
zc
,
jar
,
InvalidOid
,
InvalidTid
,
UPTODATE
/*XXX ok?*/
)
}
// newGhost creates new ghost object corresponding to class, oid and jar.
//
...
...
@@ -422,13 +437,25 @@ func newGhost(class string, oid Oid, jar *Connection) IPersistent {
xpobj
=
reflect
.
New
(
zc
.
typ
)
}
return
persistentInit
(
xpobj
,
zc
,
jar
,
oid
,
InvalidTid
,
GHOST
)
}
// persistentInit inits Persistent embedded into an object
// and returns .instance .
func
persistentInit
(
xpobj
reflect
.
Value
,
zc
*
zclass
,
jar
*
Connection
,
oid
Oid
,
serial
Tid
,
state
ObjectState
)
IPersistent
{
xobj
:=
xpobj
.
Elem
()
// typ
pbase
:=
xobj
.
FieldByName
(
"Persistent"
)
.
Addr
()
.
Interface
()
.
(
*
Persistent
)
pbase
.
zclass
=
zc
pbase
.
jar
=
jar
pbase
.
oid
=
oid
pbase
.
serial
=
0
pbase
.
state
=
GHOST
pbase
.
serial
=
serial
pbase
.
state
=
state
if
state
>
GHOST
{
// if state is not ghost, init loading state so that activate works.
pbase
.
loading
=
&
loadState
{
ready
:
make
(
chan
struct
{})}
close
(
pbase
.
loading
.
ready
)
}
obj
:=
xpobj
.
Interface
()
pbase
.
instance
=
obj
.
(
IPersistent
)
...
...
go/zodb/zodb.go
View file @
02828321
...
...
@@ -164,14 +164,17 @@ import (
// by all cumulated transaction changes from database beginning up to, and
// including, transaction specified by tid.
//
// 0 is invalid Tid
.
// 0 is invalid Tid
, but canonical invalid Tid value is InvalidTid. XXX ok? (-∞ ?)
type
Tid
uint64
// ZODB/py defines maxtid to be max signed int64 since Jun 7 2016:
// https://github.com/zopefoundation/ZODB/commit/baee84a6
// (same in neo/py with "SQLite does not accept numbers above 2^63-1" comment)
const
TidMax
Tid
=
1
<<
63
-
1
// 0x7fffffffffffffff
const
(
TidMax
Tid
=
1
<<
63
-
1
// 0x7fffffffffffffff
InvalidTid
Tid
=
1
<<
64
-
1
// 0xffffffffffffffff
)
// Oid is object identifier.
//
...
...
@@ -181,10 +184,13 @@ const TidMax Tid = 1<<63 - 1 // 0x7fffffffffffffff
// uniquely addresses corresponding data record.
//
// 0 is valid Oid and represents root database object.
// InvalidOid represents an invalid Oid.
//
// See also: Xid.
type
Oid
uint64
const
InvalidOid
Oid
=
1
<<
64
-
1
// 0xffffffffffffffff
// Xid is "extended" oid - that fully specifies object and query for its revision.
//
// At specifies whole database state at which object identified with Oid should
...
...
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