Commit 8da1816d authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent cbd8f5fc
......@@ -865,7 +865,7 @@ func (fsi *Iterator) NextTxn() (*zodb.TxnInfo, zodb.IStorageRecordIterator, erro
}
func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
fmt.Printf("iterate %v..%v\n", tidMin, tidMax)
//fmt.Printf("iterate %v..%v\n", tidMin, tidMax)
// FIXME case when only 0 or 1 txn present
if tidMin < fs.txnhMin.Tid {
tidMin = fs.txnhMin.Tid
......@@ -890,12 +890,12 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
iter := &Iter.txnIter
if (tidMin - fs.txnhMin.Tid) < (fs.txnhMax.Tid - tidMin) {
println("forward")
//fmt.Printf("forward %.1f%%\n", 100 * float64(tidMin - fs.txnhMin.Tid) / float64(fs.txnhMax.Tid - fs.txnhMin.Tid))
iter.Flags = 1*iterDir | iterPreloaded
iter.Txnh.CloneFrom(&fs.txnhMin)
iter.TidStop = tidMin - 1 // XXX overflow
} else {
println("backward")
//fmt.Printf("backward %.1f%%\n", 100 * float64(tidMin - fs.txnhMin.Tid) / float64(fs.txnhMax.Tid - fs.txnhMin.Tid))
iter.Flags = 0*iterDir | iterPreloaded
iter.Txnh.CloneFrom(&fs.txnhMax)
iter.TidStop = tidMin
......
......@@ -124,6 +124,7 @@ func TestLoad(t *testing.T) {
for ii, tmin := range minv {
for jj, tmax := range maxv {
// XXX -> ntxn ?
// expected number of iteration steps
nsteps := j - i + 1
nsteps -= ii / 2 // one less point for tidMin+1
......@@ -132,9 +133,7 @@ func TestLoad(t *testing.T) {
nsteps = 0 // j < i and j == i and ii/jj
}
println()
println(len(tidv))
fmt.Printf("%d%+d .. %d%+d\t -> %d steps\n", i, ii-1, j, jj-1, nsteps)
//fmt.Printf("%d%+d .. %d%+d\t -> %d steps\n", i, ii-1, j, jj-1, nsteps)
iter := fs.Iterate(tmin, tmax)
......@@ -157,23 +156,44 @@ func TestLoad(t *testing.T) {
dbe := _1fs_dbEntryv[i + ii/2 + k]
// TODO also check .Pos, .LenPrev, .Len
// TODO also check .Pos, .LenPrev, .Len in iter.txnIter.*
if !reflect.DeepEqual(*txni, dbe.Header.TxnInfo) {
t.Fatalf("%v: unexpected txn entry:\nhave: %q\nwant: %q", subj, *txni, dbe.Header.TxnInfo)
}
for {
ndata := len(dbe.Entryv)
for kdata := 0; ; kdata++ {
dsubj := fmt.Sprintf("%v: dstep %v/%v", subj, kdata, ndata)
datai, err := dataIter.NextData()
if err != nil {
err = okEOF(err)
if err == io.EOF {
if kdata != ndata {
t.Fatalf("%v: data steps underrun", dsubj)
}
break
}
t.Fatalf("%v: %v", dsubj, err)
}
_ = datai
if kdata > ndata {
t.Fatalf("%v: dsteps overrun", dsubj)
}
// TODO check err
txe := dbe.Entryv[kdata]
// XXX -> func
if datai.Oid != txe.Header.Oid {
t.Fatalf("%v: oid mismatch ...", dsubj) // XXX
}
if datai.Tid != txe.Header.Tid {
t.Fatalf("%v: tid mismatch ...", dsubj) // XXX
}
if !bytes.Equal(datai.Data, txe.Data()) {
t.Fatalf("%v: data mismatch ...", dsubj) // XXX
}
// TODO .DataTid
}
}
}
......
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