+ perc_i = 100.0 / (double)output_nranges;
+ perc = 0.0;
+
+ printf("\n Rows Hits %% Sum %% # Hits Size\n");
+ printf("-----------------------------------------------------------------------\n");
+ for (i = 0; i < output_nranges; i++) {
+ struct output_sum *os = &output_sums[i];
+ double gb = (double)os->nranges * block_size / 1024.0;
+ char p = 'K';
+
+ if (gb > 1024.0) {
+ p = 'M';
+ gb /= 1024.0;
+ }
+ if (gb > 1024.0) {
+ p = 'G';
+ gb /= 1024.0;
+ }
+
+ perc += perc_i;
+ hit_percent_sum += os->output;
+ hit_sum += os->nranges;
+ printf("%s %6.2f%%\t%6.2f%%\t\t%6.2f%%\t\t%8u\t%6.2f%c\n",
+ i ? "|->" : "Top", perc, os->output, hit_percent_sum,
+ os->nranges, gb, p);
+ }
+
+ printf("-----------------------------------------------------------------------\n");
+ printf("Total\t\t\t\t\t\t%8llu\n", hit_sum);
+ free(output_sums);
+}
+
+int main(int argc, char *argv[])
+{
+ unsigned long offset;
+ unsigned long long nranges;
+ unsigned long nnodes;
+ struct node *nodes;
+ struct zipf_state zs;
+ struct gauss_state gs;
+ int i, j;
+
+ if (parse_options(argc, argv))
+ return 1;
+
+ if (output_type != OUTPUT_CSV)
+ printf("Generating %s distribution with %f input and %lu GiB size and %lu block_size.\n",
+ dist_types[dist_type], dist_val, gib_size, block_size);
+
+ nranges = gib_size * 1024 * 1024 * 1024ULL;
+ nranges /= block_size;
+
+ if (dist_type == TYPE_ZIPF)
+ zipf_init(&zs, nranges, dist_val, 1);
+ else if (dist_type == TYPE_PARETO)
+ pareto_init(&zs, nranges, dist_val, 1);
+ else
+ gauss_init(&gs, nranges, dist_val, 1);
+
+ hash_bits = 0;
+ hash_size = nranges;
+ while ((hash_size >>= 1) != 0)
+ hash_bits++;
+
+ hash_size = 1 << hash_bits;
+
+ hash = calloc(hash_size, sizeof(struct flist_head));
+ for (i = 0; i < hash_size; i++)
+ INIT_FLIST_HEAD(&hash[i]);
+
+ nodes = malloc(nranges * sizeof(struct node));
+
+ for (i = j = 0; i < nranges; i++) {
+ struct node *n;
+
+ if (dist_type == TYPE_ZIPF)
+ offset = zipf_next(&zs);
+ else if (dist_type == TYPE_PARETO)
+ offset = pareto_next(&zs);
+ else
+ offset = gauss_next(&gs);
+
+ n = hash_lookup(offset);
+ if (n)
+ n->hits++;
+ else {
+ hash_insert(&nodes[j], offset);
+ j++;
+ }