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
68e94d09
Commit
68e94d09
authored
Oct 31, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X zodb: Polish a bit
parent
5540b6ad
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
37 additions
and
69 deletions
+37
-69
go/neo/t/neotest
go/neo/t/neotest
+0
-1
go/zodb/py/pydata-gen-testdata
go/zodb/py/pydata-gen-testdata
+2
-15
go/zodb/pydata.go
go/zodb/pydata.go
+0
-0
go/zodb/pydata_test.go
go/zodb/pydata_test.go
+1
-1
go/zodb/storage/fs1/py/gen-testdata
go/zodb/storage/fs1/py/gen-testdata
+1
-14
go/zodb/str.go
go/zodb/str.go
+7
-18
go/zodb/time.go
go/zodb/time.go
+0
-1
go/zodb/time_test.go
go/zodb/time_test.go
+0
-1
go/zodb/zodb.go
go/zodb/zodb.go
+14
-11
go/zodb/zodbtools/catobj.go
go/zodb/zodbtools/catobj.go
+3
-2
go/zodb/zodbtools/dump.go
go/zodb/zodbtools/dump.go
+1
-1
go/zodb/zodbtools/dump_test.go
go/zodb/zodbtools/dump_test.go
+1
-1
go/zodb/zodbtools/help.go
go/zodb/zodbtools/help.go
+6
-2
go/zodb/ztestdata_pydata_test.go
go/zodb/ztestdata_pydata_test.go
+1
-1
No files found.
go/neo/t/neotest
View file @
68e94d09
...
...
@@ -88,7 +88,6 @@ EOF
.
env.sh
pip
install
git+https://lab.nexedi.com/nexedi/wendelin.core.git@master
# XXX does not show git in ver
pip
install
git+https://lab.nexedi.com/kirr/zodburi.git@master
pip
install
zodbtools
mkdir
-p
src/lab.nexedi.com/kirr
...
...
go/zodb/py/py
serialize
-gen-testdata
→
go/zodb/py/py
data
-gen-testdata
View file @
68e94d09
...
...
@@ -22,24 +22,11 @@
from
ZODB.tests
import
testSerialize
from
ZODB
import
serialize
# escape string into valid "..." string
# XXX dup in fs1/py/pyserialize-gen-testdata
def
escapeqq
(
s
):
outv
=
[]
# we don't want ' to be escaped
for
_
in
s
.
split
(
"'"
):
# this escape almost everything except " character
# NOTE string_escape does not do smartquotes and always uses ' for quoting
# (repr(str) is the same except it does smartquoting picking ' or " automatically)
q
=
_
.
encode
(
"string_escape"
)
q
=
q
.
replace
(
'"'
,
r'\"'
)
outv
.
append
(
q
)
return
'"'
+
"'"
.
join
(
outv
)
+
'"'
from
zodbtools.util
import
escapeqq
def
main
():
# dump to go what to expect
with
open
(
"ztestdata_py
serialize
_test.go"
,
"w"
)
as
f
:
with
open
(
"ztestdata_py
data
_test.go"
,
"w"
)
as
f
:
def
emit
(
v
):
print
>>
f
,
v
emit
(
"// Code generated by %s; DO NOT EDIT."
%
__file__
)
...
...
go/zodb/py
serialize
.go
→
go/zodb/py
data
.go
View file @
68e94d09
File moved
go/zodb/py
serialize
_test.go
→
go/zodb/py
data
_test.go
View file @
68e94d09
...
...
@@ -19,7 +19,7 @@
package
zodb
//go:generate ./py/py
serialize
-gen-testdata
//go:generate ./py/py
data
-gen-testdata
import
(
"testing"
...
...
go/zodb/storage/fs1/py/gen-testdata
View file @
68e94d09
...
...
@@ -28,6 +28,7 @@ from ZODB import DB
from
ZODB.POSException
import
UndoError
from
persistent
import
Persistent
import
transaction
from
zodbtools.util
import
escapeqq
import
struct
import
time
...
...
@@ -44,20 +45,6 @@ def unpack64(packed):
def
hex64
(
packed
):
return
'0x%016x'
%
unpack64
(
packed
)
# escape string into valid "..." string
# XXX dup in zodb/py/pyserialize-gen-testdata
def
escapeqq
(
s
):
outv
=
[]
# we don't want ' to be escaped
for
_
in
s
.
split
(
"'"
):
# this escape almost everything except " character
# NOTE string_escape does not do smartquotes and always uses ' for quoting
# (repr(str) is the same except it does smartquoting picking ' or " automatically)
q
=
_
.
encode
(
"string_escape"
)
q
=
q
.
replace
(
'"'
,
r'\"'
)
outv
.
append
(
q
)
return
'"'
+
"'"
.
join
(
outv
)
+
'"'
# make time.time() predictable
_xtime
=
time
.
mktime
(
time
.
strptime
(
"04 Jan 1979"
,
"%d %b %Y"
))
def
xtime
():
...
...
go/zodb/str.go
View file @
68e94d09
...
...
@@ -30,22 +30,20 @@ import (
)
func
(
tid
Tid
)
String
()
string
{
// XXX also print "tid:" prefix ?
//return fmt.Sprintf("%016x", uint64(tid))
return
string
(
tid
.
XFmtString
(
nil
))
}
func
(
oid
Oid
)
String
()
string
{
// XXX also print "oid:" prefix ?
//return fmt.Sprintf("%016x", uint64(oid))
return
string
(
oid
.
XFmtString
(
nil
))
}
func
(
tid
Tid
)
XFmtString
(
b
[]
byte
)
[]
byte
{
// XXX also print "tid:" prefix ?
return
xfmt
.
AppendHex016
(
b
,
uint64
(
tid
))
}
func
(
oid
Oid
)
XFmtString
(
b
[]
byte
)
[]
byte
{
// XXX also print "oid:" prefix ?
return
xfmt
.
AppendHex016
(
b
,
uint64
(
oid
))
}
...
...
@@ -79,9 +77,9 @@ func (xid Xid) XFmtString(b xfmt.Buffer) xfmt.Buffer {
*/
// parseHex64 decode 16-character-wide hex-encoded string into uint64
// XXX -> xfmt ?
// parseHex64 decodes 16-character-wide hex-encoded string into uint64
func
parseHex64
(
subj
,
s
string
)
(
uint64
,
error
)
{
// XXX -> xfmt ?
// XXX like scanf("%016x") but scanf implicitly skips spaces without giving control to caller and is slower
var
b
[
8
]
byte
if
len
(
s
)
!=
16
{
...
...
@@ -154,9 +152,10 @@ Error:
return
Xid
{},
fmt
.
Errorf
(
"xid %q invalid"
,
s
)
}
// ParseTidRange parses string of form "<tidmin>..<tidmax>" into tidMin, tidMax pair
// ParseTidRange parses string of form "<tidmin>..<tidmax>" into tidMin, tidMax pair.
//
// Both <tidmin> and <tidmax> can be empty, in which case defaults 0 and TidMax are used.
//
// both <tidmin> and <tidmax> can be empty, in which case defaults 0 and TidMax are returned
// XXX also check tidMin < tidMax here? or allow reverse ranges ?
func
ParseTidRange
(
s
string
)
(
tidMin
,
tidMax
Tid
,
err
error
)
{
s1
,
s2
,
err
:=
xstrings
.
Split2
(
s
,
".."
)
...
...
@@ -186,13 +185,3 @@ func ParseTidRange(s string) (tidMin, tidMax Tid, err error) {
Error
:
return
0
,
0
,
fmt
.
Errorf
(
"tid range %q invalid"
,
s
)
}
/*
func (tid Tid) String2() string {
var b [8+16]byte
binary.BigEndian.PutUint64(b[:], uint64(tid))
hex.Encode(b[8:], b[:8])
//return mem.String(b[:8])
return string(b[:8])
}
*/
go/zodb/time.go
View file @
68e94d09
...
...
@@ -41,7 +41,6 @@ func (t TimeStamp) XFmtString(b []byte) []byte {
}
// Time converts tid to time
func
(
tid
Tid
)
Time
()
TimeStamp
{
// the same as _parseRaw in TimeStamp/py
...
...
go/zodb/time_test.go
View file @
68e94d09
...
...
@@ -18,7 +18,6 @@
// See https://www.nexedi.com/licensing for rationale and options.
package
zodb
// TODO what it is
import
"testing"
...
...
go/zodb/zodb.go
View file @
68e94d09
...
...
@@ -36,10 +36,13 @@ import (
//
// In ZODB transaction identifiers are unique 64-bit integer connected to time
// when corresponding transaction was created.
//
// See also: XTid.
type
Tid
uint64
// ZODB/py defines maxtid to be max signed int64 since baee84a6 (Jun 7 2016)
// (XXX in neo: SQLite does not accept numbers above 2^63-1)
// ZODB/py defines maxtid to be max signed int64 since Jun 7 2016:
// https://github.com/zopefoundation/ZODB/commit/baee84a6
// (XXX in neo/py: SQLite does not accept numbers above 2^63-1)
const
TidMax
Tid
=
1
<<
63
-
1
// 0x7fffffffffffffff
...
...
@@ -54,14 +57,14 @@ const TidMax Tid = 1<<63 - 1 // 0x7fffffffffffffff
type
Oid
uint64
// TxnInfo is metadata information about one transaction.
//
// XXX naming -> TxnMeta?
// XXX +TxnInfo = TxnMeta + []DataInfo ?
type
TxnInfo
struct
{
Tid
Tid
Status
TxnStatus
User
[]
byte
Description
[]
byte
// additional information about transaction. ZODB/py usually puts py
// dict here but it can be arbitrary raw bytes.
Extension
[]
byte
}
...
...
@@ -130,7 +133,7 @@ func (e *ErrXidMissing) Error() string {
// IStorage is the interface provided by ZODB storages
type
IStorage
interface
{
//
XXX
add invalidation channel
//
TODO
add invalidation channel
// StorageName returns storage name
StorageName
()
string
...
...
@@ -138,11 +141,9 @@ type IStorage interface {
// Close closes storage
Close
()
error
// History(ctx, oid, size=1)
// LastTid returns the id of the last committed transaction.
//
//
if no transactions have been committed yet, LastTid returns Tid zero value
//
If no transactions have been committed yet, LastTid returns Tid zero value.
LastTid
(
ctx
context
.
Context
)
(
Tid
,
error
)
// LastOid returns highest object id of objects committed to storage.
...
...
@@ -169,11 +170,14 @@ type IStorage interface {
// XXX Restore ?
// CheckCurrentSerialInTransaction(oid Oid, serial Tid, txn ITransaction) // XXX naming
// TODO:
// tpc_begin(txn)
// tpc_vote(txn)
// tpc_finish(txn, callback) XXX clarify about callback
// tpc_abort(txn)
// TODO: History(ctx, oid, size=1)
// Iterate creates iterator to iterate storage in [tidMin, tidMax] range.
//
// XXX allow iteration both ways (forward & backward)
...
...
@@ -202,8 +206,7 @@ type IDataIterator interface {
// Valid returns whether tid is in valid transaction identifiers range
func
(
tid
Tid
)
Valid
()
bool
{
// XXX if Tid becomes signed also check wrt 0
if
tid
<=
TidMax
{
if
0
<=
tid
&&
tid
<=
TidMax
{
return
true
}
else
{
return
false
...
...
go/zodb/zodbtools/catobj.go
View file @
68e94d09
...
...
@@ -32,7 +32,8 @@ import (
)
// Catobj dumps content of one ZODB object
// Catobj dumps content of one ZODB object.
//
// The object is printed in raw form without any headers (see Dumpobj)
func
Catobj
(
ctx
context
.
Context
,
w
io
.
Writer
,
stor
zodb
.
IStorage
,
xid
zodb
.
Xid
)
error
{
buf
,
_
,
err
:=
stor
.
Load
(
ctx
,
xid
)
...
...
@@ -111,7 +112,7 @@ func catobjMain(argv []string) {
for
_
,
arg
:=
range
argv
[
1
:
]
{
xid
,
err
:=
zodb
.
ParseXid
(
arg
)
if
err
!=
nil
{
prog
.
Fatal
(
err
)
// XXX recheck
prog
.
Fatal
(
err
)
}
xidv
=
append
(
xidv
,
xid
)
...
...
go/zodb/zodbtools/dump.go
View file @
68e94d09
...
...
@@ -244,7 +244,7 @@ func dumpMain(argv []string) {
tidMin
,
tidMax
,
err
:=
zodb
.
ParseTidRange
(
tidRange
)
if
err
!=
nil
{
prog
.
Fatal
(
err
)
// XXX recheck
prog
.
Fatal
(
err
)
}
stor
,
err
:=
zodb
.
OpenStorageURL
(
context
.
Background
(),
storUrl
)
// TODO read-only
...
...
go/zodb/zodbtools/dump_test.go
View file @
68e94d09
...
...
@@ -45,7 +45,7 @@ func diff(a, b string) string {
}
// loadZdumpPy loads a zdump file and normalizes escaped strings to the way go
// would escape them
// would escape them
.
func
loadZdumpPy
(
t
*
testing
.
T
,
path
string
)
string
{
dump
,
err
:=
ioutil
.
ReadFile
(
path
)
if
err
!=
nil
{
...
...
go/zodb/zodbtools/help.go
View file @
68e94d09
...
...
@@ -58,8 +58,12 @@ const helpXid =
`
// TODO dump format
const
helpZDump
=
`TODO describe zodb dump format
`
var
helpTopics
=
prog
.
HelpRegistry
{
{
"zurl"
,
"specifying database URL"
,
helpZURL
},
{
"xid"
,
"specifying object address"
,
helpXid
},
{
"zurl"
,
"specifying database URL"
,
helpZURL
},
{
"xid"
,
"specifying object address"
,
helpXid
},
{
"zdump"
,
"description of ZODB dump format"
,
helpZDump
},
}
go/zodb/ztestdata_py
serialize
_test.go
→
go/zodb/ztestdata_py
data
_test.go
View file @
68e94d09
// Code generated by ./py/py
serialize
-gen-testdata; DO NOT EDIT.
// Code generated by ./py/py
data
-gen-testdata; DO NOT EDIT.
package
zodb
var
_PyData_ClassName_Testv
=
[
...
]
_PyDataClassName_TestEntry
{
...
...
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