This commit is contained in:
parent
679ac6a774
commit
1f63d1788c
@ -120,33 +120,31 @@ class BloomFilter():
|
|||||||
Fowler/Noll/Vo hashing.
|
Fowler/Noll/Vo hashing.
|
||||||
"""
|
"""
|
||||||
n = len(v)
|
n = len(v)
|
||||||
a = np.int32(2166136261)
|
a = 2166136261
|
||||||
i = 0
|
i = 0
|
||||||
while i < n:
|
while i < n:
|
||||||
c = np.int32(ord(v[i]))
|
c = ord(v[i])
|
||||||
d = np.int32(c) & np.int32(0xff000000)
|
d = c & 0xff000000
|
||||||
if d:
|
if d:
|
||||||
a ^= np.int32(d >> 24)
|
a ^= d >> 24
|
||||||
a += np.int32((a << 1) + (a << 4) + (a << 7) + (a << 8) + (a << 24))
|
a += (a << 1) + (a << 4) + (a << 7) + (a << 8) + (a << 24)
|
||||||
d = c & np.int32(0xff0000)
|
d = c & 0xff0000
|
||||||
if d:
|
if d:
|
||||||
a ^= np.int32(d >> 16)
|
a ^= d >> 16
|
||||||
a += np.int32((a << 1) + (a << 4) + (a << 7) + (a << 8) + (a << 24))
|
a += (a << 1) + (a << 4) + (a << 7) + (a << 8) + (a << 24)
|
||||||
d = c & np.int32(0xff00)
|
d = c & 0xff00
|
||||||
if d:
|
if d:
|
||||||
a ^= np.int32(d >> 8)
|
a ^= d >> 8
|
||||||
a += np.int32((a << 1) + (a << 4) + (a << 7) + (a << 8) + (a << 24))
|
a += (a << 1) + (a << 4) + (a << 7) + (a << 8) + (a << 24)
|
||||||
a ^= np.int32(c & 0xff)
|
a ^= c & 0xff
|
||||||
a += np.int32((a << 1) + (a << 4) + (a << 7) + (a << 8) + (a << 24))
|
a += (a << 1) + (a << 4) + (a << 7) + (a << 8) + (a << 24)
|
||||||
print(a)
|
|
||||||
i += 1
|
i += 1
|
||||||
# From http://home.comcast.net/~bretm/hash/6.html
|
# From http://home.comcast.net/~bretm/hash/6.html
|
||||||
a += np.int32(a << 13)
|
a += a << 13
|
||||||
a ^= np.int32(a >> 7)
|
a ^= a >> 7
|
||||||
a += np.int32(a << 3)
|
a += a << 3
|
||||||
a ^= np.int32(a >> 17)
|
a ^= a >> 17
|
||||||
a += np.int32(a << 5)
|
a += a << 5
|
||||||
print(a)
|
|
||||||
return a & 0xffffffff
|
return a & 0xffffffff
|
||||||
|
|
||||||
def fnv_1a_b(self, a):
|
def fnv_1a_b(self, a):
|
||||||
|
@ -134,7 +134,6 @@
|
|||||||
}
|
}
|
||||||
a ^= c & 0xff;
|
a ^= c & 0xff;
|
||||||
a += (a << 1) + (a << 4) + (a << 7) + (a << 8) + (a << 24);
|
a += (a << 1) + (a << 4) + (a << 7) + (a << 8) + (a << 24);
|
||||||
console.log(a);
|
|
||||||
}
|
}
|
||||||
// From http://home.comcast.net/~bretm/hash/6.html
|
// From http://home.comcast.net/~bretm/hash/6.html
|
||||||
a += a << 13;
|
a += a << 13;
|
||||||
|
Loading…
Reference in New Issue
Block a user