Commit 741b31d4 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 8d2589f8
...@@ -50,7 +50,7 @@ type TxnHeader struct { ...@@ -50,7 +50,7 @@ type TxnHeader struct {
// transaction metadata tself // transaction metadata tself
zodb.TxnInfo zodb.TxnInfo
// underlying memory for loading and for user/desc/extension // underlying memory for header loading and for user/desc/extension
workMem []byte workMem []byte
} }
...@@ -73,12 +73,13 @@ func (e *ErrTxnRecord) Error() string { ...@@ -73,12 +73,13 @@ func (e *ErrTxnRecord) Error() string {
// DataHeader represents header of a data record // DataHeader represents header of a data record
type DataHeader struct { type DataHeader struct {
Pos int64 // position of data record
Oid zodb.Oid Oid zodb.Oid
Tid zodb.Tid Tid zodb.Tid
PrevDataRecPos int64 // previous-record file-position XXX name PrevRevPos int64 // position of this oid's previous-revision data record
TxnPos int64 // position of transaction record this data record belongs to TxnPos int64 // position of transaction record this data record belongs to
//_ uint16 // 2-bytes with zero values. (Was version length.) //_ uint16 // 2-bytes with zero values. (Was version length.)
DataLen uint64 // length of following data. if 0 -> following = 8 bytes backpointer XXX -> int64 too ? DataLen int64 // length of following data. if 0 -> following = 8 bytes backpointer XXX -> validate in code
// if backpointer == 0 -> oid deleted // if backpointer == 0 -> oid deleted
//Data []byte //Data []byte
//DataRecPos uint64 // if Data == nil -> byte position of data record containing data //DataRecPos uint64 // if Data == nil -> byte position of data record containing data
...@@ -203,7 +204,7 @@ func (txnh *TxnHeader) loadStrings(r io.ReaderAt) error { ...@@ -203,7 +204,7 @@ func (txnh *TxnHeader) loadStrings(r io.ReaderAt) error {
txnh.Extension = txnh.Extension[:cap(txnh.Extension)] txnh.Extension = txnh.Extension[:cap(txnh.Extension)]
} }
// loadPrev reads and decodes previous transaction record header from a readerAt // LoadPrev reads and decodes previous transaction record header from a readerAt
// txnh should be already initialized by previous call to load() // txnh should be already initialized by previous call to load()
func (txnh *TxnHeader) LoadPrev(r io.ReaderAt, flags TxnLoadFlags) error { func (txnh *TxnHeader) LoadPrev(r io.ReaderAt, flags TxnLoadFlags) error {
if txnh.PrevLen == 0 { if txnh.PrevLen == 0 {
...@@ -213,7 +214,7 @@ func (txnh *TxnHeader) LoadPrev(r io.ReaderAt, flags TxnLoadFlags) error { ...@@ -213,7 +214,7 @@ func (txnh *TxnHeader) LoadPrev(r io.ReaderAt, flags TxnLoadFlags) error {
return txnh.Load(r, txnh.Pos - txnh.PrevLen, flags) return txnh.Load(r, txnh.Pos - txnh.PrevLen, flags)
} }
// loadNext reads and decodes next transaction record header from a readerAt // LoadNext reads and decodes next transaction record header from a readerAt
// txnh should be already initialized by previous call to load() // txnh should be already initialized by previous call to load()
func (txnh *TxnHeader) LoadNext(r io.ReaderAt, flags TxnLoadFlags) error { func (txnh *TxnHeader) LoadNext(r io.ReaderAt, flags TxnLoadFlags) error {
return txnh.Load(r, txnh.Pos + txnh.Len, flags) return txnh.Load(r, txnh.Pos + txnh.Len, flags)
...@@ -226,13 +227,9 @@ func (txnh *TxnHeader) LoadNext(r io.ReaderAt, flags TxnLoadFlags) error { ...@@ -226,13 +227,9 @@ func (txnh *TxnHeader) LoadNext(r io.ReaderAt, flags TxnLoadFlags) error {
// XXX io.ReaderAt -> *os.File (if iface conv costly) // XXX io.ReaderAt -> *os.File (if iface conv costly)
func (dh *DataHeader) decode(r io.ReaderAt, pos int64, tmpBuf *[dataHeaderSize]byte) error { func (dh *DataHeader) decode(r io.ReaderAt, pos int64, tmpBuf *[dataHeaderSize]byte) error {
n, err := r.ReadAt(tmpBuf[:], pos) n, err := r.ReadAt(tmpBuf[:], pos)
// XXX vvv if EOF is after header - record is broken
if n == dataHeaderSize {
err = nil // we don't mind if it was EOF after full header read
}
if err != nil { if err != nil {
return &ErrDataRecord{pos, "read", err} return &ErrDataRecord{pos, "read", noEof(err)}
} }
dh.Oid = zodb.Oid(binary.BigEndian.Uint64(tmpBuf[0:])) // XXX -> zodb.Oid.Decode() ? dh.Oid = zodb.Oid(binary.BigEndian.Uint64(tmpBuf[0:])) // XXX -> zodb.Oid.Decode() ?
......
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