artakvg / cityhash

Automatically exported from code.google.com/p/cityhash
MIT License
0 stars 0 forks source link

Add CityHash32 #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice to have a 32-bit version for use in e.g. hash table 
implementations on 32-bit systems.

Original issue reported on code.google.com by tib...@google.com on 19 Apr 2011 at 8:05

GoogleCodeExporter commented 9 years ago
I'm able to run both CityHash64 and CityHash128 perfectly fine on my 32-bit 
system. (Actually, CityHash128 has the same amount of data as the de-facto md5, 
which returns 128-bit.)

Can you provide a more detailed use-case (or sample code) of what you're trying 
to do that the current code won't accommodate?

Original comment by eric.caron on 21 Apr 2011 at 5:48

GoogleCodeExporter commented 9 years ago
Can I take the higher (or lower) 32-bits and use them as a hash value? Is this 
expected to be as fast as if we implemented a CityHash32 directly?

Original comment by johan.ti...@gmail.com on 21 Apr 2011 at 8:24

GoogleCodeExporter commented 9 years ago
All the CityHash functions are tuned for 64-bit processors. That said, they 
will run (except for the new ones that use SSE4.2) in 32-bit code. They won't 
be very fast though. You may want to use Murmur or something else in 32-bit 
code.

As far as converting a "n-bit hash function" to a "m-bit hash function" where m 
< n, my understanding is that for any "good" hash function, you can simply 
discard n - m bits and keep m bits. For m= 32, all the CityHash variants should 
work fine with this method.

So, in short, it may make sense to create a CityHash32, but we're probably not 
going to do so.

Original comment by gp...@google.com on 29 Apr 2011 at 5:01

GoogleCodeExporter commented 9 years ago

Original comment by gp...@google.com on 20 Jun 2013 at 9:59