13 int main(int argc, char **argv)
15 int num_buckets = atoi(argv[2]);
16 const char *hex_prefix = argv[3];
17 const int prefix_len = strlen(hex_prefix) / 2;
18 uint8_t *prefix = new uint8_t[prefix_len];
20 for (int i = 0; i < prefix_len; ++i) {
22 x[0] = hex_prefix[i * 2 + 0];
23 x[1] = hex_prefix[i * 2 + 1];
26 sscanf(x, "%02x", &k);
30 for (int i = 0; i < num_buckets; ++i) {
32 snprintf(filename, sizeof(filename), "%s.part%04d", argv[1], i);
34 mtbl_reader* mtbl = mtbl_reader_init(filename, NULL);
35 const mtbl_source *src = mtbl_reader_source(mtbl);
36 mtbl_iter *it = mtbl_source_get_prefix(src, prefix, prefix_len);
38 const uint8_t *key, *val;
39 size_t len_key, len_val;
41 while (mtbl_iter_next(it, &key, &len_key, &val, &len_val)) {
42 string move((char *)(key + prefix_len), len_key - prefix_len);
43 const Count* c = (Count *)val;
44 printf("%s %d %d %d %u %f %f %d %ld\n", move.c_str(),
45 c->white, c->draw, c->black, c->opening_num,
46 float(c->sum_white_elo) / c->num_elo,
47 float(c->sum_black_elo) / c->num_elo,
48 c->num_elo, c->first_timestamp);