package city
import "github.com/go-faster/city"
Package city implements CityHash in go.
Index ¶
- func CH64(s []byte) uint64
- func Hash32(s []byte) uint32
- func Hash64(s []byte) uint64
- func Hash64WithSeed(s []byte, seed uint64) uint64
- func Hash64WithSeeds(s []byte, seed0, seed1 uint64) uint64
- type U128
Examples ¶
Functions ¶
func CH64 ¶
CH64 returns ClickHouse version of Hash64.
Code:play
Output:Example¶
package main
import (
"fmt"
"github.com/go-faster/city"
)
func main() {
// See https://github.com/ClickHouse/ClickHouse/issues/8354
/*
SELECT cityHash64('Moscow')
┌─cityHash64('Moscow')─┐
│ 12507901496292878638 │
└──────────────────────┘
SELECT farmHash64('Moscow')
┌─farmHash64('Moscow')─┐
│ 5992710078453357409 │
└──────────────────────┘
*/
s := []byte("Moscow")
fmt.Print("ClickHouse: ")
fmt.Println(city.CH64(s))
fmt.Print("CityHash: ")
fmt.Println(city.Hash64(s))
}
ClickHouse: 12507901496292878638
CityHash: 5992710078453357409
func Hash32 ¶
Hash32 return 32-bit hash.
func Hash64 ¶
Hash64 return a 64-bit hash.
func Hash64WithSeed ¶
Hash64WithSeed return a 64-bit hash with a seed.
func Hash64WithSeeds ¶
Hash64WithSeeds return a 64-bit hash with two seeds.
Types ¶
type U128 ¶
U128 is uint128.
func CH128 ¶
CH128 returns 128-bit ClickHouse CityHash.
func CH128Seed ¶
CH128Seed returns 128-bit seeded ClickHouse CityHash.
func Hash128 ¶
Hash128 returns a 128-bit hash and are tuned for strings of at least a few hundred bytes. Depending on your compiler and hardware, it's likely faster than Hash64() on sufficiently long strings. It's slower than necessary on shorter strings, but we expect that case to be relatively unimportant.
func Hash128Seed ¶
Hash128Seed return a 128-bit hash with a seed.
Source Files ¶
128.go 32.go 64.go ch_128.go ch_64.go doc.go
Directories ¶
Path | Synopsis |
---|---|
internal |
- Version
- v0.6.0
- Published
- Dec 24, 2021
- Platform
- js/wasm
- Imports
- 1 packages
- Last checked
- now –
Tools for package owners.