Commit ddf5e478 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 11ecd687
......@@ -85,6 +85,8 @@ def main():
u"undo %i.%i\nmore detailed description\n\nzzz ..." % (i, j) + "\t"*(i+j),
{"x-generator": "zodb/py2 (undo %s)" % ul["id"]})
# TODO delete an object
conn.close()
db.close()
stor.close()
......@@ -105,44 +107,57 @@ def main():
# database records
stor = FileStorage(outfs, read_only=True)
oidPrevPos = {} # oid -> pos of last drec(oid)
#oidPrevPos = {} # oid -> pos of last drec(oid)
emit("\nvar _1fs_dbEntryv = [...]dbEntry{")
for txn in stor.iterator(): # txn is TransactionRecord
# txn.extension is already depickled dict - we want to put raw data from file
# also we need to access txn record legth which is not provided by higher-level iterator
# do deep-dive into FileStorage
h = stor._read_txn_header(txn._tpos)
assert h.tid == txn.tid
assert h.tlen == txn._tend - txn._tpos
th = stor._read_txn_header(txn._tpos)
assert th.tid == txn.tid
assert th.tlen == txn._tend - txn._tpos
# -> TxnHeader
emit("\tTxnHeader{")
emit("\t\tTid:\t%s," % hex64(txn.tid))
emit("\t\tRecLenm8:\t%i," % h.tlen)
emit("\t\tRecLenm8:\t%i," % th.tlen)
emit("\t\tStatus:\t'%s'," % txn.status)
emit("\t\tUser:\t\t[]byte(\"%s\")," % txn.user.encode('string_escape'))
emit("\t\tDescription:\t[]byte(\"%s\")," % txn.description.encode('string_escape'))
emit("\t\tExtension:\t[]byte(\"%s\")," % h.ext.encode('string_escape'))
# txn: ._pos ._tend ._tpos
emit("\t\tExtension:\t[]byte(\"%s\")," % th.ext.encode('string_escape'))
# -> DataHeader + payload
for drec in txn: # drec is itemof(TransactionRecordIterator) = Record
# same as with txn - not everything is possible to get via
# higher-level api
dh = stor._read_data_header(drec.pos)
assert dh.oid == drec.oid
assert dh.tid == drec.tid
assert dh.tloc == txn._tpos
emit("\n\t\tDataHeader{")
emit("\t\t\tOid:\t%i," % unpack64(drec.oid))
emit("\t\t\tTid:\t%s," % hex64(drec.tid))
# drec: .data .prev (=prev_txn) .pos
# drec: .data .prev (=prev_txn)
emit("\t\t\tPrevDataRecPos:\t%i," % oidPrevPos.get(drec.oid, 0))
#emit("\t\t\tPrevDataRecPos:\t%i," % oidPrevPos.get(drec.oid, 0))
emit("\t\t\tPrevDataRecPos:\t%i," % dh.prev)
emit("\t\t\tTxnPos:\t%i," % txn._tpos)
assert drec.version == ''
# DataLen
emit("\t\t\tDataLen:\t%i," % dh.plen)
plen = dh.plen
if plen == 0:
data = p64(dh.back) # back-pointer or 0 (= delete)
else:
data = drec.data
emit("\t\t\tData:\t[]byte(\"%s\")," % data.encode('string_escape'))
#.data .data_txn
emit("\t\t},")
oidPrevPos[drec.oid] = drec.pos
#oidPrevPos[drec.oid] = drec.pos
emit("\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