Adding isamh stuff
[idzebra-moved-to-github.git] / index / kinput.c
1 /*
2  * Copyright (C) 1994-1999, Index Data
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss, Heikki Levanto
5  *
6  * (log at the end)
7  
8  */
9  
10 #include <fcntl.h>
11 #ifdef WIN32
12 #include <io.h>
13 #else
14 #include <unistd.h>
15 #endif
16 #include <stdlib.h>
17 #include <string.h>
18 #include <stdio.h>
19 #include <assert.h>
20
21 #include "index.h"
22
23 #define KEY_SIZE (1+sizeof(struct it_key))
24 #define INP_NAME_MAX 768
25 #define INP_BUF_START 60000
26 #define INP_BUF_ADD  400000
27
28 static int no_diffs   = 0;
29 static int no_updates = 0;
30 static int no_deletions = 0;
31 static int no_insertions = 0;
32 static int no_iterations = 0;
33
34 struct key_file {
35     int   no;            /* file no */
36     off_t offset;        /* file offset */
37     unsigned char *buf;  /* buffer block */
38     size_t buf_size;     /* number of read bytes in block */
39     size_t chunk;        /* number of bytes allocated */
40     size_t buf_ptr;      /* current position in buffer */
41     char *prev_name;     /* last word read */
42     int   sysno;         /* last sysno */
43     int   seqno;         /* last seqno */
44     off_t length;        /* length of file */
45                          /* handler invoked in each read */
46     void (*readHandler)(struct key_file *keyp, void *rinfo);
47     void *readInfo;
48 };
49
50 void getFnameTmp (char *fname, int no)
51 {
52     const char *pre;
53     
54     pre = res_get_def (common_resource, "keyTmpDir", ".");
55     sprintf (fname, "%s/key%d.tmp", pre, no);
56 }
57
58 void key_file_chunk_read (struct key_file *f)
59 {
60     int nr = 0, r = 0, fd;
61     char fname[1024];
62     getFnameTmp (fname, f->no);
63     fd = open (fname, O_BINARY|O_RDONLY);
64     if (fd == -1)
65     {
66         logf (LOG_FATAL|LOG_ERRNO, "cannot open %s", fname);
67         exit (1);
68     }
69     if (!f->length)
70     {
71         if ((f->length = lseek (fd, 0L, SEEK_END)) == (off_t) -1)
72         {
73             logf (LOG_FATAL|LOG_ERRNO, "cannot seek %s", fname);
74             exit (1);
75         }
76     }
77     if (lseek (fd, f->offset, SEEK_SET) == -1)
78     {
79         logf (LOG_FATAL|LOG_ERRNO, "cannot seek %s", fname);
80         exit (1);
81     }
82     while (f->chunk - nr > 0)
83     {
84         r = read (fd, f->buf + nr, f->chunk - nr);
85         if (r <= 0)
86             break;
87         nr += r;
88     }
89     if (r == -1)
90     {
91         logf (LOG_FATAL|LOG_ERRNO, "read of %s", fname);
92         exit (1);
93     }
94     f->buf_size = nr;
95     f->buf_ptr = 0;
96     if (f->readHandler)
97         (*f->readHandler)(f, f->readInfo);
98     close (fd);
99 }
100
101 struct key_file *key_file_init (int no, int chunk)
102 {
103     struct key_file *f;
104
105     f = (struct key_file *) xmalloc (sizeof(*f));
106     f->sysno = 0;
107     f->seqno = 0;
108     f->no = no;
109     f->chunk = chunk;
110     f->offset = 0;
111     f->length = 0;
112     f->readHandler = NULL;
113     f->buf = (unsigned char *) xmalloc (f->chunk);
114     f->prev_name = (char *) xmalloc (INP_NAME_MAX);
115     *f->prev_name = '\0';
116     key_file_chunk_read (f);
117     return f;
118 }
119
120 int key_file_getc (struct key_file *f)
121 {
122     if (f->buf_ptr < f->buf_size)
123         return f->buf[(f->buf_ptr)++];
124     if (f->buf_size < f->chunk)
125         return EOF;
126     f->offset += f->buf_size;
127     key_file_chunk_read (f);
128     if (f->buf_ptr < f->buf_size)
129         return f->buf[(f->buf_ptr)++];
130     else
131         return EOF;
132 }
133
134 int key_file_decode (struct key_file *f)
135 {
136     int c, d;
137
138     c = key_file_getc (f);
139     switch (c & 192) 
140     {
141     case 0:
142         d = c;
143         break;
144     case 64:
145         d = ((c&63) << 8) + (key_file_getc (f) & 0xff);
146         break;
147     case 128:
148         d = ((c&63) << 8) + (key_file_getc (f) & 0xff);
149         d = (d << 8) + (key_file_getc (f) & 0xff);
150         break;
151     case 192:
152         d = ((c&63) << 8) + (key_file_getc (f) & 0xff);
153         d = (d << 8) + (key_file_getc (f) & 0xff);
154         d = (d << 8) + (key_file_getc (f) & 0xff);
155         break;
156     }
157     return d;
158 }
159
160 int key_file_read (struct key_file *f, char *key)
161 {
162     int i, d, c;
163     struct it_key itkey;
164
165     c = key_file_getc (f);
166     if (c == 0)
167     {
168         strcpy (key, f->prev_name);
169         i = 1+strlen (key);
170     }
171     else if (c == EOF)
172         return 0;
173     else
174     {
175         i = 0;
176         key[i++] = c;
177         while ((key[i++] = key_file_getc (f)))
178             ;
179         strcpy (f->prev_name, key);
180         f->sysno = 0;
181     }
182     d = key_file_decode (f);
183     key[i++] = d & 1;
184     d = d >> 1;
185     itkey.sysno = d + f->sysno;
186     if (d) 
187     {
188         f->sysno = itkey.sysno;
189         f->seqno = 0;
190     }
191     d = key_file_decode (f);
192     itkey.seqno = d + f->seqno;
193     f->seqno = itkey.seqno;
194     memcpy (key + i, &itkey, sizeof(struct it_key));
195     return i + sizeof (struct it_key);
196 }
197
198 struct heap_info {
199     struct {
200         struct key_file **file;
201         char   **buf;
202     } info;
203     int    heapnum;
204     int    *ptr;
205     int    (*cmp)(const void *p1, const void *p2);
206     Dict dict;
207     ISAM isam;
208     ISAMC isamc;
209     ISAMS isams;
210     ISAMH isamh;
211 };
212
213 struct heap_info *key_heap_init (int nkeys,
214                                  int (*cmp)(const void *p1, const void *p2))
215 {
216     struct heap_info *hi;
217     int i;
218
219     hi = (struct heap_info *) xmalloc (sizeof(*hi));
220     hi->info.file = (struct key_file **)
221         xmalloc (sizeof(*hi->info.file) * (1+nkeys));
222     hi->info.buf = (char **) xmalloc (sizeof(*hi->info.buf) * (1+nkeys));
223     hi->heapnum = 0;
224     hi->ptr = (int *) xmalloc (sizeof(*hi->ptr) * (1+nkeys));
225     hi->cmp = cmp;
226     for (i = 0; i<= nkeys; i++)
227     {
228         hi->ptr[i] = i;
229         hi->info.buf[i] = (char *) xmalloc (INP_NAME_MAX);
230     }
231     return hi;
232 }
233
234 static void key_heap_swap (struct heap_info *hi, int i1, int i2)
235 {
236     int swap;
237
238     swap = hi->ptr[i1];
239     hi->ptr[i1] = hi->ptr[i2];
240     hi->ptr[i2] = swap;
241 }
242
243
244 static void key_heap_delete (struct heap_info *hi)
245 {
246     int cur = 1, child = 2;
247
248     assert (hi->heapnum > 0);
249
250     key_heap_swap (hi, 1, hi->heapnum);
251     hi->heapnum--;
252     while (child <= hi->heapnum) {
253         if (child < hi->heapnum &&
254             (*hi->cmp)(&hi->info.buf[hi->ptr[child]],
255                        &hi->info.buf[hi->ptr[child+1]]) > 0)
256             child++;
257         if ((*hi->cmp)(&hi->info.buf[hi->ptr[cur]],
258                        &hi->info.buf[hi->ptr[child]]) > 0)
259         {            
260             key_heap_swap (hi, cur, child);
261             cur = child;
262             child = 2*cur;
263         }
264         else
265             break;
266     }
267 }
268
269 static void key_heap_insert (struct heap_info *hi, const char *buf, int nbytes,
270                              struct key_file *kf)
271 {
272     int cur, parent;
273
274     cur = ++(hi->heapnum);
275     memcpy (hi->info.buf[hi->ptr[cur]], buf, nbytes);
276     hi->info.file[hi->ptr[cur]] = kf;
277
278     parent = cur/2;
279     while (parent && (*hi->cmp)(&hi->info.buf[hi->ptr[parent]],
280                                 &hi->info.buf[hi->ptr[cur]]) > 0)
281     {
282         key_heap_swap (hi, cur, parent);
283         cur = parent;
284         parent = cur/2;
285     }
286 }
287
288 static int heap_read_one (struct heap_info *hi, char *name, char *key)
289 {
290     int n, r;
291     char rbuf[INP_NAME_MAX];
292     struct key_file *kf;
293
294     if (!hi->heapnum)
295         return 0;
296     n = hi->ptr[1];
297     strcpy (name, hi->info.buf[n]);
298     kf = hi->info.file[n];
299     r = strlen(name);
300     memcpy (key, hi->info.buf[n] + r+1, KEY_SIZE);
301     key_heap_delete (hi);
302     if ((r = key_file_read (kf, rbuf)))
303         key_heap_insert (hi, rbuf, r, kf);
304     no_iterations++;
305     return 1;
306 }
307
308 struct heap_cread_info {
309     char prev_name[INP_NAME_MAX];
310     char cur_name[INP_NAME_MAX];
311     char *key;
312     struct heap_info *hi;
313     int mode;
314     int more;
315 };
316       
317 int heap_cread_item (void *vp, char **dst, int *insertMode)
318 {
319     struct heap_cread_info *p = (struct heap_cread_info *) vp;
320     struct heap_info *hi = p->hi;
321
322     if (p->mode == 1)
323     {
324         *insertMode = p->key[0];
325         memcpy (*dst, p->key+1, sizeof(struct it_key));
326         (*dst) += sizeof(struct it_key);
327         p->mode = 2;
328         return 1;
329     }
330     strcpy (p->prev_name, p->cur_name);
331     if (!(p->more = heap_read_one (hi, p->cur_name, p->key)))
332         return 0;
333     if (*p->cur_name && strcmp (p->cur_name, p->prev_name))
334     {
335         p->mode = 1;
336         return 0;
337     }
338     *insertMode = p->key[0];
339     memcpy (*dst, p->key+1, sizeof(struct it_key));
340     (*dst) += sizeof(struct it_key);
341     return 1;
342 }
343
344 int heap_inpc (struct heap_info *hi)
345 {
346     struct heap_cread_info hci;
347     ISAMC_I isamc_i = (ISAMC_I) xmalloc (sizeof(*isamc_i));
348
349     hci.key = (char *) xmalloc (KEY_SIZE);
350     hci.mode = 1;
351     hci.hi = hi;
352     hci.more = heap_read_one (hi, hci.cur_name, hci.key);
353
354     isamc_i->clientData = &hci;
355     isamc_i->read_item = heap_cread_item;
356
357     while (hci.more)
358     {
359         char this_name[INP_NAME_MAX];
360         ISAMC_P isamc_p, isamc_p2;
361         char *dict_info;
362
363         strcpy (this_name, hci.cur_name);
364         assert (hci.cur_name[1]);
365         no_diffs++;
366         if ((dict_info = dict_lookup (hi->dict, hci.cur_name)))
367         {
368             memcpy (&isamc_p, dict_info+1, sizeof(ISAMC_P));
369             isamc_p2 = isc_merge (hi->isamc, isamc_p, isamc_i);
370             if (!isamc_p2)
371             {
372                 no_deletions++;
373                 if (!dict_delete (hi->dict, this_name))
374                     abort();
375             }
376             else 
377             {
378                 no_updates++;
379                 if (isamc_p2 != isamc_p)
380                     dict_insert (hi->dict, this_name,
381                                  sizeof(ISAMC_P), &isamc_p2);
382             }
383         } 
384         else
385         {
386             isamc_p = isc_merge (hi->isamc, 0, isamc_i);
387             no_insertions++;
388             dict_insert (hi->dict, this_name, sizeof(ISAMC_P), &isamc_p);
389         }
390     }
391     xfree (isamc_i);
392     return 0;
393
394
395 int heap_inps (struct heap_info *hi)
396 {
397     struct heap_cread_info hci;
398     ISAMS_I isams_i = (ISAMS_I) xmalloc (sizeof(*isams_i));
399
400     hci.key = (char *) xmalloc (KEY_SIZE);
401     hci.mode = 1;
402     hci.hi = hi;
403     hci.more = heap_read_one (hi, hci.cur_name, hci.key);
404
405     isams_i->clientData = &hci;
406     isams_i->read_item = heap_cread_item;
407
408     while (hci.more)
409     {
410         char this_name[INP_NAME_MAX];
411         ISAMS_P isams_p;
412         char *dict_info;
413
414         strcpy (this_name, hci.cur_name);
415         assert (hci.cur_name[1]);
416         no_diffs++;
417         if (!(dict_info = dict_lookup (hi->dict, hci.cur_name)))
418         {
419             isams_p = isams_merge (hi->isams, isams_i);
420             no_insertions++;
421             dict_insert (hi->dict, this_name, sizeof(ISAMS_P), &isams_p);
422         }
423         else
424             abort();
425     }
426     xfree (isams_i);
427     return 0;
428
429
430 int heap_inph (struct heap_info *hi)
431 {
432     struct heap_cread_info hci;
433     ISAMH_I isamh_i = (ISAMH_I) xmalloc (sizeof(*isamh_i));
434
435     hci.key = (char *) xmalloc (KEY_SIZE);
436     hci.mode = 1;
437     hci.hi = hi;
438     hci.more = heap_read_one (hi, hci.cur_name, hci.key);
439
440     isamh_i->clientData = &hci;
441     isamh_i->read_item = heap_cread_item;
442
443     while (hci.more)
444     {
445         char this_name[INP_NAME_MAX];
446         ISAMH_P isamh_p, isamh_p2;
447         char *dict_info;
448
449         strcpy (this_name, hci.cur_name);
450         assert (hci.cur_name[1]);
451         no_diffs++;
452         if ((dict_info = dict_lookup (hi->dict, hci.cur_name)))
453         {
454             memcpy (&isamh_p, dict_info+1, sizeof(ISAMH_P));
455             isamh_p2 = isamh_append (hi->isamh, isamh_p, isamh_i);
456             if (!isamh_p2)
457             {
458                 no_deletions++;
459                 if (!dict_delete (hi->dict, this_name))
460                     abort();
461             }
462             else 
463             {
464                 no_updates++;
465                 if (isamh_p2 != isamh_p)
466                     dict_insert (hi->dict, this_name,
467                                  sizeof(ISAMH_P), &isamh_p2);
468             }
469         } 
470         else
471         {
472             isamh_p = isamh_append (hi->isamh, 0, isamh_i);
473             no_insertions++;
474             dict_insert (hi->dict, this_name, sizeof(ISAMH_P), &isamh_p);
475         }
476     }
477     xfree (isamh_i);
478     return 0;
479
480
481 int heap_inp (struct heap_info *hi)
482 {
483     char *info;
484     char next_name[INP_NAME_MAX];
485     char cur_name[INP_NAME_MAX];
486     int key_buf_size = INP_BUF_START;
487     int key_buf_ptr;
488     char *next_key;
489     char *key_buf;
490     int more;
491     
492     next_key = (char *) xmalloc (KEY_SIZE);
493     key_buf = (char *) xmalloc (key_buf_size);
494     more = heap_read_one (hi, cur_name, key_buf);
495     while (more)                   /* EOF ? */
496     {
497         int nmemb;
498         key_buf_ptr = KEY_SIZE;
499         while (1)
500         {
501             if (!(more = heap_read_one (hi, next_name, next_key)))
502                 break;
503             if (*next_name && strcmp (next_name, cur_name))
504                 break;
505             memcpy (key_buf + key_buf_ptr, next_key, KEY_SIZE);
506             key_buf_ptr += KEY_SIZE;
507             if (key_buf_ptr+(int) KEY_SIZE >= key_buf_size)
508             {
509                 char *new_key_buf;
510                 new_key_buf = (char *) xmalloc (key_buf_size + INP_BUF_ADD);
511                 memcpy (new_key_buf, key_buf, key_buf_size);
512                 key_buf_size += INP_BUF_ADD;
513                 xfree (key_buf);
514                 key_buf = new_key_buf;
515             }
516         }
517         no_diffs++;
518         nmemb = key_buf_ptr / KEY_SIZE;
519         assert (nmemb * (int) KEY_SIZE == key_buf_ptr);
520         if ((info = dict_lookup (hi->dict, cur_name)))
521         {
522             ISAM_P isam_p, isam_p2;
523             memcpy (&isam_p, info+1, sizeof(ISAM_P));
524             isam_p2 = is_merge (hi->isam, isam_p, nmemb, key_buf);
525             if (!isam_p2)
526             {
527                 no_deletions++;
528                 if (!dict_delete (hi->dict, cur_name))
529                     abort ();
530             }
531             else 
532             {
533                 no_updates++;
534                 if (isam_p2 != isam_p)
535                     dict_insert (hi->dict, cur_name, sizeof(ISAM_P), &isam_p2);
536             }
537         }
538         else
539         {
540             ISAM_P isam_p;
541             no_insertions++;
542             isam_p = is_merge (hi->isam, 0, nmemb, key_buf);
543             dict_insert (hi->dict, cur_name, sizeof(ISAM_P), &isam_p);
544         }
545         memcpy (key_buf, next_key, KEY_SIZE);
546         strcpy (cur_name, next_name);
547     }
548     return 0;
549 }
550
551 struct progressInfo {
552     time_t   startTime;
553     time_t   lastTime;
554     off_t    totalBytes;
555     off_t    totalOffset;
556 };
557
558 void progressFunc (struct key_file *keyp, void *info)
559 {
560     struct progressInfo *p = (struct progressInfo *) info;
561     time_t now, remaining;
562
563     if (keyp->buf_size <= 0 || p->totalBytes <= 0)
564         return ;
565     time (&now);
566
567     if (now >= p->lastTime+10)
568     {
569         p->lastTime = now;
570         remaining = (time_t) ((now - p->startTime)*
571             ((double) p->totalBytes/p->totalOffset - 1.0));
572         if (remaining <= 130)
573             logf (LOG_LOG, "Merge %2.1f%% completed; %ld seconds remaining",
574                  (100.0*p->totalOffset) / p->totalBytes, (long) remaining);
575         else
576             logf (LOG_LOG, "Merge %2.1f%% completed; %ld minutes remaining",
577                  (100.0*p->totalOffset) / p->totalBytes, (long) remaining/60);
578     }
579     p->totalOffset += keyp->buf_size;
580 }
581
582 #ifndef R_OK
583 #define R_OK 4
584 #endif
585
586 void key_input (BFiles bfs, int nkeys, int cache)
587                 
588 {
589     Dict dict;
590     ISAM isam = NULL;
591     ISAMC isamc = NULL;
592     ISAMS isams = NULL;
593     ISAMH isamh = NULL;
594     struct key_file **kf;
595     char rbuf[1024];
596     int i, r;
597     struct heap_info *hi;
598     struct progressInfo progressInfo;
599
600     if (nkeys < 0)
601     {
602         char fname[1024];
603         nkeys = 0;
604         while (1)
605         {
606             getFnameTmp (fname, nkeys+1);
607             if (access (fname, R_OK) == -1)
608                 break;
609             nkeys++;
610         }
611         if (!nkeys)
612             return ;
613     }
614     dict = dict_open (bfs, FNAME_DICT, cache, 1, 0);
615     if (!dict)
616     {
617         logf (LOG_FATAL, "dict_open fail");
618         exit (1);
619     }
620     if (res_get_match (common_resource, "isam", "s", NULL))
621     {
622         isams = isams_open (bfs, FNAME_ISAMS, 1,
623                             key_isams_m (common_resource));
624         if (!isams)
625         {
626             logf (LOG_FATAL, "isams_open fail");
627             exit (1);
628         }
629     }
630     else if (res_get_match (common_resource, "isam", "i", NULL))
631     {
632         isam = is_open (bfs, FNAME_ISAM, key_compare, 1,
633                         sizeof(struct it_key), common_resource);
634         if (!isam)
635         {
636             logf (LOG_FATAL, "is_open fail");
637             exit (1);
638         }
639     }
640     else if (res_get_match (common_resource, "isam", "h", NULL))
641     {
642         isamh = isamh_open (bfs, FNAME_ISAMH, 1,
643                           key_isamh_m (common_resource));
644         if (!isamh)
645         {
646             logf (LOG_FATAL, "isamh_open fail");
647             exit (1);
648         }
649     }
650     else
651     {
652         isamc = isc_open (bfs, FNAME_ISAMC, 1,
653                           key_isamc_m (common_resource));
654         if (!isamc)
655         {
656             logf (LOG_FATAL, "isc_open fail");
657             exit (1);
658         }
659     }
660     kf = (struct key_file **) xmalloc ((1+nkeys) * sizeof(*kf));
661     progressInfo.totalBytes = 0;
662     progressInfo.totalOffset = 0;
663     time (&progressInfo.startTime);
664     time (&progressInfo.lastTime);
665     for (i = 1; i<=nkeys; i++)
666     {
667         kf[i] = key_file_init (i, 32768);
668         kf[i]->readHandler = progressFunc;
669         kf[i]->readInfo = &progressInfo;
670         progressInfo.totalBytes += kf[i]->length;
671         progressInfo.totalOffset += kf[i]->buf_size;
672     }
673     hi = key_heap_init (nkeys, key_qsort_compare);
674     hi->dict = dict;
675     hi->isam = isam;
676     hi->isamc = isamc;
677     hi->isams = isams;
678     hi->isamh = isamh;
679     
680     for (i = 1; i<=nkeys; i++)
681         if ((r = key_file_read (kf[i], rbuf)))
682             key_heap_insert (hi, rbuf, r, kf[i]);
683     if (isamc)
684         heap_inpc (hi);
685     else if (isams)
686         heap_inps (hi);
687     else if (isam)
688         heap_inp (hi);
689     else if (isamh)
690         heap_inph (hi);
691         
692     dict_close (dict);
693     if (isam)
694         is_close (isam);
695     if (isamc)
696         isc_close (isamc);
697     if (isams)
698         isams_close (isams);
699     if (isamh)
700         isamh_close (isamh);
701    
702     for (i = 1; i<=nkeys; i++)
703     {
704         getFnameTmp (rbuf, i);
705         unlink (rbuf);
706     }
707     logf (LOG_LOG, "Iterations . . .%7d", no_iterations);
708     logf (LOG_LOG, "Distinct words .%7d", no_diffs);
709     logf (LOG_LOG, "Updates. . . . .%7d", no_updates);
710     logf (LOG_LOG, "Deletions. . . .%7d", no_deletions);
711     logf (LOG_LOG, "Insertions . . .%7d", no_insertions);
712 }
713
714
715
716 /*
717  * $Log: kinput.c,v $
718  * Revision 1.35  1999-06-30 15:07:23  heikki
719  * Adding isamh stuff
720  *
721  * Revision 1.34  1999/05/26 07:49:13  adam
722  * C++ compilation.
723  *
724  * Revision 1.33  1999/05/15 14:36:38  adam
725  * Updated dictionary. Implemented "compression" of dictionary.
726  *
727  * Revision 1.32  1999/05/12 13:08:06  adam
728  * First version of ISAMS.
729  *
730  * Revision 1.31  1999/02/02 14:50:56  adam
731  * Updated WIN32 code specific sections. Changed header.
732  *
733  * Revision 1.30  1998/10/28 10:53:57  adam
734  * Added type cast to prevent warning.
735  *
736  * Revision 1.29  1998/06/11 15:41:39  adam
737  * Minor changes.
738  *
739  * Revision 1.28  1998/03/05 08:45:12  adam
740  * New result set model and modular ranking system. Moved towards
741  * descent server API. System information stored as "SGML" records.
742  *
743  * Revision 1.27  1998/02/17 10:32:52  adam
744  * Fixed bug: binary files weren't opened with flag b on NT.
745  *
746  * Revision 1.26  1998/01/29 13:39:13  adam
747  * Compress ISAM is default.
748  *
749  * Revision 1.25  1997/09/17 12:19:14  adam
750  * Zebra version corresponds to YAZ version 1.4.
751  * Changed Zebra server so that it doesn't depend on global common_resource.
752  *
753  * Revision 1.24  1997/09/09 13:38:07  adam
754  * Partial port to WIN95/NT.
755  *
756  * Revision 1.23  1997/09/04 13:57:39  adam
757  * Added O_BINARY for open calls.
758  *
759  * Revision 1.22  1997/02/12 20:39:45  adam
760  * Implemented options -f <n> that limits the log to the first <n>
761  * records.
762  * Changed some log messages also.
763  *
764  * Revision 1.21  1996/11/08 11:10:23  adam
765  * Buffers used during file match got bigger.
766  * Compressed ISAM support everywhere.
767  * Bug fixes regarding masking characters in queries.
768  * Redesigned Regexp-2 queries.
769  *
770  * Revision 1.20  1996/11/01 08:58:41  adam
771  * Interface to isamc system now includes update and delete.
772  *
773  * Revision 1.19  1996/10/29 14:09:46  adam
774  * Use of cisam system - enabled if setting isamc is 1.
775  *
776  * Revision 1.18  1996/06/04 10:18:59  adam
777  * Minor changes - removed include of ctype.h.
778  *
779  * Revision 1.17  1996/05/14  15:47:07  adam
780  * Cleanup of various buffer size entities.
781  *
782  * Revision 1.16  1996/04/09  10:05:20  adam
783  * Bug fix: prev_name buffer possibly too small; allocated in key_file_init.
784  *
785  * Revision 1.15  1996/03/21  14:50:09  adam
786  * File update uses modify-time instead of change-time.
787  *
788  * Revision 1.14  1996/02/07  14:06:37  adam
789  * Better progress report during register merge.
790  * New command: clean - removes temporary shadow files.
791  *
792  * Revision 1.13  1996/02/05  12:30:00  adam
793  * Logging reduced a bit.
794  * The remaining running time is estimated during register merge.
795  *
796  * Revision 1.12  1995/12/06  17:49:19  adam
797  * Uses dict_delete now.
798  *
799  * Revision 1.11  1995/12/06  16:06:43  adam
800  * Better diagnostics. Work on 'real' dictionary deletion.
801  *
802  * Revision 1.10  1995/12/06  12:41:22  adam
803  * New command 'stat' for the index program.
804  * Filenames can be read from stdin by specifying '-'.
805  * Bug fix/enhancement of the transformation from terms to regular
806  * expressons in the search engine.
807  *
808  * Revision 1.9  1995/10/10  12:24:39  adam
809  * Temporary sort files are compressed.
810  *
811  * Revision 1.8  1995/10/04  16:57:19  adam
812  * Key input and merge sort in one pass.
813  *
814  * Revision 1.7  1995/10/02  15:18:52  adam
815  * New member in recRetrieveCtrl: diagnostic.
816  *
817  * Revision 1.6  1995/09/29  15:51:56  adam
818  * First work on multi-way read.
819  *
820  * Revision 1.5  1995/09/29  14:01:43  adam
821  * Bug fixes.
822  *
823  * Revision 1.4  1995/09/28  14:22:57  adam
824  * Sort uses smaller temporary files.
825  *
826  * Revision 1.3  1995/09/06  16:11:17  adam
827  * Option: only one word key per file.
828  *
829  * Revision 1.2  1995/09/04  12:33:42  adam
830  * Various cleanup. YAZ util used instead.
831  *
832  * Revision 1.1  1995/09/04  09:10:37  adam
833  * More work on index add/del/update.
834  * Merge sort implemented.
835  * Initial work on z39 server.
836  *
837  */
838