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
6a52ac1a
Commit
6a52ac1a
authored
Mar 25, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X zodbdump: use xfmt
parent
b750d103
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
19 deletions
+12
-19
t/neo/zodb/cmd/zodbdump/zodbdump.go
t/neo/zodb/cmd/zodbdump/zodbdump.go
+10
-17
t/neo/zodb/str.go
t/neo/zodb/str.go
+2
-2
No files found.
t/neo/zodb/cmd/zodbdump/zodbdump.go
View file @
6a52ac1a
...
...
@@ -38,7 +38,6 @@ import (
"io"
"log"
"os"
"strconv"
"../../../zodb"
"../../../storage/fs1"
...
...
@@ -53,7 +52,7 @@ type dumper struct {
afterFirst
bool
// true after first transaction has been dumped
workMem
[]
byte
// reusable data buffer for formatting
xbuf
xfmt
.
Buffer
// reusable data buffer for formatting
}
var
_LF
=
[]
byte
{
'\n'
}
...
...
@@ -61,41 +60,36 @@ var _LF = []byte{'\n'}
// DumpData dumps one data record
func
(
d
*
dumper
)
DumpData
(
datai
*
zodb
.
StorageRecordInformation
)
error
{
buf
:=
d
.
workMem
[
:
0
]
xbuf
:=
&
d
.
xbuf
xbuf
.
Reset
()
//entry := "obj " + datai.Oid.String() + " "
buf
=
append
(
buf
,
"obj "
...
)
buf
=
xfmt
.
Append
(
buf
,
&
datai
.
Oid
)
buf
=
append
(
buf
,
' '
)
xbuf
.
S
(
"obj "
)
.
V
(
&
datai
.
Oid
)
.
Cb
(
' '
)
writeData
:=
false
switch
{
case
datai
.
Data
==
nil
:
//entry += "delete"
buf
=
append
(
buf
,
"delete"
...
)
xbuf
.
S
(
"delete"
)
case
datai
.
Tid
!=
datai
.
DataTid
:
//entry += "from " + datai.DataTid.String()
buf
=
append
(
buf
,
"from "
...
)
buf
=
xfmt
.
Append
(
buf
,
&
datai
.
DataTid
)
xbuf
.
S
(
"from "
)
.
V
(
&
datai
.
DataTid
)
default
:
//entry += fmt.Sprintf("%d sha1:%x", len(datai.Data), sha1.Sum(datai.Data))
buf
=
strconv
.
AppendInt
(
buf
,
int64
(
len
(
datai
.
Data
)),
10
)
buf
=
append
(
buf
,
" sha1:"
...
)
dataSha1
:=
sha1
.
Sum
(
datai
.
Data
)
buf
=
xfmt
.
AppendHex
(
buf
,
dataSha1
[
:
])
xbuf
.
D
(
len
(
datai
.
Data
))
.
S
(
" sha1:"
)
.
Xb
(
dataSha1
[
:
])
writeData
=
true
}
//entry += "\n"
buf
=
append
(
buf
,
'\n'
)
xbuf
.
Cb
(
'\n'
)
// TODO use writev(data, "\n") via net.Buffers (it is already available)
//_, err := d.W.Write(mem.Bytes(entry))
_
,
err
:=
d
.
W
.
Write
(
buf
)
_
,
err
:=
d
.
W
.
Write
(
xbuf
.
Bytes
())
if
err
!=
nil
{
goto
out
}
...
...
@@ -106,6 +100,7 @@ func (d *dumper) DumpData(datai *zodb.StorageRecordInformation) error {
goto
out
}
// XXX maybe better to merge with next record ?
_
,
err
=
d
.
W
.
Write
(
_LF
)
if
err
!=
nil
{
goto
out
...
...
@@ -113,8 +108,6 @@ func (d *dumper) DumpData(datai *zodb.StorageRecordInformation) error {
}
out
:
d
.
workMem
=
buf
// XXX do we need this context ?
// see for rationale in similar place in DumpTxn
if
err
!=
nil
{
...
...
t/neo/zodb/str.go
View file @
6a52ac1a
...
...
@@ -27,11 +27,11 @@ func (oid Oid) String() string {
}
func
(
tid
Tid
)
XFmtString
(
b
[]
byte
)
[]
byte
{
return
xfmt
.
AppendHex
64
(
b
,
uint64
(
tid
))
return
xfmt
.
AppendHex
016
(
b
,
uint64
(
tid
))
}
func
(
oid
Oid
)
XFmtString
(
b
[]
byte
)
[]
byte
{
return
xfmt
.
AppendHex
64
(
b
,
uint64
(
oid
))
return
xfmt
.
AppendHex
016
(
b
,
uint64
(
oid
))
}
// XXX move me out of here
...
...
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