Commit 8ee22408 authored by Jim Fulton's avatar Jim Fulton

Refined iterator interface in support of moving data between storages.

parent c6508ad3
...@@ -184,7 +184,7 @@ ...@@ -184,7 +184,7 @@
# may have a back pointer to a version record or to a non-version # may have a back pointer to a version record or to a non-version
# record. # record.
# #
__version__='$Revision: 1.42 $'[11:-2] __version__='$Revision: 1.43 $'[11:-2]
import struct, time, os, bpthread, string, base64, sys import struct, time, os, bpthread, string, base64, sys
from struct import pack, unpack from struct import pack, unpack
...@@ -737,7 +737,7 @@ class FileStorage(BaseStorage.BaseStorage): ...@@ -737,7 +737,7 @@ class FileStorage(BaseStorage.BaseStorage):
# OK, not clear the checkpoint flag # OK, not clear the checkpoint flag
file.seek(pos+16) file.seek(pos+16)
write(' ') write(self._tstatus)
file.flush() file.flush()
if fsync is not None: if fsync is not None:
...@@ -1718,7 +1718,6 @@ class FileIterator(Iterator): ...@@ -1718,7 +1718,6 @@ class FileIterator(Iterator):
file.seek(0,2) file.seek(0,2)
self._file_size=file.tell() self._file_size=file.tell()
self._pos=4 self._pos=4
self._index={}
def next(self, index=0): def next(self, index=0):
file=self._file file=self._file
...@@ -1792,16 +1791,14 @@ class FileIterator(Iterator): ...@@ -1792,16 +1791,14 @@ class FileIterator(Iterator):
pos=tpos+23+ul+dl+el pos=tpos+23+ul+dl+el
user=read(ul) user=read(ul)
description=read(dl) description=read(dl)
d={}
if el: if el:
try: try: e=loads(read(el))
e=loads(read(el)) except: e={}
d.update(e) else: e={}
except: pass
result=RecordIterator( result=RecordIterator(
tid, user, description, d, tid, status, user, description, e,
pos, (tend, file, seek, read, pos, (tend, file, seek, read,
self._index, self._index.get,
tpos, tpos,
) )
) )
...@@ -1824,8 +1821,9 @@ class FileIterator(Iterator): ...@@ -1824,8 +1821,9 @@ class FileIterator(Iterator):
class RecordIterator(Iterator): class RecordIterator(Iterator):
"""Iterate over the transactions in a FileStorage file. """Iterate over the transactions in a FileStorage file.
""" """
def __init__(self, tid, user, desc, ext, pos, stuff): def __init__(self, tid, status, user, desc, ext, pos, stuff):
self.tid=tid self.tid=tid
self.status=status
self.user=user self.user=user
self.description=desc self.description=desc
self._extension=ext self._extension=ext
...@@ -1835,7 +1833,7 @@ class RecordIterator(Iterator): ...@@ -1835,7 +1833,7 @@ class RecordIterator(Iterator):
def next(self, index=0): def next(self, index=0):
name='' name=''
pos = self._pos pos = self._pos
tend, file, seek, read, _index, get, tpos = self._stuff tend, file, seek, read, tpos = self._stuff
while pos < tend: while pos < tend:
# Read the data records for this transaction # Read the data records for this transaction
...@@ -1867,8 +1865,7 @@ class RecordIterator(Iterator): ...@@ -1867,8 +1865,7 @@ class RecordIterator(Iterator):
p=read(8) p=read(8)
p=_loadBack(file, oid, p)[0] p=_loadBack(file, oid, p)[0]
r=Record(oid, get(oid, None), serial, version, p) r=Record(oid, serial, version, p)
_index[oid]=serial
return r return r
...@@ -1879,4 +1876,4 @@ class Record: ...@@ -1879,4 +1876,4 @@ class Record:
"""An abstract database record """An abstract database record
""" """
def __init__(self, *args): def __init__(self, *args):
self.oid, self.old, self.serial, self.version, self.p = args self.oid, self.serial, self.version, self.data = args
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