Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: CVS

CVS: Products/Ape/lib/apelib/zodb3 - storage.py:1.18

 

 

Zope cvs RSS feed   Index | Next | Previous | View Threaded


cz at gocept

Oct 18, 2006, 6:01 AM

Post #1 of 1 (4332 views)
Permalink
CVS: Products/Ape/lib/apelib/zodb3 - storage.py:1.18

Update of /cvs-repository/Products/Ape/lib/apelib/zodb3
In directory cvs.zope.org:/tmp/cvs-serv6816

Modified Files:
storage.py
Log Message:
fixed the hash64 function for 64 bit machines

the hash64 maps all hash result into an unsigned 32-bit integer which did break on 64bit machines because the python hash has doubled in size.


=== Products/Ape/lib/apelib/zodb3/storage.py 1.17 => 1.18 ===
--- Products/Ape/lib/apelib/zodb3/storage.py:1.17 Wed Jan 12 01:53:42 2005
+++ Products/Ape/lib/apelib/zodb3/storage.py Wed Oct 18 09:01:36 2006
@@ -87,10 +87,16 @@
def hash64(self, value):
"""Returns an 8-byte hash value.
"""
- v = hash(value)
- if v < 0:
+ if v < -2L ** 32:
+ v += 2L ** 64
+ elif v < 0:
# Treat the hash as an unsigned 32-bit integer
v += 2L ** 32
+ if v > 2L ** 32:
+ v = v / 2 ** 32
+
+ assert v >= 0 and v <= 2L ** 32
+
h = '%08x' % v
if h == HASH0:
# Avoid the special zero hash.

_______________________________________________
Zope-CVS maillist - Zope-CVS [at] zope
http://mail.zope.org/mailman/listinfo/zope-cvs

Zope CVS instructions: http://dev.zope.org/CVS

Zope cvs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.