Commit b3990efb authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 7b0c4bc4
...@@ -760,7 +760,7 @@ func (it *Iter) NextTxn(flags TxnLoadFlags) error { ...@@ -760,7 +760,7 @@ func (it *Iter) NextTxn(flags TxnLoadFlags) error {
panic("Iter.Dir invalid") panic("Iter.Dir invalid")
} }
fmt.Printf("Iter.NextTxn dir=%v -> %v\n", it.Dir, err) //fmt.Printf("Iter.NextTxn dir=%v -> %v\n", it.Dir, err)
if err != nil { if err != nil {
// reset .Datah to be invalid (just in case) // reset .Datah to be invalid (just in case)
...@@ -1136,7 +1136,7 @@ func (e *iterStartError) NextTxn() (*zodb.TxnInfo, zodb.IStorageRecordIterator, ...@@ -1136,7 +1136,7 @@ func (e *iterStartError) NextTxn() (*zodb.TxnInfo, zodb.IStorageRecordIterator,
// error != nil only on IO error // error != nil only on IO error
// XXX ^^^ text // XXX ^^^ text
func (fs *FileStorage) findTxnRecord(r io.ReaderAt, tid zodb.Tid) (TxnHeader, error) { func (fs *FileStorage) findTxnRecord(r io.ReaderAt, tid zodb.Tid) (TxnHeader, error) {
fmt.Printf("findTxn %v\n", tid) //fmt.Printf("findTxn %v\n", tid)
// XXX read snapshot under lock // XXX read snapshot under lock
// NOTE cloning to unalias strings memory // NOTE cloning to unalias strings memory
...@@ -1165,11 +1165,11 @@ func (fs *FileStorage) findTxnRecord(r io.ReaderAt, tid zodb.Tid) (TxnHeader, er ...@@ -1165,11 +1165,11 @@ func (fs *FileStorage) findTxnRecord(r io.ReaderAt, tid zodb.Tid) (TxnHeader, er
iter := &Iter{R: r} iter := &Iter{R: r}
if (tid - tmin.Tid) < (tmax.Tid - tid) { if (tid - tmin.Tid) < (tmax.Tid - tid) {
fmt.Printf("forward %.1f%%\n", 100 * float64(tid - tmin.Tid) / float64(tmax.Tid - tmin.Tid)) //fmt.Printf("forward %.1f%%\n", 100 * float64(tid - tmin.Tid) / float64(tmax.Tid - tmin.Tid))
iter.Dir = IterForward iter.Dir = IterForward
iter.Txnh = tmin // ok not to clone - memory is already ours iter.Txnh = tmin // ok not to clone - memory is already ours
} else { } else {
fmt.Printf("backward %.1f%%\n", 100 * float64(tid - tmin.Tid) / float64(tmax.Tid - tmin.Tid)) //fmt.Printf("backward %.1f%%\n", 100 * float64(tid - tmin.Tid) / float64(tmax.Tid - tmin.Tid))
iter.Dir = IterBackward iter.Dir = IterBackward
iter.Txnh = tmax // ok not to clone - ... ^^^ iter.Txnh = tmax // ok not to clone - ... ^^^
} }
...@@ -1210,63 +1210,14 @@ func (fs *FileStorage) findTxnRecord(r io.ReaderAt, tid zodb.Tid) (TxnHeader, er ...@@ -1210,63 +1210,14 @@ func (fs *FileStorage) findTxnRecord(r io.ReaderAt, tid zodb.Tid) (TxnHeader, er
// Iterate creates zodb-level iterator for tidMin..tidMax range // Iterate creates zodb-level iterator for tidMin..tidMax range
func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator { 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)
// XXX still needed ?
/*
// FIXME case when only 0 or 1 txn present
if tidMin < fs.txnhMin.Tid {
tidMin = fs.txnhMin.Tid
}
if tidMax > fs.txnhMax.Tid {
tidMax = fs.txnhMax.Tid
}
*/
// when iterating use IO optimized for sequential access // when iterating use IO optimized for sequential access
// XXX -> IterateRaw ? // XXX -> IterateRaw ?
fsSeq := xbufio.NewSeqReaderAt(fs.file) fsSeq := xbufio.NewSeqReaderAt(fs.file)
ziter := &zIter{iter: Iter{R: fsSeq, Dir: IterForward}, TidStop: tidMax} ziter := &zIter{iter: Iter{R: fsSeq}}
iter := &ziter.iter iter := &ziter.iter
// XXX still needed?
/*
if tidMin > tidMax {
ziter.zFlags |= zIterEOF // empty
return ziter
}
*/
/*
// scan either from file start or end, depending which way it is likely closer, to tidMin
if (tidMin - fs.txnhMin.Tid) < (fs.txnhMax.Tid - tidMin) {
fmt.Printf("forward %.1f%%\n", 100 * float64(tidMin - fs.txnhMin.Tid) / float64(fs.txnhMax.Tid - fs.txnhMin.Tid))
iter.Dir = IterForward
iter.Txnh.CloneFrom(&fs.txnhMin)
ziter.zFlags = zIterPreloaded
ziter.TidStop = tidMin - 1 // XXX overflow
} else {
fmt.Printf("backward %.1f%%\n", 100 * float64(tidMin - fs.txnhMin.Tid) / float64(fs.txnhMax.Tid - fs.txnhMin.Tid))
iter.Dir = IterBackward
iter.Txnh.CloneFrom(&fs.txnhMax)
ziter.zFlags = zIterPreloaded
ziter.TidStop = tidMin
}
println("AAA")
// XXX recheck how we enter loop
var err error
for {
err = iter.NextTxn(LoadNoStrings) // XXX -> ziter
if err != nil {
err = okEOF(err)
break
}
}
println("BBB")
*/
// find first txn : txn.tid >= tidMin // find first txn : txn.tid >= tidMin
txnh, err := fs.findTxnRecord(fsSeq, tidMin) txnh, err := fs.findTxnRecord(fsSeq, tidMin)
if err != nil { if err != nil {
...@@ -1277,28 +1228,14 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator { ...@@ -1277,28 +1228,14 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
return ziter return ziter
} }
fmt.Printf("tidRange: %v..%v -> found %v @%v\n", tidMin, tidMax, txnh.Tid, txnh.Pos) //fmt.Printf("tidRange: %v..%v -> found %v @%v\n", tidMin, tidMax, txnh.Tid, txnh.Pos)
fmt.Printf("\t%#v\n", txnh)
/*
// where to start around tidMin found - let's reinitialize iter to
// iterate appropriately forward up to tidMax
ziter.zFlags &= ^zIterEOF
if iter.Dir == IterForward {
// when ^^^ we were searching forward first txn was already found
err = iter.Txnh.loadStrings(fsSeq) // XXX ok? XXX -> move NextTxn() ?
if err != nil {
return &iterStartError{err}
}
ziter.zFlags |= zIterPreloaded
}
*/
// setup iter from what findTxnRecord found
iter.Txnh = txnh iter.Txnh = txnh
iter.Datah.Pos = txnh.DataPos() iter.Datah.Pos = txnh.DataPos() // XXX dup wrt Iter.NextTxn
iter.Datah.DataLen = -DataHeaderSize // first iteration will go to first data record iter.Datah.DataLen = -DataHeaderSize // first iteration will go to first data record
iter.Dir = IterForward iter.Dir = IterForward // XXX allow both ways iteration at ZODB level
ziter.zFlags |= zIterPreloaded ziter.zFlags |= zIterPreloaded
ziter.TidStop = tidMax ziter.TidStop = tidMax
......
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