Commit 3b98998d authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent adea442b
...@@ -12,13 +12,22 @@ import ( ...@@ -12,13 +12,22 @@ import (
// one entry inside transaction // one entry inside transaction
type txnEntry struct { type txnEntry struct {
header DataHeader Header DataHeader
data []byte rawData []byte // what is on disk, e.g. it can be backpointer
data []byte // data client should see on load; nil means same as RawData
}
func (txe *txnEntry) Data() []byte {
data := txe.data
if data == nil {
data = txe.rawData
}
return data
} }
type dbEntry struct { type dbEntry struct {
header TxnHeader Header TxnHeader
entryv []txnEntry Entryv []txnEntry
} }
func TestLoad(t *testing.T) { func TestLoad(t *testing.T) {
...@@ -28,11 +37,8 @@ func TestLoad(t *testing.T) { ...@@ -28,11 +37,8 @@ func TestLoad(t *testing.T) {
} }
for _, dbe := range _1fs_dbEntryv { for _, dbe := range _1fs_dbEntryv {
for _, txe := range dbe.entryv { for _, txe := range dbe.Entryv {
txh := txe.header txh := txe.Header
if txh.DataLen == 0 {
continue // FIXME skipping backpointers
}
xid := zodb.Xid{zodb.XTid{txh.Tid, false}, txh.Oid} // loadSerial xid := zodb.Xid{zodb.XTid{txh.Tid, false}, txh.Oid} // loadSerial
data, tid, err := fs.Load(xid) data, tid, err := fs.Load(xid)
...@@ -42,8 +48,8 @@ func TestLoad(t *testing.T) { ...@@ -42,8 +48,8 @@ func TestLoad(t *testing.T) {
if tid != txh.Tid { if tid != txh.Tid {
t.Errorf("load %v: returned tid unexpected: %v", xid) t.Errorf("load %v: returned tid unexpected: %v", xid)
} }
if !bytes.Equal(data, txe.data) { if !bytes.Equal(data, txe.Data()) {
t.Errorf("load %v: different data:\nhave: %s\nwant: %s", xid, strconv.Quote(string(data)), strconv.Quote(string(txe.data))) t.Errorf("load %v: different data:\nhave: %s\nwant: %s", xid, strconv.Quote(string(data)), strconv.Quote(string(txe.Data())))
} }
} }
} }
......
...@@ -151,7 +151,6 @@ def main(): ...@@ -151,7 +151,6 @@ def main():
emit("\t\t\t\tDataHeader{") emit("\t\t\t\tDataHeader{")
emit("\t\t\t\t\tOid:\t%i," % unpack64(drec.oid)) emit("\t\t\t\t\tOid:\t%i," % unpack64(drec.oid))
emit("\t\t\t\t\tTid:\t%s," % hex64(drec.tid)) emit("\t\t\t\t\tTid:\t%s," % hex64(drec.tid))
# drec: .data .prev (=prev_txn)
emit("\t\t\t\t\tPrevDataRecPos:\t%i," % dh.prev) emit("\t\t\t\t\tPrevDataRecPos:\t%i," % dh.prev)
emit("\t\t\t\t\tTxnPos:\t%i," % txn._tpos) emit("\t\t\t\t\tTxnPos:\t%i," % txn._tpos)
...@@ -160,11 +159,14 @@ def main(): ...@@ -160,11 +159,14 @@ def main():
emit("\t\t\t\t},") emit("\t\t\t\t},")
plen = dh.plen plen = dh.plen
if plen == 0: if plen == 0:
data = p64(dh.back) # back-pointer or 0 (= delete) rawdata = p64(dh.back) # back-pointer or 0 (= delete)
data = "[]byte(%s)" % escapeqq(drec.data) # XXX vs .data = None ?
else: else:
data = drec.data rawdata = drec.data
data = "nil"
emit("\t\t\t\t[]byte(%s)," % escapeqq(data)) emit("\t\t\t\t[]byte(%s)," % escapeqq(rawdata))
emit("\t\t\t\t%s /* same as ^^^ */," % data)
emit("\t\t\t},") emit("\t\t\t},")
emit("\t\t},") emit("\t\t},")
......
This diff is collapsed.
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