Commit 1dd5d4c1 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 0fc00c67
...@@ -39,17 +39,18 @@ type Backend struct { ...@@ -39,17 +39,18 @@ type Backend struct {
// 2 ? (data.fs) // 2 ? (data.fs)
// 3 packed/ (deltified objects) // 3 packed/ (deltified objects)
// //
// XXX we currently depend on extra functionality FS provides over // NOTE we currently depend on extra functionality FS provides over
// plain zodb.IStorage (e.g. loading with nextSerial) and even if // plain zodb.IStorage (loading with nextSerial) and even if nextSerial
// nextSerial will be gone in the future, we will probably depend on // will be gone in the future, we will probably depend on particular
// particular layout more and more -> directly work with fs1 & friends. // layout more and more -> directly work with fs1 & friends.
zstor *fs1.FileStorage // underlying ZODB storage zstor *fs1.FileStorage // underlying ZODB storage
} }
var _ storage.Backend = (*Backend)(nil) var _ storage.Backend = (*Backend)(nil)
func Open(ctx context.Context, path string) (*Backend, error) { func Open(ctx context.Context, path string) (*Backend, error) {
zstor, _, err := fs1.Open(ctx, path, &zodb.DriverOptions{ReadOnly: true}) // XXX RO? +Watchq? // XXX +Watchq? but nobody except us should change the file. -> lock?
zstor, _, err := fs1.Open(ctx, path, &zodb.DriverOptions{ReadOnly: true})
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -69,7 +70,7 @@ func (f *Backend) LastOid(ctx context.Context) (zodb.Oid, error) { ...@@ -69,7 +70,7 @@ func (f *Backend) LastOid(ctx context.Context) (zodb.Oid, error) {
} }
func (f *Backend) Load(ctx context.Context, xid zodb.Xid) (*proto.AnswerObject, error) { func (f *Backend) Load(ctx context.Context, xid zodb.Xid) (*proto.AnswerObject, error) {
// FIXME kill nextSerial support after neo/py cache does not depend on next_serial // TODO kill nextSerial support after neo/py cache does not depend on next_serial
// see also: https://github.com/zopefoundation/ZODB/pull/323 // see also: https://github.com/zopefoundation/ZODB/pull/323
buf, serial, nextSerial, err := f.zstor.Load_XXXWithNextSerialXXX(ctx, xid) buf, serial, nextSerial, err := f.zstor.Load_XXXWithNextSerialXXX(ctx, xid)
if err != nil { if err != nil {
...@@ -81,15 +82,14 @@ func (f *Backend) Load(ctx context.Context, xid zodb.Xid) (*proto.AnswerObject, ...@@ -81,15 +82,14 @@ func (f *Backend) Load(ctx context.Context, xid zodb.Xid) (*proto.AnswerObject,
nextSerial = proto.INVALID_TID nextSerial = proto.INVALID_TID
} }
return &proto.AnswerObject{ return &proto.AnswerObject{
Oid: xid.Oid, Oid: xid.Oid,
Serial: serial, Serial: serial,
NextSerial: nextSerial, NextSerial: nextSerial,
Compression: false, Compression: false,
Data: buf, Data: buf,
Checksum: xsha1.NEOSum(buf.Data), // XXX computing every time Checksum: xsha1.NEOSum(buf.Data), // XXX computing every time
// XXX .DataSerial // XXX .DataSerial
}, nil }, nil
...@@ -103,7 +103,7 @@ func openBackend(ctx context.Context, path string) (storage.Backend, error) { ...@@ -103,7 +103,7 @@ func openBackend(ctx context.Context, path string) (storage.Backend, error) {
if err == nil { if err == nil {
return b, nil return b, nil
} else { } else {
return nil, err // XXX don't return just b -> will be !nil interface return nil, err // don't return just b -> will be !nil interface
} }
} }
......
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