X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fkinput.c;h=55023e976fdf3106b63928ad8773e2464bae820d;hb=4e1ac996f683092752e957b56ac228b2b9c1a381;hp=89824d544c69b905de61b4845e6dda70fca7eb0b;hpb=45554249f7785e31125a062dc410a93ef693f574;p=idzebra-moved-to-github.git diff --git a/index/kinput.c b/index/kinput.c index 89824d5..55023e9 100644 --- a/index/kinput.c +++ b/index/kinput.c @@ -1,10 +1,47 @@ /* - * Copyright (C) 1994-1996, Index Data I/S + * Copyright (C) 1994-1998, Index Data I/S * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * * $Log: kinput.c,v $ - * Revision 1.19 1996-10-29 14:09:46 adam + * Revision 1.29 1998-06-11 15:41:39 adam + * Minor changes. + * + * Revision 1.28 1998/03/05 08:45:12 adam + * New result set model and modular ranking system. Moved towards + * descent server API. System information stored as "SGML" records. + * + * Revision 1.27 1998/02/17 10:32:52 adam + * Fixed bug: binary files weren't opened with flag b on NT. + * + * Revision 1.26 1998/01/29 13:39:13 adam + * Compress ISAM is default. + * + * Revision 1.25 1997/09/17 12:19:14 adam + * Zebra version corresponds to YAZ version 1.4. + * Changed Zebra server so that it doesn't depend on global common_resource. + * + * Revision 1.24 1997/09/09 13:38:07 adam + * Partial port to WIN95/NT. + * + * Revision 1.23 1997/09/04 13:57:39 adam + * Added O_BINARY for open calls. + * + * Revision 1.22 1997/02/12 20:39:45 adam + * Implemented options -f that limits the log to the first + * records. + * Changed some log messages also. + * + * Revision 1.21 1996/11/08 11:10:23 adam + * Buffers used during file match got bigger. + * Compressed ISAM support everywhere. + * Bug fixes regarding masking characters in queries. + * Redesigned Regexp-2 queries. + * + * Revision 1.20 1996/11/01 08:58:41 adam + * Interface to isamc system now includes update and delete. + * + * Revision 1.19 1996/10/29 14:09:46 adam * Use of cisam system - enabled if setting isamc is 1. * * Revision 1.18 1996/06/04 10:18:59 adam @@ -71,7 +108,11 @@ */ #include +#ifdef WINDOWS +#include +#else #include +#endif #include #include #include @@ -116,10 +157,10 @@ void getFnameTmp (char *fname, int no) void key_file_chunk_read (struct key_file *f) { - int nr = 0, r, fd; + int nr = 0, r = 0, fd; char fname[1024]; getFnameTmp (fname, f->no); - fd = open (fname, O_RDONLY); + fd = open (fname, O_BINARY|O_RDONLY); if (fd == -1) { logf (LOG_FATAL|LOG_ERRNO, "cannot open %s", fname); @@ -400,9 +441,7 @@ int heap_cread_item (void *vp, char **dst, int *insertMode) int heap_inpc (struct heap_info *hi) { struct heap_cread_info hci; - ISAMC_P isamc_p; ISAMC_I isamc_i = xmalloc (sizeof(*isamc_i)); - void *dict_info; hci.key = xmalloc (KEY_SIZE); hci.mode = 1; @@ -414,16 +453,33 @@ int heap_inpc (struct heap_info *hi) while (hci.more) { - logf (LOG_DEBUG, "inserting %s", 1+hci.cur_name); + char this_name[INP_NAME_MAX]; + ISAMC_P isamc_p, isamc_p2; + char *dict_info; + + strcpy (this_name, hci.cur_name); + assert (hci.cur_name[1]); + no_diffs++; if ((dict_info = dict_lookup (hi->dict, hci.cur_name))) { - logf (LOG_FATAL, "Cannot merge really yet! %s", hci.cur_name); - exit (1); + memcpy (&isamc_p, dict_info+1, sizeof(ISAMC_P)); + isamc_p2 = isc_merge (hi->isamc, isamc_p, isamc_i); + if (!isamc_p2) + { + no_deletions++; + if (!dict_delete (hi->dict, this_name)) + abort(); + } + else + { + no_updates++; + if (isamc_p2 != isamc_p) + dict_insert (hi->dict, this_name, + sizeof(ISAMC_P), &isamc_p2); + } } else { - char this_name[128]; - strcpy (this_name, hci.cur_name); isamc_p = isc_merge (hi->isamc, 0, isamc_i); no_insertions++; dict_insert (hi->dict, this_name, sizeof(ISAMC_P), &isamc_p); @@ -475,7 +531,6 @@ int heap_inp (struct heap_info *hi) if ((info = dict_lookup (hi->dict, cur_name))) { ISAM_P isam_p, isam_p2; - logf (LOG_DEBUG, "updating %s", 1+cur_name); memcpy (&isam_p, info+1, sizeof(ISAM_P)); isam_p2 = is_merge (hi->isam, isam_p, nmemb, key_buf); if (!isam_p2) @@ -494,7 +549,6 @@ int heap_inp (struct heap_info *hi) else { ISAM_P isam_p; - logf (LOG_DEBUG, "inserting %s", 1+cur_name); no_insertions++; isam_p = is_merge (hi->isam, 0, nmemb, key_buf); dict_insert (hi->dict, cur_name, sizeof(ISAM_P), &isam_p); @@ -536,7 +590,11 @@ void progressFunc (struct key_file *keyp, void *info) p->totalOffset += keyp->buf_size; } -void key_input (int nkeys, int cache) +#ifndef R_OK +#define R_OK 4 +#endif + +void key_input (BFiles bfs, int nkeys, int cache) { Dict dict; @@ -562,24 +620,26 @@ void key_input (int nkeys, int cache) if (!nkeys) return ; } - dict = dict_open (FNAME_DICT, cache, 1); + dict = dict_open (bfs, FNAME_DICT, cache, 1); if (!dict) { logf (LOG_FATAL, "dict_open fail"); exit (1); } - if (res_get_match (common_resource, "isam", "c", NULL)) + if (!res_get_match (common_resource, "isam", "i", NULL)) { - isamc = isc_open (FNAME_ISAMC, 1, key_isamc_m ()); + isamc = isc_open (bfs, + FNAME_ISAMC, 1, key_isamc_m (common_resource)); if (!isamc) { - logf (LOG_FATAL, "isc_open fail"); - exit (1); + logf (LOG_FATAL, "isc_open fail"); + exit (1); } } else { - isam = is_open (FNAME_ISAM, key_compare, 1, sizeof(struct it_key)); + isam = is_open (bfs, FNAME_ISAM, key_compare, 1, + sizeof(struct it_key), common_resource); if (!isam) { logf (LOG_FATAL, "is_open fail"); @@ -616,7 +676,7 @@ void key_input (int nkeys, int cache) is_close (isam); if (isamc) isc_close (isamc); - + for (i = 1; i<=nkeys; i++) { getFnameTmp (rbuf, i);