Exemplo n.º 1
0
def _find_l2_hash_mul(cdict):
    """Similar to the _find_l1_phash_mul, but not looking for perfection, just
    well distributed stuff"""
    global _l1_bucket_max
    candidate_lengths = _find_candidate_lengths_mul(cdict.tuple2int)
    for p in candidate_lengths:
        hash_f = hashmul.hashmul_t(p)
        if xedhash.is_well_distributed(cdict.tuple2int, hash_f, _l1_bucket_max):
            return hash_f
        del hash_f
    return None
Exemplo n.º 2
0
def find_fks_well_distributed(keylist):
    """Return a hash well-distributed function (not necessarily perfect!)
       for a given key list"""
    global _max_k
    global _l1_bucket_max
    mlist = _get_l1_mlist(len(keylist)) # number of buckets
    for m in mlist:
        for p in _primes:
            for k in range(3, _max_k):
                hash_f = hash_fun_fks_t(k,p,m)
                if xedhash.is_well_distributed(keylist, hash_f, _l1_bucket_max):
                    return hash_f
                del hash_f
    return None