2 * Copyright (C) 1994-1996, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.2 1996-05-22 08:25:56 adam
10 * Revision 1.1 1996/05/14 14:04:34 adam
11 * In zebraidx, the 'stat' command is improved. Statistics about ISAM/DICT
23 struct inv_stat_info {
28 int isam_occurrences[20];
32 static int inv_stat_handle (char *name, const char *info, int pos,
37 struct inv_stat_info *stat_info = (struct inv_stat_info*) client;
41 stat_info->no_dict_entries++;
42 stat_info->no_dict_bytes += strlen(name);
44 assert (*info == sizeof(ISAM_P));
45 memcpy (&isam_p, info+1, sizeof(ISAM_P));
47 ispt = is_position (stat_info->isam, isam_p);
49 occur = is_numkeys (ispt);
53 while (occur > stat_info->isam_bounds[i] && stat_info->isam_bounds[i])
55 ++(stat_info->isam_occurrences[i]);
60 void inv_prstat (const char *dict_fname, const char *isam_fname)
67 int after = 1000000000;
68 struct inv_stat_info stat_info;
69 char term_dict[2*IT_MAX_WORD+2];
74 dict = dict_open (dict_fname, 100, 0);
77 logf (LOG_FATAL, "dict_open fail of `%s'", dict_fname);
80 isam = is_open (isam_fname, key_compare, 0, sizeof(struct it_key));
83 logf (LOG_FATAL, "is_open fail of `%s'", isam_fname);
86 records = rec_open (0);
88 stat_info.no_dict_entries = 0;
89 stat_info.no_dict_bytes = 0;
90 stat_info.isam = isam;
91 stat_info.isam_bounds[0] = 1;
92 stat_info.isam_bounds[1] = 2;
93 stat_info.isam_bounds[2] = 3;
94 stat_info.isam_bounds[3] = 5;
95 stat_info.isam_bounds[4] = 10;
96 stat_info.isam_bounds[5] = 20;
97 stat_info.isam_bounds[6] = 30;
98 stat_info.isam_bounds[7] = 50;
99 stat_info.isam_bounds[8] = 100;
100 stat_info.isam_bounds[9] = 200;
101 stat_info.isam_bounds[10] = 5000;
102 stat_info.isam_bounds[11] = 10000;
103 stat_info.isam_bounds[12] = 20000;
104 stat_info.isam_bounds[13] = 50000;
105 stat_info.isam_bounds[14] = 100000;
106 stat_info.isam_bounds[15] = 200000;
107 stat_info.isam_bounds[16] = 500000;
108 stat_info.isam_bounds[17] = 1000000;
109 stat_info.isam_bounds[18] = 0;
111 for (i = 0; i<20; i++)
112 stat_info.isam_occurrences[i] = 0;
114 dict_scan (dict, term_dict, &before, &after, &stat_info, inv_stat_handle);
116 rec_close (&records);
120 fprintf (stderr, "%d dictionary entries. %d bytes for strings\n",
121 stat_info.no_dict_entries, stat_info.no_dict_bytes);
122 fprintf (stderr, " size occurrences\n");
124 for (i = 0; stat_info.isam_bounds[i]; i++)
126 int here = stat_info.isam_bounds[i];
127 fprintf (stderr, "%7d-%-7d %7d\n",
128 prev, here, stat_info.isam_occurrences[i]);
131 fprintf (stderr, "%7d- %7d\n",
132 prev, stat_info.isam_occurrences[i]);