Documentation
¶
Overview ¶
Package city implements CityHash in go.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CH64 ¶ added in v0.2.0
CH64 returns ClickHouse version of Hash64.
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)) }
Output: ClickHouse: 12507901496292878638 CityHash: 5992710078453357409
func Hash32 ¶
Hash32 return 32-bit hash.
Example ¶
package main import ( "fmt" "github.com/go-faster/city" ) func main() { s := []byte("hello") hash32 := city.Hash32(s) fmt.Printf("the 32-bit hash of 'hello' is: %#x\n", hash32) }
Output: the 32-bit hash of 'hello' is: 0x79969366
func Hash64 ¶
Hash64 return a 64-bit hash.
Example ¶
package main import ( "fmt" "github.com/go-faster/city" ) func main() { s := []byte("hello") hash64 := city.Hash64(s) fmt.Printf("the 64-bit hash of 'hello' is: %#x\n", hash64) }
Output: the 64-bit hash of 'hello' is: 0xb48be5a931380ce8
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 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.
Example ¶
package main import ( "fmt" "github.com/go-faster/city" ) func main() { fmt.Println(city.Hash128([]byte("hello"))) }
Output: {8030732511675000650 7283604105673962311}
func Hash128Seed ¶
Hash128Seed return a 128-bit hash with a seed.
Click to show internal directories.
Click to hide internal directories.