MCPcopy Create free account
hub / github.com/apache/arrow / generate_hash

Function generate_hash

cpp/src/parquet/chunker_internal_codegen.py:85–94  ·  view source on GitHub ↗

Produce predictable hash values for a given seed and n using MD5. The value can be arbitrary as long as it is deterministic and has a uniform distribution. The MD5 hash is used to produce a 16 character hexadecimal string which is then converted to a 64-bit integer.

(n: int, seed: int)

Source from the content-addressed store, hash-verified

83
84
85def generate_hash(n: int, seed: int):
86 """Produce predictable hash values for a given seed and n using MD5.
87
88 The value can be arbitrary as long as it is deterministic and has a uniform
89 distribution. The MD5 hash is used to produce a 16 character hexadecimal
90 string which is then converted to a 64-bit integer.
91 """
92 value = bytes([seed] * 64 + [n] * 64)
93 hasher = hashlib.md5(value)
94 return hasher.hexdigest()[:16]
95
96
97def generate_hashtable(seed: int, length=256):

Callers 1

generate_hashtableFunction · 0.85

Calls 1

bytesFunction · 0.85

Tested by

no test coverage detected