#define REPORT_MAX (1 << 0)
#define REPORT_MIN (1 << 1)
#define REPORT_ABSMAX (1 << 2)
+#define REPORT_AVG (1 << 3)
static void
report_absmax(const char *tag)
calc_height(nr_records, records_per_block);
}
+ if (report_what & REPORT_AVG) {
+ records_per_block[0] *= 3;
+ records_per_block[0] /= 4;
+ records_per_block[1] *= 3;
+ records_per_block[1] /= 4;
+
+ if (records_per_block[0] < 2) {
+ fprintf(stderr,
+_("%s: cannot calculate average case scenario due to leaf geometry underflow.\n"),
+ tag);
+ return;
+ }
+
+ if (records_per_block[1] < 4) {
+ fprintf(stderr,
+_("%s: cannot calculate average case scenario due to node geometry underflow.\n"),
+ tag);
+ return;
+ }
+
+ printf(
+_("%s: average case per %u-byte block: %u records (leaf) / %u keyptrs (node)\n"),
+ tag, blocksize, records_per_block[0],
+ records_per_block[1]);
+
+ calc_height(nr_records, records_per_block);
+ }
+
if (report_what & REPORT_MIN) {
records_per_block[0] /= 2;
records_per_block[1] /= 2;
report_what = REPORT_MAX;
else if (!strcmp(optarg, "absmax"))
report_what = REPORT_ABSMAX;
+ else if (!strcmp(optarg, "avg"))
+ report_what = REPORT_AVG;
else {
btheight_help();
return 0;
Dump all keys and pointers in intermediate btree nodes, and all records in leaf btree nodes.
.RE
.TP
-.BI "btheight [\-b " blksz "] [\-n " recs "] [\-w " max "|" min "|" absmax "] btree types..."
+.BI "btheight [\-b " blksz "] [\-n " recs "] [\-w " max "|" min "|" absmax "|" avg "] btree types..."
For a given number of btree records and a btree type, report the number of
records and blocks for each level of the btree, and the total number of blocks.
The btree type must be given after the options.
.B \-w min
shows only the worst case scenario, which is when the btree blocks are
half full.
+.TP
+.B \-w avg
+shows only the average case scenario, which is when the btree blocks are
+three quarters full.
.RE
.TP
.BI "convert " "type number" " [" "type number" "] ... " type