Example #1
0
try:
  from hashlib import md5
except ImportError:
  from md5 import md5
import bisect
import sys

try:
  import pyhash
  hasher = pyhash.fnv1a_32()

  def fnv32a(string, seed=0x811c9dc5):
    return hasher(string, seed=seed)
except ImportError:
  def fnv32a(string, seed=0x811c9dc5):
    """
    FNV-1a Hash (http://isthe.com/chongo/tech/comp/fnv/) in Python.
    Taken from https://gist.github.com/vaiorabbit/5670985
    """
    hval = seed
    fnv_32_prime = 0x01000193
    uint32_max = 2 ** 32
    for s in string:
      hval = hval ^ ord(s)
      hval = (hval * fnv_32_prime) % uint32_max
    return hval


class ConsistentHashRing:
  def __init__(self, nodes, replica_count=100, hash_type='carbon_ch'):
    self.ring = []
Example #2
0
   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License."""

from hashlib import md5
from itertools import chain
import bisect

try:
    import pyhash

    hasher = pyhash.fnv1a_32()

    def fnv32a(string, seed=0x811C9DC5):
        return hasher(string, seed=seed)


except ImportError:

    def fnv32a(string, seed=0x811C9DC5):
        """
    FNV-1a Hash (http://isthe.com/chongo/tech/comp/fnv/) in Python.
    Taken from https://gist.github.com/vaiorabbit/5670985
    """
        hval = seed
        fnv_32_prime = 0x01000193
        uint32_max = 2 ** 32
import pyhash
import sys
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt

bloomFilterSize = 10
bit_vector = []

#hashFunctions
fnv = pyhash.fnv1a_32()
mur = pyhash.murmur3_32()
lookup = pyhash.lookup3()
super1 = pyhash.super_fast_hash()
city = pyhash.city_64()
spooky = pyhash.spooky_32()
farm = pyhash.farm_32()
metro = pyhash.metro_64()
mum = pyhash.mum_64()
xx = pyhash.xx_32()
#10 hash functions
hashfuncs = [fnv, mur, lookup, super1, city, spooky, farm, metro, mum, xx]
#hash


def insertBloom(kmer, hashFuncCount):
    global bloomFilterSize
    global bit_vector
    index = 0
    for hf in hashfuncs:
        if (index <= hashFuncCount):
            if (bit_vector[hf(kmer) % bloomFilterSize] == 0):