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
506e24ef
Commit
506e24ef
authored
Mar 08, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
196d218f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
t/neo/zodb/cmd/zodbdump/zodbdump.go
t/neo/zodb/cmd/zodbdump/zodbdump.go
+32
-0
No files found.
t/neo/zodb/cmd/zodbdump/zodbdump.go
View file @
506e24ef
...
...
@@ -42,8 +42,40 @@ import (
"lab.nexedi.com/kirr/go123/mem"
//"lab.nexedi.com/kirr/go123/xio"
pickle
"githib.com/kisielk/og-rek"
)
// dumpb pickles an object to []byte
func
dumpb
(
obj
interface
{})
[]
byte
{
buf
:=
bytes
.
Buffer
{}
p
:=
pickle
.
NewEncoder
(
&
buf
)
err
:=
p
.
Encode
(
obj
)
}
// normalizeExtPy normalizes extension to the form zodbdump/py would print it.
// specifically the dictionary pickle inside is analyzed and then ... XXX
func
normalizeExtPy
(
ext
[]
byte
)
[]
byte
{
// depickle ext
r
:=
bufio
.
NewBuffer
(
ext
)
p
:=
pickle
.
NewDecoder
(
r
)
xv
,
_
:=
p
.
Decode
()
v
,
ok
:=
xv
.
(
map
[
interface
{}]
interface
{})
// on any error (e.g. ext is not pickle at all) or if it was not dict return original
if
!
ok
{
return
ext
}
keyv
:=
make
([]
*
struct
{
key
interface
{},
kpickle
[]
byte
},
len
(
v
))
for
i
,
key
:=
range
v
{
keyv
[
i
]
.
key
=
key
keyv
[
i
]
.
kpickle
=
dumpb
(
key
)
}
}
// zodbDump dumps contents of a storage in between tidMin..tidMax range to a writer.
// see top-level documentation for the dump format.
func
zodbDump
(
w
io
.
Writer
,
stor
zodb
.
IStorage
,
tidMin
,
tidMax
zodb
.
Tid
,
hashOnly
bool
)
error
{
...
...
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