Commit 53b772dd authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 0921f02d
......@@ -116,7 +116,7 @@ func (dh *DataHeader) Decode(r io.ReaderAt, pos int64) error {
func NewFileStorage(path string) (*FileStorage, error) {
func OpenFileStorage(path string) (*FileStorage, error) {
f, err := os.Open(path) // XXX opens in O_RDONLY
if err != nil {
return nil, err // XXX err more context ?
......@@ -248,9 +248,9 @@ func (fs *FileStorage) StorageName() string {
return "FileStorage v1"
}
func (fs *FileStorage) Iterate(start, stop zodb.Tid) zodb.IStorageIterator {
if start != zodb.Tid0 || stop != zodb.TidMax {
panic("TODO start/stop support")
func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
if tidMin != zodb.Tid0 || tidMax != zodb.TidMax {
panic("TODO tidMin/tidMax support")
}
// TODO
......
......@@ -37,10 +37,6 @@ type oidLoadedOk struct {
data []byte
}
// current knowledge of what was "before" for an oid as we scan over
// data base entries
type beforeMap map[zodb.Oid]oidLoadedOk
func checkLoad(t *testing.T, fs *FileStorage, xid zodb.Xid, expect oidLoadedOk) {
data, tid, err := fs.Load(xid)
if err != nil {
......@@ -55,12 +51,15 @@ func checkLoad(t *testing.T, fs *FileStorage, xid zodb.Xid, expect oidLoadedOk)
}
func TestLoad(t *testing.T) {
fs, err := NewFileStorage("testdata/1.fs")
fs, err := OpenFileStorage("testdata/1.fs")
if err != nil {
t.Fatal(err)
}
//defer xclose(fs)
before := beforeMap{}
// current knowledge of what was "before" for an oid as we scan over
// data base entries
before := map[zodb.Oid]oidLoadedOk{}
for _, dbe := range _1fs_dbEntryv {
for _, txe := range dbe.Entryv {
......@@ -93,4 +92,22 @@ func TestLoad(t *testing.T) {
xid := zodb.Xid{zodb.XTid{zodb.TidMax, true}, oid}
checkLoad(t, fs, xid, expect)
}
// check iterating XXX move to separate test ?
// tids we will use for tid{Min,Max}
tidv := []zodb.Tid{zodb.Tid(0)}
for _, dbe := range _1fs_dbEntryv {
tidv = append(tidv, dbe.Header.Tid)
}
tidv = append(tidv, zodb.TidMax)
for i, tidMin := range tidv {
for j, tidMax := range tidv {
iter := fs.Iterate(tidMin, tidMax)
if tidMin > tidMax {
// expect error / panic or empty iteration ?
}
}
}
}
......@@ -153,7 +153,7 @@ type IStorage interface {
// tpc_finish(txn, callback) XXX clarify about callback
// tpc_abort(txn)
Iterate(start, stop Tid) IStorageIterator // XXX -> Iter() ?
Iterate(tidMin, tidMax Tid) IStorageIterator // XXX -> Iter() ?
}
type IStorageIterator 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