Commit ef153515 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Return max (oid|serial) from the last iteration before the loop break.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2500 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 2dbdc90e
...@@ -684,12 +684,14 @@ class BTreeDatabaseManager(DatabaseManager): ...@@ -684,12 +684,14 @@ class BTreeDatabaseManager(DatabaseManager):
# XXX: XOR is a lame checksum # XXX: XOR is a lame checksum
count = 0 count = 0
tid_checksum = 0 tid_checksum = 0
tid = 0
max_tid = 0 max_tid = 0
for max_tid in safeIter(self._trans.keys, min=util.u64(min_tid)): for tid in safeIter(self._trans.keys, min=util.u64(min_tid)):
if max_tid % num_partitions == partition: if tid % num_partitions == partition:
if count >= length: if count >= length:
break break
tid_checksum ^= max_tid max_tid = tid
tid_checksum ^= tid
count += 1 count += 1
return count, tid_checksum, util.p64(max_tid) return count, tid_checksum, util.p64(max_tid)
...@@ -701,21 +703,23 @@ class BTreeDatabaseManager(DatabaseManager): ...@@ -701,21 +703,23 @@ class BTreeDatabaseManager(DatabaseManager):
min_oid = u64(min_oid) min_oid = u64(min_oid)
count = 0 count = 0
oid_checksum = serial_checksum = 0 oid_checksum = serial_checksum = 0
max_oid = max_serial = 0 max_oid = oid = max_serial = serial = 0
for max_oid, tserial in safeIter(self._obj.items, min=min_oid): for oid, tserial in safeIter(self._obj.items, min=min_oid):
if max_oid % num_partitions == partition: if oid % num_partitions == partition:
if max_oid == min_oid: if oid == min_oid:
try: try:
serial_iter = tserial.keys(min=u64(min_serial)) serial_iter = tserial.keys(min=u64(min_serial))
except ValueError: except ValueError:
continue continue
else: else:
serial_iter = tserial.keys() serial_iter = tserial.keys()
for max_serial in serial_iter: for serial in serial_iter:
if count >= length: if count >= length:
break break
oid_checksum ^= max_oid oid_checksum ^= oid
serial_checksum ^= max_serial serial_checksum ^= serial
max_serial = serial
max_oid = oid
count += 1 count += 1
if count >= length: if count >= length:
break break
......
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