MCPcopy Create free account
hub / github.com/apache/fory / ComputeMetaStringHash

Function ComputeMetaStringHash

go/fory/meta_string_resolver.go:271–289  ·  view source on GitHub ↗

ComputeMetaStringHash computes the hashcode for meta string bytes

(data []byte, encoding meta.Encoding)

Source from the content-addressed store, hash-verified

269
270// ComputeMetaStringHash computes the hashcode for meta string bytes
271func ComputeMetaStringHash(data []byte, encoding meta.Encoding) int64 {
272 length := len(data)
273 var hashcode int64
274
275 if length == 0 {
276 hashcode = 256
277 hashcode |= int64(encoding)
278 } else if length <= SmallStringThreshold {
279 // Small string: use direct bytes as hash components
280 words := smallMetaStringWords(data)
281 hashcode = computeSmallMetaStringHash(words, length, encoding)
282 } else {
283 // Large string: use MurmurHash3
284 h64 := Murmur3Sum64WithSeed(data, 47)
285 hashcode = int64((h64 >> 8) << 8)
286 hashcode |= int64(encoding)
287 }
288 return hashcode
289}
290
291func (r *MetaStringResolver) ResetRead() {
292 r.dynamicIDToEnumString = nil

Calls 4

smallMetaStringWordsFunction · 0.85
Murmur3Sum64WithSeedFunction · 0.85
int64Function · 0.50