2 * Copyright (C) 1994-1997, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.5 1997-09-17 12:19:13 adam
8 * Zebra version corresponds to YAZ version 1.4.
9 * Changed Zebra server so that it doesn't depend on global common_resource.
11 * Revision 1.4 1996/11/08 11:10:21 adam
12 * Buffers used during file match got bigger.
13 * Compressed ISAM support everywhere.
14 * Bug fixes regarding masking characters in queries.
15 * Redesigned Regexp-2 queries.
17 * Revision 1.3 1996/06/04 10:18:58 adam
18 * Minor changes - removed include of ctype.h.
20 * Revision 1.2 1996/05/22 08:25:56 adam
23 * Revision 1.1 1996/05/14 14:04:34 adam
24 * In zebraidx, the 'stat' command is improved. Statistics about ISAM/DICT
35 struct inv_stat_info {
41 int isam_occurrences[20];
45 static int inv_stat_handle (char *name, const char *info, int pos,
50 struct inv_stat_info *stat_info = (struct inv_stat_info*) client;
53 stat_info->no_dict_entries++;
54 stat_info->no_dict_bytes += strlen(name);
56 assert (*info == sizeof(ISAM_P));
57 memcpy (&isam_p, info+1, sizeof(ISAM_P));
63 ispt = is_position (stat_info->isam, isam_p);
64 occur = is_numkeys (ispt);
73 pp = isc_pp_open (stat_info->isamc, isam_p);
74 occur = isc_pp_num (pp);
76 while (isc_pp_read(pp, buf))
78 assert (occurx == occur);
83 while (occur > stat_info->isam_bounds[i] && stat_info->isam_bounds[i])
85 ++(stat_info->isam_occurrences[i]);
90 void inv_prstat (BFiles bfs)
98 int after = 1000000000;
99 struct inv_stat_info stat_info;
100 char term_dict[2*IT_MAX_WORD+2];
105 dict = dict_open (bfs, FNAME_DICT, 100, 0);
108 logf (LOG_FATAL, "dict_open fail");
111 if (res_get_match (common_resource, "isam", "c", NULL))
113 isamc = isc_open (bfs, FNAME_ISAMC, 0, key_isamc_m (common_resource));
116 logf (LOG_FATAL, "isc_open fail");
122 isam = is_open (bfs, FNAME_ISAM, key_compare, 0,
123 sizeof(struct it_key), common_resource);
126 logf (LOG_FATAL, "is_open fail");
130 records = rec_open (bfs, 0);
132 stat_info.no_dict_entries = 0;
133 stat_info.no_dict_bytes = 0;
134 stat_info.isam = isam;
135 stat_info.isamc = isamc;
136 stat_info.isam_bounds[0] = 1;
137 stat_info.isam_bounds[1] = 2;
138 stat_info.isam_bounds[2] = 3;
139 stat_info.isam_bounds[3] = 5;
140 stat_info.isam_bounds[4] = 10;
141 stat_info.isam_bounds[5] = 20;
142 stat_info.isam_bounds[6] = 30;
143 stat_info.isam_bounds[7] = 50;
144 stat_info.isam_bounds[8] = 100;
145 stat_info.isam_bounds[9] = 200;
146 stat_info.isam_bounds[10] = 5000;
147 stat_info.isam_bounds[11] = 10000;
148 stat_info.isam_bounds[12] = 20000;
149 stat_info.isam_bounds[13] = 50000;
150 stat_info.isam_bounds[14] = 100000;
151 stat_info.isam_bounds[15] = 200000;
152 stat_info.isam_bounds[16] = 500000;
153 stat_info.isam_bounds[17] = 1000000;
154 stat_info.isam_bounds[18] = 0;
156 for (i = 0; i<20; i++)
157 stat_info.isam_occurrences[i] = 0;
159 dict_scan (dict, term_dict, &before, &after, &stat_info, inv_stat_handle);
161 rec_close (&records);
168 fprintf (stderr, "%d dictionary entries. %d bytes for strings\n",
169 stat_info.no_dict_entries, stat_info.no_dict_bytes);
170 fprintf (stderr, " size occurrences\n");
172 for (i = 0; stat_info.isam_bounds[i]; i++)
174 int here = stat_info.isam_bounds[i];
175 fprintf (stderr, "%7d-%-7d %7d\n",
176 prev, here, stat_info.isam_occurrences[i]);
179 fprintf (stderr, "%7d- %7d\n",
180 prev, stat_info.isam_occurrences[i]);