2 * Copyright (C) 1994-1998, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.6 1998-03-06 13:54:02 adam
8 * Fixed two nasty bugs in isc_merge.
10 * Revision 1.5 1997/09/17 12:19:13 adam
11 * Zebra version corresponds to YAZ version 1.4.
12 * Changed Zebra server so that it doesn't depend on global common_resource.
14 * Revision 1.4 1996/11/08 11:10:21 adam
15 * Buffers used during file match got bigger.
16 * Compressed ISAM support everywhere.
17 * Bug fixes regarding masking characters in queries.
18 * Redesigned Regexp-2 queries.
20 * Revision 1.3 1996/06/04 10:18:58 adam
21 * Minor changes - removed include of ctype.h.
23 * Revision 1.2 1996/05/22 08:25:56 adam
26 * Revision 1.1 1996/05/14 14:04:34 adam
27 * In zebraidx, the 'stat' command is improved. Statistics about ISAM/DICT
38 struct inv_stat_info {
44 int isam_occurrences[20];
48 static int inv_stat_handle (char *name, const char *info, int pos,
53 struct inv_stat_info *stat_info = (struct inv_stat_info*) client;
56 stat_info->no_dict_entries++;
57 stat_info->no_dict_bytes += strlen(name);
59 assert (*info == sizeof(ISAM_P));
60 memcpy (&isam_p, info+1, sizeof(ISAM_P));
66 ispt = is_position (stat_info->isam, isam_p);
67 occur = is_numkeys (ispt);
76 pp = isc_pp_open (stat_info->isamc, isam_p);
77 occur = isc_pp_num (pp);
79 while (isc_pp_read(pp, buf))
81 assert (occurx == occur);
86 while (occur > stat_info->isam_bounds[i] && stat_info->isam_bounds[i])
88 ++(stat_info->isam_occurrences[i]);
93 void inv_prstat (BFiles bfs)
101 int after = 1000000000;
102 struct inv_stat_info stat_info;
103 char term_dict[2*IT_MAX_WORD+2];
108 dict = dict_open (bfs, FNAME_DICT, 100, 0);
111 logf (LOG_FATAL, "dict_open fail");
114 if (!res_get_match (common_resource, "isam", "i", NULL))
116 isamc = isc_open (bfs, FNAME_ISAMC, 0, key_isamc_m (common_resource));
119 logf (LOG_FATAL, "isc_open fail");
125 isam = is_open (bfs, FNAME_ISAM, key_compare, 0,
126 sizeof(struct it_key), common_resource);
129 logf (LOG_FATAL, "is_open fail");
133 records = rec_open (bfs, 0);
135 stat_info.no_dict_entries = 0;
136 stat_info.no_dict_bytes = 0;
137 stat_info.isam = isam;
138 stat_info.isamc = isamc;
139 stat_info.isam_bounds[0] = 1;
140 stat_info.isam_bounds[1] = 2;
141 stat_info.isam_bounds[2] = 3;
142 stat_info.isam_bounds[3] = 5;
143 stat_info.isam_bounds[4] = 10;
144 stat_info.isam_bounds[5] = 20;
145 stat_info.isam_bounds[6] = 30;
146 stat_info.isam_bounds[7] = 50;
147 stat_info.isam_bounds[8] = 100;
148 stat_info.isam_bounds[9] = 200;
149 stat_info.isam_bounds[10] = 5000;
150 stat_info.isam_bounds[11] = 10000;
151 stat_info.isam_bounds[12] = 20000;
152 stat_info.isam_bounds[13] = 50000;
153 stat_info.isam_bounds[14] = 100000;
154 stat_info.isam_bounds[15] = 200000;
155 stat_info.isam_bounds[16] = 500000;
156 stat_info.isam_bounds[17] = 1000000;
157 stat_info.isam_bounds[18] = 0;
159 for (i = 0; i<20; i++)
160 stat_info.isam_occurrences[i] = 0;
162 dict_scan (dict, term_dict, &before, &after, &stat_info, inv_stat_handle);
164 rec_close (&records);
171 fprintf (stderr, "%d dictionary entries. %d bytes for strings\n",
172 stat_info.no_dict_entries, stat_info.no_dict_bytes);
173 fprintf (stderr, " size occurrences\n");
175 for (i = 0; stat_info.isam_bounds[i]; i++)
177 int here = stat_info.isam_bounds[i];
178 fprintf (stderr, "%7d-%-7d %7d\n",
179 prev, here, stat_info.isam_occurrences[i]);
182 fprintf (stderr, "%7d- %7d\n",
183 prev, stat_info.isam_occurrences[i]);