// hashSlot returns a consistent slot number between 0 and 16383
// for any given string key.
762929
func Slot(key string) int {
	if key == "" {
		return RandomSlot()
	}
	key = Key(key)
	return int(crc16sum(key)) % slotNumber
}
548213
func hashString(s string) uint32 {
	if len(s) >= 12 {
		// Call the Go runtime's optimized hash implementation,
		// which uses the AESENC instruction on amd64 machines.
		return uint32(goStringHash(s, 0))
	}
	return softHashString(s)
}
344646
func (mmap MarshalMap) Int64Slice(key string) ([]int64, error) {
	return mmap.Int64Array(key)
}
84661
func (s *CustomCodeSigning) SetHashAlgorithm(v string) *CustomCodeSigning {
	s.HashAlgorithm = &v
	return s
}
686816
func bulkHash4(b []byte, dst []uint32) {
	if len(b) < minMatchLength {
		return
	}
	hb := uint32(b[3]) | uint32(b[2])<<8 | uint32(b[1])<<16 | uint32(b[0])<<24
	dst[0] = (hb * hashmul) >> (32 - hashBits)
	end := len(b) - minMatchLength + 1
	for i := 1; i < end; i++ {
		hb = (hb << 8) | uint32(b[i+3])
		dst[i] = (hb * hashmul) >> (32 - hashBits)
	}
}
98218
func HashFromString(dataStr string) (Hash, error) {
	data, err := hex.DecodeString(dataStr)
	if err != nil {
		return Hash{}, errors.WithStack(err)
	}
	return HashFromBytes(data)
}
926104
func (b *builtinSHA1Sig) evalString(row chunk.Row) (string, bool, error) {
	str, isNull, err := b.args[0].EvalString(b.ctx, row)
	if isNull || err != nil {
		return "", isNull, err
	}
	hasher := sha1.New()
	_, err = hasher.Write([]byte(str))
	if err != nil {
		return "", true, err
	}
	return fmt.Sprintf("%x", hasher.Sum(nil)), false, nil
}
351891
func HashKey(key []byte) int64 {
	h := int64(xxhash.Sum64(key))
	if h == 0 {
		h = 1
	} else if h < 0 {
		h = 0 - h
	}
	return h
}
500308
func HashTo(v Value, p []byte) {
	h := hashPool.Get().(hash.Hash)
	h.Reset()
	defer hashPool.Put(h)
	if len(p) < HashSize {
		panic("buffer too small to fit the hash")
	}
	if v != nil {
		// TODO(kortschak,dennwc) Remove dependence on String() method.
		h.Write([]byte(v.String()))
	}
	h.Sum(p[:0])
}
321303
func (db *DB) HSet(key []byte, field []byte, value []byte) (int64, error) {
	if err := checkHashKFSize(key, field); err != nil {
		return 0, err
	} else if err := checkValueSize(value); err != nil {
		return 0, err
	}

	t := db.hashBatch
	t.Lock()
	defer t.Unlock()

	n, err := db.hSetItem(key, field, value)
	if err != nil {
		return 0, err
	}

	err = t.Commit()
	return n, err
}
587267
func (a *ACLToken) SetHash() []byte {
	// Initialize a 256bit Blake2 hash (32 bytes)
	hash, err := blake2b.New256(nil)
	if err != nil {
		panic(err)
	}

	// Write all the user set fields
	hash.Write([]byte(a.Name))
	hash.Write([]byte(a.Type))
	for _, policyName := range a.Policies {
		hash.Write([]byte(policyName))
	}
	if a.Global {
		hash.Write([]byte("global"))
	} else {
		hash.Write([]byte("local"))
	}

	// Finalize the hash
	hashVal := hash.Sum(nil)

	// Set and return the hash
	a.Hash = hashVal
	return hashVal
}
1237222
func (h Hash) Len() int {
	ret := len(h)
	for _, c := range h {
		if c == 0 {
			ret--
		} else {
			break
		}
	}
	return ret
}
363577
func (auth *Auth) SetHash(h hash.Hash) {
	h.Write([]byte("\n"))
	auth.Hash = h.Sum(nil)
	auth.ReqHash = false
}
1277004
func LvlInt(s string) int {
	for i, str := range levels {
		if strings.TrimSpace(str) == strings.ToUpper(s) {
			return i
		}
	}
	return 0
}
133511
func (s *DynamoDBAction) SetHashKeyValue(v string) *DynamoDBAction {
	s.HashKeyValue = &v
	return s
}
988811
func HashString(input string) uint32 {

	hash := seed
	len := len(input)

	// step through the string 4 bytes at a time
	for i := 3; i < len; i += 4 {
		key := uint32(input[i-3]) | uint32(input[i-2]<<8) | uint32(input[i-1]<<16) | uint32(input[i]<<24)
		key = MixKey(key)
		hash = MixHash(hash, key)
	}

	// deal with remaining characters

	if len != 0 {
		var key uint32
		switch len % 4 {
		case 1:
			key = uint32(input[len-1])
		case 2:
			key = uint32(input[len-2]) | uint32(input[len-1]<<8)
		case 3:
			key = uint32(input[len-3]) | uint32(input[len-2]<<8) | uint32(input[len-1]<<16)
		}
		key = MixKey(key)
		hash = MixHash(hash, key)
	}

	return Finalize(hash, int32(len))
}
448136
func (db *RedisDB) HSet(k, f, v string) {
	db.master.Lock()
	defer db.master.Unlock()
	db.hashSet(k, f, v)
}