MCPcopy Index your code
hub / github.com/apache/fory / hash_meta_string_data

Function hash_meta_string_data

python/pyfory/context.py:60–68  ·  view source on GitHub ↗
(data: bytes, encoding: int)

Source from the content-addressed store, hash-verified

58
59
60def hash_meta_string_data(data: bytes, encoding: int) -> int:
61 length = len(data)
62 if length <= SMALL_STRING_THRESHOLD:
63 padded = data + b"\x00" * (16 - length)
64 v1 = int.from_bytes(padded[:8], "little", signed=False)
65 v2 = int.from_bytes(padded[8:16], "little", signed=False)
66 return hash_small_metastring(v1, v2, length, encoding)
67 hashcode = mmh3.hash_buffer(data, seed=47)[0]
68 return (hashcode >> 8 << 8) | (encoding & 0xFF)
69
70
71class EncodedMetaString:

Callers 1

_read_big_meta_stringMethod · 0.85

Calls 2

hash_small_metastringFunction · 0.85
from_bytesMethod · 0.45

Tested by

no test coverage detected