Original link: http://www.concentric.net/~Ttwang/tech/inthash.htm
Taken from: http://web.archive.org/web/20071223173210/http://www.concentric.net/~Ttwang/tech/inthash.htm
Reformatted using pandoc
Thomas Wang, Jan 1997
last update Mar 2007
| /* | |
| For any 1<k<=64, let mask=(1<<k)-1. hash_64() is a bijection on [0,1<<k), which means | |
| hash_64(x, mask)==hash_64(y, mask) if and only if x==y. hash_64i() is the inversion of | |
| hash_64(): hash_64i(hash_64(x, mask), mask) == hash_64(hash_64i(x, mask), mask) == x. | |
| */ | |
| // Thomas Wang's integer hash functions. See <https://gist.github.com/lh3/59882d6b96166dfc3d8d> for a snapshot. | |
| uint64_t hash_64(uint64_t key, uint64_t mask) | |
| { | |
| key = (~key + (key << 21)) & mask; // key = (key << 21) - key - 1; |
| ## Consumer Throughput: Single consumer thread, no compression | |
| ## Consumer Throughput: 3 consumer thread, no compression | |
| bin/kafka-consumer-perf-test.sh --topic benchmark-3-3-none \ | |
| --zookeeper kafka-zk-1:2181,kafka-zk-2:2181,kafka-zk-3:2181 \ | |
| --messages 15000000 \ | |
| --threads 1 |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>本地图片在线预览</title> | |
| </head> | |
| <body> | |
| <script type="text/javascript"> | |
| var result=document.getElementById("result"); | |
| var file=document.getElementById("file"); |
| // Package main go 语言模拟 shell 命令 `tree <DIR>` | |
| package main | |
| import ( | |
| "errors" | |
| "fmt" | |
| "io/ioutil" | |
| "os" | |
| "path/filepath" | |
| ) |
| package tmp | |
| import ( | |
| "fmt" | |
| "testing" | |
| ) | |
| // https://stackoverflow.com/questions/18709855/semi-reversible-integer-hash-please-keep-an-open-mind/18713986#18713986 | |
| // http://www.wolframalpha.com/input/?i=multiplicative+inverse+of+7+mod+100000000 | |
| func TestShuffle(t *testing.T) { |
| package tmp | |
| import ( | |
| "fmt" | |
| "math" | |
| "math/rand" | |
| "testing" | |
| "github.com/CardInfoLink/angrycard/util" | |
| ) |
Original link: http://www.concentric.net/~Ttwang/tech/inthash.htm
Taken from: http://web.archive.org/web/20071223173210/http://www.concentric.net/~Ttwang/tech/inthash.htm
Reformatted using pandoc
Thomas Wang, Jan 1997
last update Mar 2007