Skip to content

Commit

Permalink
Revert "Added binding for MurmurHash2 (#24)" (#31)
Browse files Browse the repository at this point in the history
This reverts commit d086eff.
  • Loading branch information
adrianeboyd authored Dec 15, 2021
1 parent 13f209c commit 7784bd1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion murmurhash/mrmr.pxd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from libc.stdint cimport uint64_t, int64_t, uint32_t


cdef uint32_t hash32(void* key, int length, uint32_t seed, int version) nogil
cdef uint32_t hash32(void* key, int length, uint32_t seed) nogil
cdef uint64_t hash64(void* key, int length, uint64_t seed) nogil
cdef uint64_t real_hash64(void* key, int length, uint64_t seed) nogil
cdef void hash128_x86(const void* key, int len, uint32_t seed, void* out) nogil
Expand Down
24 changes: 10 additions & 14 deletions murmurhash/mrmr.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from libc.stdint cimport uint64_t, int64_t, uint32_t, int32_t
from libc.stdint cimport uint64_t, int64_t, int32_t


cdef extern from "murmurhash/MurmurHash3.h":
Expand All @@ -9,15 +9,11 @@ cdef extern from "murmurhash/MurmurHash3.h":
cdef extern from "murmurhash/MurmurHash2.h":
uint64_t MurmurHash64A(void * key, int length, uint32_t seed) nogil
uint64_t MurmurHash64B(void * key, int length, uint32_t seed) nogil
uint32_t MurmurHash2(void * key, int length, uint32_t seed) nogil


cdef uint32_t hash32(void* key, int length, uint32_t seed, int version) nogil:
cdef uint32_t hash32(void* key, int length, uint32_t seed) nogil:
cdef int32_t out
if version==3:
MurmurHash3_x86_32(key, length, seed, &out)
else:
out = MurmurHash2(key, length, seed)
MurmurHash3_x86_32(key, length, seed, &out)
return out


Expand All @@ -38,17 +34,17 @@ cdef void hash128_x64(const void* key, int length, uint32_t seed, void* out) nog
MurmurHash3_x64_128(key, length, seed, out)


cpdef int32_t hash(value, uint32_t seed=0, murmur_version=3):
cpdef int32_t hash(value, uint32_t seed=0):
if isinstance(value, unicode):
return hash_unicode(value, seed=seed, murmur_version=murmur_version)
return hash_unicode(value, seed=seed)
else:
return hash_bytes(value, seed=seed, murmur_version=murmur_version)
return hash_bytes(value, seed=seed)


cpdef int32_t hash_unicode(unicode value, uint32_t seed=0, murmur_version=3):
return hash_bytes(value.encode('utf8'), seed=seed, murmur_version=murmur_version)
cpdef int32_t hash_unicode(unicode value, uint32_t seed=0):
return hash_bytes(value.encode('utf8'), seed=seed)


cpdef int32_t hash_bytes(bytes value, uint32_t seed=0, murmur_version=3):
cpdef int32_t hash_bytes(bytes value, uint32_t seed=0):
cdef char* chars = <char*>value
return hash32(chars, len(value), seed, murmur_version)
return hash32(chars, len(value), seed)

0 comments on commit 7784bd1

Please sign in to comment.