13 using namespace impala;
16 int main(
int argc,
char **argv) {
17 google::InitGoogleLogging(argv[0]);
20 int num_buckets1 = 16;
21 int num_buckets2 = 1024;
22 int num_values = num_buckets1 * num_buckets2;
24 int num_collisions1 = 0;
25 int num_collisions2 = 0;
26 int num_empty2 = num_buckets2;
27 vector<bool> buckets1;
28 vector<bool> buckets2;
29 buckets1.resize(num_buckets1);
30 buckets2.resize(num_buckets2);
33 for (
int i = 0; i < num_values; ++i) {
36 uint32_t bucket1_idx = hash1 % num_buckets1;
37 if (buckets1[bucket1_idx]) ++num_collisions1;
38 buckets1[bucket1_idx] =
true;
40 LOG(ERROR) << i <<
":" << hash1 <<
":" << hash2;
42 if (bucket1_idx == 0) {
43 uint32_t bucket2_idx = hash2 % num_buckets2;
44 if (buckets2[bucket2_idx]) {
47 buckets2[bucket2_idx] =
true;
53 LOG(ERROR) <<
"Same hash:" << endl
54 <<
" Bucket 1 Collisions: " << num_collisions1 << endl
55 <<
" Expected 1 Collisions: " << num_values - num_buckets1 << endl
56 <<
" Bucket 2 Collisions: " << num_collisions2 << endl
57 <<
" Bucket 2 Empties: " << num_empty2 << endl
58 <<
" Bucket 2 Total Values: " << num_values / num_buckets1;
static uint32_t Hash(const void *data, int32_t bytes, uint32_t seed)
int main(int argc, char **argv)
static void Init()
Initialize CpuInfo.