How to use the mmh3.hash64 function in mmh3

To help you get started, we’ve selected a few mmh3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hajimes / mmh3 / test_mmh3.py View on Github external
def test_hash64():
    assert mmh3.hash64('foo') == (-2129773440516405919, 9128664383759220103)
    assert mmh3.hash64('foo', signed = False) == (16316970633193145697,
        9128664383759220103)
    # TODO
github mynameisfiber / fuggetaboutit / experiments / timing_bloom_filter_disk.py View on Github external
def _indexes(self, key):
        for i in xrange(self.num_hashes):
            h1, h2 = mmh3.hash64(key)
            yield (h1 + i * h2) % self.num_bytes_per_hash + i*self.num_bytes_per_hash
github mynameisfiber / fuggetaboutit / build / lib.macosx-10.7-intel-2.7 / fuggetaboutit / counting_bloom_filter.py View on Github external
def _indexes(self, key):
        """
        Generates the indicies corresponding to the given key
        """
        h1, h2 = mmh3.hash64(key)
        for i in xrange(self.num_hashes):
            yield (h1 + i * h2) % self.num_bytes
github mynameisfiber / countmemaybe / countmemaybe / bloomfilter.py View on Github external
def _idxiter(self, key):
        k1, k2 = mmh3.hash64(key)
        for i in range(self.N):
            idx = (k1 + i * k2) % self.size
            yield idx
github DataDog / integrations-core / datadog_checks_base / datadog_checks / base / utils / sql.py View on Github external
def compute_sql_signature(query):
    """
    Given a raw SQL query or prepared statement, generate a 64-bit hex signature
    on the normalized query.
    """
    normalized = datadog_agent.obfuscate_sql(query)
    return format(mmh3.hash64(normalized, signed=False)[0], 'x')
github DataDog / integrations-core / mysql / datadog_checks / mysql / sql.py View on Github external
def compute_exec_plan_signature(json_plan):
    """
    Given a query execution plan, generate a 64-bit hex signature on the normalized execution plan
    """
    if not json_plan:
        return None, None
    normalized_json = datadog_agent.obfuscate_sql_exec_plan(json_plan, normalize=True)
    with_sorted_keys = json.dumps(json.loads(normalized_json), sort_keys=True)
    return normalized_json, format(mmh3.hash64(with_sorted_keys, signed=False)[0], 'x')
github yunwilliamyu / hyperminhash / hyperminhash.py View on Github external
def triple_hash(self, item):
        '''Returns a triple i, val, aug hashed values, where i is bucketbits,
        val is the position of the leading one in a 64-bit integer, and aug is the bits
        to go in the subbuckets'''

        y, h2 = mmh3.hash64(str(item).encode())
        val = 64 + 1 - int(np.uint64(y)).bit_length()
        val = min(val, 2**self.bucketsize)

        h2prime = int(np.uint64(h2))
        i = h2prime >> self._bucketbit_shift
        aug = h2prime & self._bbit_mask

        return (i, val, aug)
github DataDog / integrations-core / postgres / datadog_checks / postgres / statements.py View on Github external
def compute_sql_signature(query):
    """
    Given a raw SQL query or prepared statement, generate a 64-bit hex signature
    on the normalized query.
    """
    normalized = datadog_agent.obfuscate_sql(query)
    return format(mmh3.hash64(normalized, signed=False)[0], 'x')
github Parsely / probably / probably / hashfunctions.py View on Github external
def hash64(key, seed):
    """
    Wrapper around mmh3.hash64 to get us single 64-bit value.

    This also does the extra work of ensuring that we always treat the
    returned values as big-endian unsigned long, like smhasher used to
    do.
    """
    hash_val = mmh3.hash64(key, seed)[0]
    return struct.unpack('>Q', struct.pack('q', hash_val))[0]

mmh3

Python extension for MurmurHash (MurmurHash3), a set of fast and robust hash functions.

MIT
Latest version published 2 months ago

Package Health Score

88 / 100
Full package analysis