Commit 3b04f1df authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c22731dc
...@@ -91,7 +91,7 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) { ...@@ -91,7 +91,7 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) {
} }
// buffer for formatting // buffer for formatting
xbuf := xfmt.Buffer{} buf := xfmt.Buffer{}
// now loop loading transactions backwards until EOF / ntxn limit // now loop loading transactions backwards until EOF / ntxn limit
for i := ntxn; i > 0; i-- { for i := ntxn; i > 0; i-- {
...@@ -115,20 +115,20 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) { ...@@ -115,20 +115,20 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) {
} }
// print information about read txn record // print information about read txn record
xbuf.Reset() buf.Reset()
dataSha1 := sha1.Sum(data) dataSha1 := sha1.Sum(data)
xbuf .V(txnh.Tid.Time()) .S(": hash=") .Xb(dataSha1[:]) buf .V(txnh.Tid.Time()) .S(": hash=") .Xb(dataSha1[:])
// fstail.py uses repr to print user/description: // fstail.py uses repr to print user/description:
// https://github.com/zopefoundation/ZODB/blob/5.2.0-5-g6047e2fae/src/ZODB/scripts/fstail.py#L39 // https://github.com/zopefoundation/ZODB/blob/5.2.0-5-g6047e2fae/src/ZODB/scripts/fstail.py#L39
xbuf .S("\nuser=") .Qpyb(txnh.User) .S(" description=") .Qpyb(txnh.Description) buf .S("\nuser=") .Qpyb(txnh.User) .S(" description=") .Qpyb(txnh.Description)
// NOTE in zodb/py .length is len - 8, in zodb/go - whole txn record length // NOTE in zodb/py .length is len - 8, in zodb/go - whole txn record length
xbuf .S(" length=") .D64(txnh.Len - 8) buf .S(" length=") .D64(txnh.Len - 8)
xbuf .S(" offset=") .D64(txnh.Pos) .S(" (+") .D64(txnh.HeaderLen()) .S(")\n\n") buf .S(" offset=") .D64(txnh.Pos) .S(" (+") .D64(txnh.HeaderLen()) .S(")\n\n")
_, err = w.Write(xbuf.Bytes()) _, err = w.Write(buf.Bytes())
if err != nil { if err != nil {
break break
} }
......
...@@ -24,9 +24,9 @@ ...@@ -24,9 +24,9 @@
// //
// xfmt analog would be // xfmt analog would be
// //
// xbuf := xfmt.Buffer{} // buf := xfmt.Buffer{}
// xbuf .S("hello ") .Q("world") .C(' ') .D(1) .C(' ') .Xb([]byte("data")) // buf .S("hello ") .Q("world") .C(' ') .D(1) .C(' ') .Xb([]byte("data"))
// s := xbuf.Bytes() // s := buf.Bytes()
// //
// xfmt.Buffer can be reused several times via Buffer.Reset() . // xfmt.Buffer can be reused several times via Buffer.Reset() .
package xfmt package xfmt
......
...@@ -52,7 +52,7 @@ type dumper struct { ...@@ -52,7 +52,7 @@ type dumper struct {
afterFirst bool // true after first transaction has been dumped afterFirst bool // true after first transaction has been dumped
xbuf xfmt.Buffer // reusable data buffer for formatting buf xfmt.Buffer // reusable data buffer for formatting
} }
var _LF = []byte{'\n'} var _LF = []byte{'\n'}
...@@ -60,31 +60,31 @@ var _LF = []byte{'\n'} ...@@ -60,31 +60,31 @@ var _LF = []byte{'\n'}
// DumpData dumps one data record // DumpData dumps one data record
func (d *dumper) DumpData(datai *zodb.StorageRecordInformation) error { func (d *dumper) DumpData(datai *zodb.StorageRecordInformation) error {
xbuf := &d.xbuf buf := &d.buf
xbuf.Reset() buf.Reset()
xbuf .S("obj ") .V(&datai.Oid) .Cb(' ') buf .S("obj ") .V(&datai.Oid) .Cb(' ')
writeData := false writeData := false
switch { switch {
case datai.Data == nil: case datai.Data == nil:
xbuf.S("delete") buf .S("delete")
case datai.Tid != datai.DataTid: case datai.Tid != datai.DataTid:
xbuf .S("from ") .V(&datai.DataTid) buf .S("from ") .V(&datai.DataTid)
default: default:
dataSha1 := sha1.Sum(datai.Data) dataSha1 := sha1.Sum(datai.Data)
xbuf .D(len(datai.Data)) .S(" sha1:") .Xb(dataSha1[:]) buf .D(len(datai.Data)) .S(" sha1:") .Xb(dataSha1[:])
writeData = true writeData = true
} }
xbuf .Cb('\n') buf .Cb('\n')
// TODO use writev(data, "\n") via net.Buffers (it is already available) // TODO use writev(data, "\n") via net.Buffers (it is already available)
_, err := d.W.Write(xbuf.Bytes()) _, err := d.W.Write(buf.Bytes())
if err != nil { if err != nil {
goto out goto out
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment