Commit 75a9a26b authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent de0d5028
......@@ -283,7 +283,6 @@ func (fs *FileStorage) Load(_ context.Context, xid zodb.Xid) (data *zodb.Buf, ti
// be of first-found transaction
tid = dh.Tid
// TODO data -> slab
data, err = dh.LoadData(fs.file)
if err != nil {
return nil, 0, &ErrXidLoad{xid, err}
......@@ -315,7 +314,7 @@ type zIter struct {
dhLoading DataHeader
sri zodb.StorageRecordInformation // ptr to this will be returned by .NextData
dataBuf []byte
dataBuf *zodb.Buf
}
type zIterFlags int
......@@ -369,17 +368,22 @@ func (zi *zIter) NextData() (*zodb.StorageRecordInformation, error) {
// NOTE dh.LoadData() changes dh state while going through backpointers -
// - need to use separate dh because of this
zi.dhLoading = zi.iter.Datah
zi.sri.Data = zi.dataBuf
err = zi.dhLoading.LoadData(zi.iter.R, &zi.sri.Data)
if zi.dataBuf != nil {
zi.dataBuf.Free()
zi.dataBuf = nil
}
// zi.sri.Data = zi.dataBuf
zi.dataBuf, err = zi.dhLoading.LoadData(zi.iter.R) //, &zi.sri.Data)
if err != nil {
return nil, err // XXX recheck
}
// if memory was reallocated - use it next time
if cap(zi.sri.Data) > cap(zi.dataBuf) {
zi.dataBuf = zi.sri.Data
}
// // if memory was reallocated - use it next time
// if cap(zi.sri.Data) > cap(zi.dataBuf) {
// zi.dataBuf = zi.sri.Data
// }
zi.sri.Data = zi.dataBuf.Data
zi.sri.DataTid = zi.dhLoading.Tid
return &zi.sri, nil
}
......
......@@ -75,15 +75,15 @@ type oidLoadedOk struct {
// checkLoad verifies that fs.Load(xid) returns expected result
func checkLoad(t *testing.T, fs *FileStorage, xid zodb.Xid, expect oidLoadedOk) {
data, tid, err := fs.Load(context.Background(), xid)
buf, tid, err := fs.Load(context.Background(), xid)
if err != nil {
t.Errorf("load %v: %v", xid, err)
}
if tid != expect.tid {
t.Errorf("load %v: returned tid unexpected: %v ; want: %v", xid, tid, expect.tid)
}
if !reflect.DeepEqual(data, expect.data) { // NOTE reflect to catch nil != ""
t.Errorf("load %v: different data:\nhave: %q\nwant: %q", xid, data, expect.data)
if !reflect.DeepEqual(buf.Data, expect.data) { // NOTE reflect to catch nil != ""
t.Errorf("load %v: different data:\nhave: %q\nwant: %q", xid, buf.Data, expect.data)
}
}
......
......@@ -132,7 +132,7 @@ type DumperFsDump struct {
// for loading data
dhLoading fs1.DataHeader
data []byte
// data []byte
}
func (d *DumperFsDump) DumperName() string {
......@@ -174,30 +174,30 @@ func (d *DumperFsDump) DumpTxn(buf *xfmt.Buffer, it *fs1.Iter) error {
// load actual data
d.dhLoading = *dh
data := d.data
err = d.dhLoading.LoadData(it.R, &data)
dataBuf, err := d.dhLoading.LoadData(it.R)
if err != nil {
return err
}
// if memory was reallocated - use it next time
if cap(data) > cap(d.data) {
d.data = data
}
if data == nil {
if dataBuf == nil {
buf .S(" class=undo or abort of object creation")
} else {
fullclass := zodb.PyData(data).ClassName()
fullclass := zodb.PyData(dataBuf.Data).ClassName()
buf .S(" size=") .D64(d.dhLoading.DataLen)
buf .S(" class=") .S(fullclass)
}
if dh.DataLen == 0 && data != nil {
if dh.DataLen == 0 && dataBuf != nil {
// it was backpointer - print tid of transaction it points to
buf .S(" bp=") .V(d.dhLoading.Tid)
}
// XXX avoid `if != nil`
if dataBuf != nil {
dataBuf.Free()
}
buf .S("\n")
}
......
......@@ -156,7 +156,7 @@ type IStorage interface {
//
// XXX zodb.loadBefore() returns (data, serial, serial_next) -> add serial_next?
//
// XXX currently deleted data is returned as data=nil -- is it ok?
// XXX currently deleted data is returned as data.Data=nil -- is it ok?
// TODO specify error when data not found -> ErrOidMissing | ErrXidMissing
Load(ctx context.Context, xid Xid) (data *Buf, serial Tid, err error) // XXX -> StorageRecordInformation ?
......
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