Commit b90ada39 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 3529459c
......@@ -27,7 +27,7 @@ import (
pickle "github.com/kisielk/og-rek"
)
// PyData represent data stored into ZODB by Python applications.
// PyData represents data stored into ZODB by Python applications.
//
// The format is based on python pickles. Basically every serialized object has
// two parts: class description and object state. See
......
......@@ -792,7 +792,7 @@ func Iterate(r io.ReaderAt, posStart int64, dir IterDir) *Iter {
case IterBackward:
it.Txnh.LenPrev = lenIterStart
default:
panic("invalid dir")
panic("dir invalid")
}
return it
}
......@@ -1267,9 +1267,7 @@ func (fs *FileStorage) computeIndex(ctx context.Context) (index *Index, err erro
// not want to load actual data - only data headers.
fsSeq := xbufio.NewSeqReaderAt(fs.file)
// pre-setup txnh so that txnh.LoadNext starts loading from the beginning of file
txnh := &TxnHeader{Pos: index.TopPos, Len: lenIterStart}
dh := &DataHeader{}
it := Iterate(fsSeq, index.TopPos, IterForward)
loop:
for {
......@@ -1280,7 +1278,7 @@ loop:
default:
}
err = txnh.LoadNext(fsSeq, LoadNoStrings)
err = it.NextTxn(LoadNoStrings)
if err != nil {
err = okEOF(err)
break
......@@ -1288,14 +1286,10 @@ loop:
// XXX check txnh.Status != TxnInprogress
index.TopPos = txnh.Pos + txnh.Len
// first data iteration will go to first data record
dh.Pos = txnh.DataPos()
dh.DataLen = -DataHeaderSize
index.TopPos = it.Txnh.Pos + it.Txnh.Len
for {
err = dh.LoadNext(fsSeq, txnh)
err = it.NextData()
if err != nil {
err = okEOF(err)
if err != nil {
......@@ -1304,7 +1298,7 @@ loop:
break
}
index.Set(dh.Oid, dh.Pos)
index.Set(it.Datah.Oid, it.Datah.Pos)
}
}
......
......@@ -288,7 +288,7 @@ func TestComputeIndex(t *testing.T) {
fs := xfsopen(t, "testdata/1.fs") // TODO open ro
defer exc.XRun(fs.Close)
index, err := fs.computeIndex(context.TODO())
index, err := fs.computeIndex(context.Background())
if err != nil {
t.Fatal(err)
}
......
......@@ -50,13 +50,12 @@ type Dumper interface {
// transaction if it needs to dump information about data records.
//
// If dumper return io.EOF the whole dumping process finishes.
// XXX -> better dedicated err?
DumpTxn(buf *xfmt.Buffer, it *fs1.Iter) error
}
// Dump dumps content of a FileStorage file @ path.
// To do so it reads file header and then iterates over all transactions in the file.
// The logic to actually output information and if needed read/process data is implemented by Dumper d.
// The logic to actually output information and, if needed read/process data, is implemented by Dumper d.
func Dump(w io.Writer, path string, dir fs1.IterDir, d Dumper) (err error) {
defer xerr.Contextf(&err, "%s: %s", path, d.DumperName()) // XXX ok?
......@@ -78,7 +77,7 @@ func Dump(w io.Writer, path string, dir fs1.IterDir, d Dumper) (err error) {
return err
}
// make sure to flush buffer if we return prematurely e.g. with an error
// make sure to flush buffer on return
defer func() {
err2 := flushBuf()
err = xerr.First(err, err2)
......
......@@ -94,3 +94,5 @@ func reindexMain(argv []string) {
log.Fatal(err)
}
}
// TODO verify-index
......@@ -28,7 +28,7 @@ var commands = zodbtools.CommandRegistry{
// + fsstats? (fsstats.py)
{"reindex", reindexSummary, reindexUsage, reindexMain},
// XXX reindex -> reindex, verify-index
{"verify-index", verifyIdxSummary, verifyIdxUsage, verifyIdxMaxin},
// recover (fsrecover.py)
// verify (fstest.py)
......
......@@ -198,7 +198,7 @@ def main():
with open("ztestdata_expect_test.go", "w") as f:
def emit(v):
print >>f, v
emit("// Code generated by %s; DO NOT EDIT." % __name__)
emit("// Code generated by %s; DO NOT EDIT." % __file__)
emit("package fs1\n")
emit("import \"lab.nexedi.com/kirr/neo/go/zodb\"\n")
......
// Code generated by py/gen-testdata; DO NOT EDIT.
// Code generated by ./py/gen-testdata; DO NOT EDIT.
package fs1
import "lab.nexedi.com/kirr/neo/go/zodb"
......
......@@ -165,6 +165,7 @@ type IStorage interface {
// tpc_finish(txn, callback) XXX clarify about callback
// tpc_abort(txn)
// XXX allow iteration both ways (forward & backward)
// XXX text
Iterate(tidMin, tidMax Tid) IStorageIterator // XXX , error ?
}
......
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