2 * Copyright (C) 1994-1996, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.3 1996-06-04 10:18:58 adam
8 * Minor changes - removed include of ctype.h.
10 * Revision 1.2 1996/05/22 08:25:56 adam
13 * Revision 1.1 1996/05/14 14:04:34 adam
14 * In zebraidx, the 'stat' command is improved. Statistics about ISAM/DICT
25 struct inv_stat_info {
30 int isam_occurrences[20];
34 static int inv_stat_handle (char *name, const char *info, int pos,
39 struct inv_stat_info *stat_info = (struct inv_stat_info*) client;
43 stat_info->no_dict_entries++;
44 stat_info->no_dict_bytes += strlen(name);
46 assert (*info == sizeof(ISAM_P));
47 memcpy (&isam_p, info+1, sizeof(ISAM_P));
49 ispt = is_position (stat_info->isam, isam_p);
51 occur = is_numkeys (ispt);
55 while (occur > stat_info->isam_bounds[i] && stat_info->isam_bounds[i])
57 ++(stat_info->isam_occurrences[i]);
62 void inv_prstat (const char *dict_fname, const char *isam_fname)
69 int after = 1000000000;
70 struct inv_stat_info stat_info;
71 char term_dict[2*IT_MAX_WORD+2];
76 dict = dict_open (dict_fname, 100, 0);
79 logf (LOG_FATAL, "dict_open fail of `%s'", dict_fname);
82 isam = is_open (isam_fname, key_compare, 0, sizeof(struct it_key));
85 logf (LOG_FATAL, "is_open fail of `%s'", isam_fname);
88 records = rec_open (0);
90 stat_info.no_dict_entries = 0;
91 stat_info.no_dict_bytes = 0;
92 stat_info.isam = isam;
93 stat_info.isam_bounds[0] = 1;
94 stat_info.isam_bounds[1] = 2;
95 stat_info.isam_bounds[2] = 3;
96 stat_info.isam_bounds[3] = 5;
97 stat_info.isam_bounds[4] = 10;
98 stat_info.isam_bounds[5] = 20;
99 stat_info.isam_bounds[6] = 30;
100 stat_info.isam_bounds[7] = 50;
101 stat_info.isam_bounds[8] = 100;
102 stat_info.isam_bounds[9] = 200;
103 stat_info.isam_bounds[10] = 5000;
104 stat_info.isam_bounds[11] = 10000;
105 stat_info.isam_bounds[12] = 20000;
106 stat_info.isam_bounds[13] = 50000;
107 stat_info.isam_bounds[14] = 100000;
108 stat_info.isam_bounds[15] = 200000;
109 stat_info.isam_bounds[16] = 500000;
110 stat_info.isam_bounds[17] = 1000000;
111 stat_info.isam_bounds[18] = 0;
113 for (i = 0; i<20; i++)
114 stat_info.isam_occurrences[i] = 0;
116 dict_scan (dict, term_dict, &before, &after, &stat_info, inv_stat_handle);
118 rec_close (&records);
122 fprintf (stderr, "%d dictionary entries. %d bytes for strings\n",
123 stat_info.no_dict_entries, stat_info.no_dict_bytes);
124 fprintf (stderr, " size occurrences\n");
126 for (i = 0; stat_info.isam_bounds[i]; i++)
128 int here = stat_info.isam_bounds[i];
129 fprintf (stderr, "%7d-%-7d %7d\n",
130 prev, here, stat_info.isam_occurrences[i]);
133 fprintf (stderr, "%7d- %7d\n",
134 prev, stat_info.isam_occurrences[i]);