2 * Copyright (C) 1994-1996, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.4 1996-11-08 11:10:21 adam
8 * Buffers used during file match got bigger.
9 * Compressed ISAM support everywhere.
10 * Bug fixes regarding masking characters in queries.
11 * Redesigned Regexp-2 queries.
13 * Revision 1.3 1996/06/04 10:18:58 adam
14 * Minor changes - removed include of ctype.h.
16 * Revision 1.2 1996/05/22 08:25:56 adam
19 * Revision 1.1 1996/05/14 14:04:34 adam
20 * In zebraidx, the 'stat' command is improved. Statistics about ISAM/DICT
31 struct inv_stat_info {
37 int isam_occurrences[20];
41 static int inv_stat_handle (char *name, const char *info, int pos,
46 struct inv_stat_info *stat_info = (struct inv_stat_info*) client;
49 stat_info->no_dict_entries++;
50 stat_info->no_dict_bytes += strlen(name);
52 assert (*info == sizeof(ISAM_P));
53 memcpy (&isam_p, info+1, sizeof(ISAM_P));
59 ispt = is_position (stat_info->isam, isam_p);
60 occur = is_numkeys (ispt);
69 pp = isc_pp_open (stat_info->isamc, isam_p);
70 occur = isc_pp_num (pp);
72 while (isc_pp_read(pp, buf))
74 assert (occurx == occur);
79 while (occur > stat_info->isam_bounds[i] && stat_info->isam_bounds[i])
81 ++(stat_info->isam_occurrences[i]);
86 void inv_prstat (void)
94 int after = 1000000000;
95 struct inv_stat_info stat_info;
96 char term_dict[2*IT_MAX_WORD+2];
101 dict = dict_open (FNAME_DICT, 100, 0);
104 logf (LOG_FATAL, "dict_open fail");
107 if (res_get_match (common_resource, "isam", "c", NULL))
109 isamc = isc_open (FNAME_ISAMC, 0, key_isamc_m ());
112 logf (LOG_FATAL, "isc_open fail");
118 isam = is_open (FNAME_ISAM, key_compare, 0, sizeof(struct it_key));
121 logf (LOG_FATAL, "is_open fail");
125 records = rec_open (0);
127 stat_info.no_dict_entries = 0;
128 stat_info.no_dict_bytes = 0;
129 stat_info.isam = isam;
130 stat_info.isamc = isamc;
131 stat_info.isam_bounds[0] = 1;
132 stat_info.isam_bounds[1] = 2;
133 stat_info.isam_bounds[2] = 3;
134 stat_info.isam_bounds[3] = 5;
135 stat_info.isam_bounds[4] = 10;
136 stat_info.isam_bounds[5] = 20;
137 stat_info.isam_bounds[6] = 30;
138 stat_info.isam_bounds[7] = 50;
139 stat_info.isam_bounds[8] = 100;
140 stat_info.isam_bounds[9] = 200;
141 stat_info.isam_bounds[10] = 5000;
142 stat_info.isam_bounds[11] = 10000;
143 stat_info.isam_bounds[12] = 20000;
144 stat_info.isam_bounds[13] = 50000;
145 stat_info.isam_bounds[14] = 100000;
146 stat_info.isam_bounds[15] = 200000;
147 stat_info.isam_bounds[16] = 500000;
148 stat_info.isam_bounds[17] = 1000000;
149 stat_info.isam_bounds[18] = 0;
151 for (i = 0; i<20; i++)
152 stat_info.isam_occurrences[i] = 0;
154 dict_scan (dict, term_dict, &before, &after, &stat_info, inv_stat_handle);
156 rec_close (&records);
163 fprintf (stderr, "%d dictionary entries. %d bytes for strings\n",
164 stat_info.no_dict_entries, stat_info.no_dict_bytes);
165 fprintf (stderr, " size occurrences\n");
167 for (i = 0; stat_info.isam_bounds[i]; i++)
169 int here = stat_info.isam_bounds[i];
170 fprintf (stderr, "%7d-%-7d %7d\n",
171 prev, here, stat_info.isam_occurrences[i]);
174 fprintf (stderr, "%7d- %7d\n",
175 prev, stat_info.isam_occurrences[i]);