-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats.c
50 lines (43 loc) · 1.1 KB
/
stats.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// stats.c ... show statistics for a Relation
// part of signature indexed files
// Show info and page stats for a Relation
// Usage: ./stats RelName
#include "defs.h"
#include "reln.h"
#include "page.h"
#include "tsig.h"
#define USAGE "./stats RelName"
// Main ... process args, run query
int main(int argc, char **argv)
{
// process command-line args
if (argc < 2) fatal(USAGE, "");
char *relname = argv[1];
// open relation and show stats
Reln r = openRelation(relname);
if (r == NULL) fatal(USAGE,"No such relation");
relationStats(r);
#if 0
int pid, nP; Page p;
// useful for sanity-checking contents of pages
nP = nPages(r);
printf("\nData Pages [pid]:#tups");
for (pid = 0; pid < nP; pid++) {
if (pid%6 == 0) putchar('\n');
p = getPage(dataFile(r), pid);
printf(" [%02d]:%3d", pid, pageNitems(p));
free(p);
}
printf("\nTsig Pages [pid]:#sigs");
nP = nTsigPages(r);
for (pid = 0; pid < nP; pid++) {
if (pid%6 == 0) putchar('\n');
p = getPage(tsigFile(r), pid);
printf(" [%02d]:%3d", pid, pageNitems(p));
free(p);
}
putchar('\n');
#endif
closeRelation(r);
return 0;
}