ComputeMetaStringHash computes the hashcode for meta string bytes
(data []byte, encoding meta.Encoding)
| 269 | |
| 270 | // ComputeMetaStringHash computes the hashcode for meta string bytes |
| 271 | func 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 | |
| 291 | func (r *MetaStringResolver) ResetRead() { |
| 292 | r.dynamicIDToEnumString = nil |