From: Adam Dickmeiss Date: Tue, 29 Oct 1996 14:09:36 +0000 (+0000) Subject: Use of cisam system - enabled if setting isamc is 1. X-Git-Tag: ZEBRA.1.0~387 X-Git-Url: http://jsfdemo.indexdata.com/?a=commitdiff_plain;h=45554249f7785e31125a062dc410a93ef693f574;p=idzebra-moved-to-github.git Use of cisam system - enabled if setting isamc is 1. --- diff --git a/index/Makefile b/index/Makefile index 57ddf29..19f317c 100644 --- a/index/Makefile +++ b/index/Makefile @@ -1,7 +1,7 @@ # Copyright (C) 1995-1996, Index Data I/S # All rights reserved. # Sebastian Hammer, Adam Dickmeiss -# $Id: Makefile,v 1.40 1996-10-11 10:56:58 adam Exp $ +# $Id: Makefile,v 1.41 1996-10-29 14:09:36 adam Exp $ SHELL=/bin/sh RANLIB=ranlib @@ -20,7 +20,7 @@ TPROG3=zebrasrv DEFS=$(INCLUDE) O1 = main.o dir.o dirs.o trav.o extract.o kinput.o kcompare.o \ symtab.o recindex.o recstat.o lockutil.o lockidx.o \ - zinfo.o invstat.o keychars.o + zinfo.o invstat.o keychars.o O2 = kdump.o O3 = zserver.o kcompare.o zrpn.o zsets.o attribute.o recindex.o \ zlogs.o lockutil.o locksrv.o zinfo.o keychars.o @@ -28,22 +28,22 @@ CPP=$(CC) -E all: $(TPROG1) $(TPROG2) $(TPROG3) -$(TPROG1): $(O1) ../lib/dict.a ../lib/isam.a ../lib/recctrl.a \ - ../lib/bfile.a ../lib/dfa.a ../lib/alexutil.a +$(TPROG1): $(O1) ../lib/dict.a ../lib/isam.a ../lib/isamc.a ../lib/recctrl.a \ + ../lib/bfile.a ../lib/dfa.a ../lib/zebrautl.a $(CC) $(CFLAGS) -o $(TPROG1) $(O1) \ - ../lib/dict.a ../lib/isam.a ../lib/recctrl.a \ - ../lib/bfile.a ../lib/dfa.a ../lib/alexutil.a \ + ../lib/dict.a ../lib/isam.a ../lib/isamc.a ../lib/recctrl.a \ + ../lib/bfile.a ../lib/dfa.a ../lib/zebrautl.a \ $(YAZLIB) $(TPROG2): $(O2) - $(CC) $(CFLAGS) -o $(TPROG2) $(O2) ../lib/alexutil.a $(YAZLIB) + $(CC) $(CFLAGS) -o $(TPROG2) $(O2) ../lib/zebrautl.a $(YAZLIB) $(TPROG3): $(O3) \ ../lib/rset.a ../lib/dict.a ../lib/isam.a ../lib/recctrl.a \ - ../lib/bfile.a ../lib/dfa.a ../lib/alexutil.a + ../lib/isamc.a ../lib/bfile.a ../lib/dfa.a ../lib/zebrautl.a $(CC) $(CFLAGS) -o $(TPROG3) $(O3) \ ../lib/rset.a ../lib/dict.a ../lib/isam.a ../lib/recctrl.a \ - ../lib/bfile.a ../lib/dfa.a ../lib/alexutil.a \ + ../lib/isamc.a ../lib/bfile.a ../lib/dfa.a ../lib/zebrautl.a \ $(YAZLIB) $(OSILIB) $(NETLIB) -lm .c.o: diff --git a/index/extract.c b/index/extract.c index ff5081c..743d174 100644 --- a/index/extract.c +++ b/index/extract.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: extract.c,v $ - * Revision 1.62 1996-10-11 10:57:01 adam + * Revision 1.63 1996-10-29 14:09:39 adam + * Use of cisam system - enabled if setting isamc is 1. + * + * Revision 1.62 1996/10/11 10:57:01 adam * New module recctrl. Used to manage records (extract/retrieval). * Several files have been moved to the recctrl sub directory. * @@ -227,7 +230,6 @@ #include #include -#include #include #include "index.h" @@ -264,6 +266,8 @@ static void logRecord (int showFlag) void key_open (int mem) { + if (!mem) + mem = atoi(res_get_def (common_resource, "memMax", "4"))*1024*1024; if (mem < 50000) mem = 50000; key_buf = xmalloc (mem); @@ -358,7 +362,7 @@ void key_flush (void) key_file_no++; logf (LOG_LOG, "sorting section %d", key_file_no); qsort (key_buf + ptr_top-ptr_i, ptr_i, sizeof(char*), key_qsort_compare); - sprintf (out_fname, TEMP_FNAME, key_file_no); + getFnameTmp (out_fname, key_file_no); if (!(outf = fopen (out_fname, "w"))) { diff --git a/index/index.h b/index/index.h index d38b61a..a90bf03 100644 --- a/index/index.h +++ b/index/index.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: index.h,v $ - * Revision 1.44 1996-06-06 12:08:40 quinn + * Revision 1.45 1996-10-29 14:09:42 adam + * Use of cisam system - enabled if setting isamc is 1. + * + * Revision 1.44 1996/06/06 12:08:40 quinn * Added showRecord function * * Revision 1.43 1996/06/04 10:18:12 adam @@ -154,20 +157,23 @@ * New simple file index tool. * */ - #include #include -#include +#include + #include #include +#include #define IT_MAX_WORD 256 #define IT_KEY_HAVE_SEQNO 1 #define IT_KEY_HAVE_FIELD 0 +typedef int SYSNO; + struct it_key { int sysno; - int seqno; + int seqno; }; enum dirsKind { dirs_dir, dirs_file }; @@ -197,6 +203,7 @@ struct recordGroup { int fileVerboseFlag; }; +void getFnameTmp (char *fname, int no); struct dirs_info *dirs_open (Dict dict, const char *rep); struct dirs_info *dirs_fopen (Dict dict, const char *path); @@ -219,18 +226,17 @@ void repositoryShow (struct recordGroup *rGroup); void key_open (int mem); int key_close (void); -void key_write (int cmd, struct it_key *k, const char *str); int key_compare (const void *p1, const void *p2); int key_qsort_compare (const void *p1, const void *p2); void key_logdump (int mask, const void *p); void inv_prstat (const char *dict_fname, const char *isam_fname); -void key_input (const char *dict_fname, const char *isam_fname, - int nkeys, int cache); +void key_input (int nkeys, int cache); +ISAMC_M key_isamc_m (void); int merge_sort (char **buf, int from, int to); -#define TEMP_FNAME "keys%d.tmp" -#define FNAME_WORD_DICT "worddict" -#define FNAME_WORD_ISAM "wordisam" +#define FNAME_DICT "dict" +#define FNAME_ISAM "isam" +#define FNAME_ISAMC "isamc" #define FNAME_CONFIG "zebra.cfg" #define GMATCH_DICT "gmatch" diff --git a/index/kcompare.c b/index/kcompare.c index f38f948..2d7e720 100644 --- a/index/kcompare.c +++ b/index/kcompare.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: kcompare.c,v $ - * Revision 1.17 1996-06-04 10:18:58 adam + * Revision 1.18 1996-10-29 14:09:44 adam + * Use of cisam system - enabled if setting isamc is 1. + * + * Revision 1.17 1996/06/04 10:18:58 adam * Minor changes - removed include of ctype.h. * * Revision 1.16 1996/05/13 14:23:05 adam @@ -126,3 +129,123 @@ int key_qsort_compare (const void *p1, const void *p2) return cp1[l] - cp2[l]; } +struct iscz_code_info { + struct it_key key; +}; + +static void *iscz_code_start (int mode) +{ + struct iscz_code_info *p = xmalloc (sizeof(*p)); + p->key.sysno = 0; + p->key.seqno = 0; + return p; +} + +static void iscz_code_stop (int mode, void *p) +{ + xfree (p); +} + +void iscz_encode_int (unsigned d, char **dst) +{ + unsigned char *bp = (unsigned char*) *dst; + + if (d <= 63) + *bp++ = d; + else if (d <= 16383) + { + *bp++ = 64 + (d>>8); + *bp++ = d & 255; + } + else if (d <= 4194303) + { + *bp++ = 128 + (d>>16); + *bp++ = (d>>8) & 255; + *bp++ = d & 255; + } + else + { + *bp++ = 192 + (d>>24); + *bp++ = (d>>16) & 255; + *bp++ = (d>>8) & 255; + *bp++ = d & 255; + } + *dst = (char *) bp; +} + +int isxz_decode_int (unsigned char **src) +{ + unsigned c = *(*src)++; + switch (c & 192) + { + case 0: + return c; + case 64: + return ((c & 63) << 8) + *(*src)++; + case 128: + c = ((c & 63) << 8) + *(*src)++; + c = (c << 8) + *(*src)++; + return c; + } + c = ((c & 63) << 8) + *(*src)++; + c = (c << 8) + *(*src)++; + c = (c << 8) + *(*src)++; + return c; +} + +static void iscz_code_item (int mode, void *vp, char **dst, char **src) +{ + struct iscz_code_info *p = vp; + struct it_key tkey; + int d; + + if (mode == ISAMC_ENCODE) + { + memcpy (&tkey, *src, sizeof(struct it_key)); + d = tkey.sysno - p->key.sysno; + iscz_encode_int (d, dst); + if (d) + { + p->key.sysno = tkey.sysno; + p->key.seqno = 0; + } + iscz_encode_int (tkey.seqno - p->key.seqno, dst); + p->key.seqno = tkey.seqno; + (*src) += sizeof(struct it_key); + } + else + { + d = isxz_decode_int ((unsigned char **) src); + if (d) + { + p->key.sysno += d; + p->key.seqno = 0; + } + d = isxz_decode_int ((unsigned char **) src); + p->key.seqno += d; + memcpy (*dst, &p->key, sizeof(struct it_key)); + (*dst) += sizeof(struct it_key); + } +} + +ISAMC_M key_isamc_m (void) +{ + static ISAMC_M me = NULL; + + if (me) + return me; + + me = isc_getmethod (); + + me->compare_item = key_compare; + + me->code_start = iscz_code_start; + me->code_item = iscz_code_item; + me->code_stop = iscz_code_stop; + + me->debug = atoi(res_get_def (common_resource, "isamcDebug", "0")); + + logf (LOG_LOG, "ISAMC system active"); + return me; +} + diff --git a/index/kinput.c b/index/kinput.c index eef3ab5..89824d5 100644 --- a/index/kinput.c +++ b/index/kinput.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: kinput.c,v $ - * Revision 1.18 1996-06-04 10:18:59 adam + * 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 * Minor changes - removed include of ctype.h. * * Revision 1.17 1996/05/14 15:47:07 adam @@ -105,7 +108,10 @@ struct key_file { void getFnameTmp (char *fname, int no) { - sprintf (fname, TEMP_FNAME, no); + const char *pre; + + pre = res_get_def (common_resource, "keyTmpDir", "."); + sprintf (fname, "%s/key%d.tmp", pre, no); } void key_file_chunk_read (struct key_file *f) @@ -256,6 +262,9 @@ struct heap_info { int heapnum; int *ptr; int (*cmp)(const void *p1, const void *p2); + Dict dict; + ISAM isam; + ISAMC isamc; }; struct heap_info *key_heap_init (int nkeys, @@ -352,7 +361,79 @@ static int heap_read_one (struct heap_info *hi, char *name, char *key) return 1; } -int heap_inp (Dict dict, ISAM isam, struct heap_info *hi) +struct heap_cread_info { + char prev_name[INP_NAME_MAX]; + char cur_name[INP_NAME_MAX]; + char *key; + struct heap_info *hi; + int mode; + int more; +}; + +int heap_cread_item (void *vp, char **dst, int *insertMode) +{ + struct heap_cread_info *p = vp; + struct heap_info *hi = p->hi; + + if (p->mode == 1) + { + *insertMode = p->key[0]; + memcpy (*dst, p->key+1, sizeof(struct it_key)); + (*dst) += sizeof(struct it_key); + p->mode = 2; + return 1; + } + strcpy (p->prev_name, p->cur_name); + if (!(p->more = heap_read_one (hi, p->cur_name, p->key))) + return 0; + if (*p->cur_name && strcmp (p->cur_name, p->prev_name)) + { + p->mode = 1; + return 0; + } + *insertMode = p->key[0]; + memcpy (*dst, p->key+1, sizeof(struct it_key)); + (*dst) += sizeof(struct it_key); + return 1; +} + +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; + hci.hi = hi; + hci.more = heap_read_one (hi, hci.cur_name, hci.key); + + isamc_i->clientData = &hci; + isamc_i->read_item = heap_cread_item; + + while (hci.more) + { + logf (LOG_DEBUG, "inserting %s", 1+hci.cur_name); + if ((dict_info = dict_lookup (hi->dict, hci.cur_name))) + { + logf (LOG_FATAL, "Cannot merge really yet! %s", hci.cur_name); + exit (1); + } + 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); + } + } + xfree (isamc_i); + return 0; +} + +int heap_inp (struct heap_info *hi) { char *info; char next_name[INP_NAME_MAX]; @@ -391,32 +472,32 @@ int heap_inp (Dict dict, ISAM isam, struct heap_info *hi) no_diffs++; nmemb = key_buf_ptr / KEY_SIZE; assert (nmemb*KEY_SIZE == key_buf_ptr); - if ((info = dict_lookup (dict, cur_name))) + if ((info = dict_lookup (hi->dict, cur_name))) { ISAM_P isam_p, isam_p2; - logf (LOG_DEBUG, "updating %s", cur_name); + logf (LOG_DEBUG, "updating %s", 1+cur_name); memcpy (&isam_p, info+1, sizeof(ISAM_P)); - isam_p2 = is_merge (isam, isam_p, nmemb, key_buf); + isam_p2 = is_merge (hi->isam, isam_p, nmemb, key_buf); if (!isam_p2) { no_deletions++; - if (!dict_delete (dict, cur_name)) + if (!dict_delete (hi->dict, cur_name)) abort (); } else { no_updates++; if (isam_p2 != isam_p) - dict_insert (dict, cur_name, sizeof(ISAM_P), &isam_p2); + dict_insert (hi->dict, cur_name, sizeof(ISAM_P), &isam_p2); } } else { ISAM_P isam_p; - logf (LOG_DEBUG, "inserting %s", cur_name); + logf (LOG_DEBUG, "inserting %s", 1+cur_name); no_insertions++; - isam_p = is_merge (isam, 0, nmemb, key_buf); - dict_insert (dict, cur_name, sizeof(ISAM_P), &isam_p); + isam_p = is_merge (hi->isam, 0, nmemb, key_buf); + dict_insert (hi->dict, cur_name, sizeof(ISAM_P), &isam_p); } memcpy (key_buf, next_key, KEY_SIZE); strcpy (cur_name, next_name); @@ -455,12 +536,12 @@ void progressFunc (struct key_file *keyp, void *info) p->totalOffset += keyp->buf_size; } -void key_input (const char *dict_fname, const char *isam_fname, - int nkeys, int cache) +void key_input (int nkeys, int cache) { Dict dict; - ISAM isam; + ISAM isam = NULL; + ISAMC isamc = NULL; struct key_file **kf; char rbuf[1024]; int i, r; @@ -481,19 +562,30 @@ void key_input (const char *dict_fname, const char *isam_fname, if (!nkeys) return ; } - dict = dict_open (dict_fname, cache, 1); + dict = dict_open (FNAME_DICT, cache, 1); if (!dict) { - logf (LOG_FATAL, "dict_open fail of `%s'", dict_fname); + logf (LOG_FATAL, "dict_open fail"); exit (1); } - isam = is_open (isam_fname, key_compare, 1, sizeof(struct it_key)); - if (!isam) + if (res_get_match (common_resource, "isam", "c", NULL)) { - logf (LOG_FATAL, "is_open fail of `%s'", isam_fname); - exit (1); + isamc = isc_open (FNAME_ISAMC, 1, key_isamc_m ()); + if (!isamc) + { + logf (LOG_FATAL, "isc_open fail"); + exit (1); + } + } + else + { + isam = is_open (FNAME_ISAM, key_compare, 1, sizeof(struct it_key)); + if (!isam) + { + logf (LOG_FATAL, "is_open fail"); + exit (1); + } } - kf = xmalloc ((1+nkeys) * sizeof(*kf)); progressInfo.totalBytes = 0; progressInfo.totalOffset = 0; @@ -508,13 +600,22 @@ void key_input (const char *dict_fname, const char *isam_fname, progressInfo.totalOffset += kf[i]->buf_size; } hi = key_heap_init (nkeys, key_qsort_compare); + hi->dict = dict; + hi->isam = isam; + hi->isamc = isamc; + for (i = 1; i<=nkeys; i++) if ((r = key_file_read (kf[i], rbuf))) key_heap_insert (hi, rbuf, r, kf[i]); - heap_inp (dict, isam, hi); - + if (isamc) + heap_inpc (hi); + else + heap_inp (hi); dict_close (dict); - is_close (isam); + if (isam) + is_close (isam); + if (isamc) + isc_close (isamc); for (i = 1; i<=nkeys; i++) { diff --git a/index/main.c b/index/main.c index f7cb72b..dcb89a6 100644 --- a/index/main.c +++ b/index/main.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: main.c,v $ - * Revision 1.43 1996-06-06 12:08:42 quinn + * Revision 1.44 1996-10-29 14:09:48 adam + * Use of cisam system - enabled if setting isamc is 1. + * + * Revision 1.43 1996/06/06 12:08:42 quinn * Added showRecord function * * Revision 1.42 1996/05/31 09:07:01 quinn @@ -162,13 +165,11 @@ #include #include -#include #include #include "index.h" char *prog; -size_t mem_max = 4*1024*1024; -extern char *data1_tabpath; +size_t mem_max = 0; static void abort_func (int level, const char *msg, void *info) { @@ -238,8 +239,9 @@ int main (int argc, char **argv) configName); exit (1); } - data1_tabpath = res_get (common_resource, "profilePath"); - bf_lockDir (res_get (common_resource, "lockPath")); + data1_set_tabpath (res_get (common_resource, + "profilePath")); + bf_lockDir (res_get (common_resource, "lockDir")); init_charmap(); } if (!strcmp (arg, "update")) @@ -303,7 +305,7 @@ int main (int argc, char **argv) zebraIndexLockMsg ("r"); } rec_prstat (); - inv_prstat (FNAME_WORD_DICT, FNAME_WORD_ISAM); + inv_prstat (FNAME_DICT, FNAME_ISAM); } else { @@ -367,8 +369,7 @@ int main (int argc, char **argv) if (nsections) { logf (LOG_LOG, "Merging with index"); - key_input (FNAME_WORD_DICT, FNAME_WORD_ISAM, nsections, - 60); + key_input (nsections, 60); sync (); } } diff --git a/index/zrpn.c b/index/zrpn.c index a5da244..1099c27 100644 --- a/index/zrpn.c +++ b/index/zrpn.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zrpn.c,v $ - * Revision 1.53 1996-06-26 09:21:43 adam + * Revision 1.54 1996-10-29 14:09:52 adam + * Use of cisam system - enabled if setting isamc is 1. + * + * Revision 1.53 1996/06/26 09:21:43 adam * Bug fix: local attribute set wasn't obeyed in scan. * * Revision 1.52 1996/06/17 14:26:20 adam @@ -192,6 +195,7 @@ #include #include +#include #include #include #include @@ -204,6 +208,27 @@ typedef struct { Z_AttributesPlusTerm *zapt; } AttrType; +static RSET rset_create_isamx (ZServerInfo *zi, int pos) +{ + if (zi->isam) + { + rset_isam_parms parms; + + parms.pos = pos; + parms.is = zi->isam; + return rset_create (rset_kind_isam, &parms); + } + if (zi->isamc) + { + rset_isamc_parms parms; + + parms.pos = pos; + parms.is = zi->isamc; + return rset_create (rset_kind_isamc, &parms); + } + return rset_create (rset_kind_null, NULL); +} + static int attr_find (AttrType *src, oid_value *attributeSetP) { while (src->major < src->zapt->num_attributes) @@ -495,7 +520,7 @@ static int isam_trunc_cmp (const void *p1, const void *p2) static RSET rset_trunc (ISAM isam, ISAM_P *isam_p, int no) { - + assert (isam); qsort (isam_p, no, sizeof(*isam_p), isam_trunc_cmp); return rset_trunc_r (isam, isam_p, 0, no, 100); } @@ -709,7 +734,7 @@ static int relational_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, return 0; } logf (LOG_DEBUG, "dict_lookup_grep: %s", term_dict); - r = dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info, max_pos, + r = dict_lookup_grep (zi->dict, term_dict, 0, grep_info, max_pos, 0, grep_handle); if (r) logf (LOG_WARN, "dict_lookup_grep fail, rel=gt: %d", r); @@ -806,7 +831,7 @@ static int field_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, for (i = 0; term_sub[i]; i++) verbatim_char (term_sub[i], &j, term_dict); strcpy (term_dict+j, ")"); - r = dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info, + r = dict_lookup_grep (zi->dict, term_dict, 0, grep_info, &max_pos, 0, grep_handle); if (r) logf (LOG_WARN, "dict_lookup_grep err, trunc=none:%d", r); @@ -816,7 +841,7 @@ static int field_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, for (i = 0; term_sub[i]; i++) verbatim_char (term_sub[i], &j, term_dict); strcpy (term_dict+j, ".*)"); - dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info, + dict_lookup_grep (zi->dict, term_dict, 0, grep_info, &max_pos, 0, grep_handle); break; case 2: /* left truncation */ @@ -834,7 +859,7 @@ static int field_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, else verbatim_char (term_sub[i], &j, term_dict); strcpy (term_dict+j, ")"); - r = dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info, + r = dict_lookup_grep (zi->dict, term_dict, 0, grep_info, &max_pos, 0, grep_handle); if (r) logf (LOG_WARN, "dict_lookup_grep err, trunc=#: %d", @@ -842,7 +867,7 @@ static int field_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, break; case 102: /* regular expression */ sprintf (term_dict + j, "(%s)", term_sub); - r = dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info, + r = dict_lookup_grep (zi->dict, term_dict, 0, grep_info, &max_pos, 0, grep_handle); if (r) logf (LOG_WARN, "dict_lookup_grep err, trunc=regular: %d", @@ -857,7 +882,7 @@ static int field_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, cp += 2; } sprintf (term_dict + j, "(%s)", cp); - r = dict_lookup_grep (zi->wordDict, term_dict, r, grep_info, + r = dict_lookup_grep (zi->dict, term_dict, r, grep_info, &max_pos, j, grep_handle); if (r) logf (LOG_WARN, "dict_lookup_grep err, trunc=eregular: %d", @@ -928,7 +953,7 @@ static RSET rpn_search_APT_relevance (ZServerInfo *zi, parms.key_size = sizeof(struct it_key); parms.max_rec = 100; parms.cmp = key_compare; - parms.is = zi->wordIsam; + parms.is = zi->isam; parms.no_terms = 0; if (zapt->term->which != Z_Term_general) @@ -999,7 +1024,6 @@ static RSET rpn_search_APT_cphrase (ZServerInfo *zi, oid_value attributeSet, int num_bases, char **basenames) { - rset_isam_parms parms; char termz[IT_MAX_WORD+1]; struct grep_info grep_info; RSET result; @@ -1025,12 +1049,10 @@ static RSET rpn_search_APT_cphrase (ZServerInfo *zi, result = rset_create (rset_kind_null, NULL); else if (grep_info.isam_p_indx == 1) { - parms.is = zi->wordIsam; - parms.pos = *grep_info.isam_p_buf; - result = rset_create (rset_kind_isam, &parms); + result = rset_create_isamx (zi, *grep_info.isam_p_buf); } else - result = rset_trunc (zi->wordIsam, grep_info.isam_p_buf, + result = rset_trunc (zi->isam, grep_info.isam_p_buf, grep_info.isam_p_indx); #ifdef TERM_COUNT xfree(grep_info.term_no); @@ -1186,16 +1208,12 @@ static RSET rpn_search_APT_phrase (ZServerInfo *zi, if (grep_info.isam_p_indx == 0) rset[rset_no] = rset_create (rset_kind_null, NULL); else if (grep_info.isam_p_indx > 1) - rset[rset_no] = rset_trunc (zi->wordIsam, + rset[rset_no] = rset_trunc (zi->isam, grep_info.isam_p_buf, grep_info.isam_p_indx); else { - rset_isam_parms parms; - - parms.is = zi->wordIsam; - parms.pos = *grep_info.isam_p_buf; - rset[rset_no] = rset_create (rset_kind_isam, &parms); + rset[rset_no] = rset_create_isamx (zi, *grep_info.isam_p_buf); } assert (rset[rset_no]); if (++rset_no >= sizeof(rset)/sizeof(*rset)) @@ -1423,6 +1441,7 @@ void count_set_save (RSET *r, int *count) rfd = rset_open (*r, RSETF_READ|RSETF_SORT_SYSNO); while (rset_read (*r, rfd, &key)) { + logf (LOG_DEBUG, "sysno=%-7d seqno=%d", key.sysno, key.seqno); if (key.sysno != psysno) { rset_write (w, wfd, &key); @@ -1469,7 +1488,7 @@ int rpn_search (ZServerInfo *zi, oident *attrset; oid_value attributeSet; - dict_grep_cmap (zi->wordDict, map_chrs_input); + dict_grep_cmap (zi->dict, map_chrs_input); zlog_rpn (rpn); zi->errCode = 0; @@ -1631,7 +1650,7 @@ int rpn_scan (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, trans_scan_term (zi, zapt, termz+prefix_len); - dict_scan (zi->wordDict, termz, &before_tmp, &after_tmp, scan_info, + dict_scan (zi->dict, termz, &before_tmp, &after_tmp, scan_info, scan_handle); } glist = odr_malloc (zi->odr, (before+after)*sizeof(*glist)); @@ -1645,7 +1664,6 @@ int rpn_scan (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, const char *mterm = NULL; const char *tst; RSET rset; - rset_isam_parms parms; for (j = 0; j < ord_no; j++) { @@ -1660,9 +1678,8 @@ int rpn_scan (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, if (j0 == -1) break; scan_term_untrans (zi->odr, &glist[i+before].term, mterm); - parms.is = zi->wordIsam; - parms.pos = scan_info_array[j0].list[ptr[j0]].isam_p; - rset = rset_create (rset_kind_isam, &parms); + rset = + rset_create_isamx (zi, scan_info_array[j0].list[ptr[j0]].isam_p); ptr[j0]++; for (j = j0+1; jwordIsam; - parms.pos = scan_info_array[j].list[ptr[j]].isam_p; - rset2 = rset_create (rset_kind_isam, &parms); + rset2 = rset_create_isamx + (zi, scan_info_array[j].list[ptr[j]].isam_p); bool_parms.key_size = sizeof(struct it_key); bool_parms.cmp = key_compare; @@ -1707,7 +1722,6 @@ int rpn_scan (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, const char *mterm = NULL; const char *tst; RSET rset; - rset_isam_parms parms; for (j = 0; j odr, &glist[before-1-i].term, mterm); - parms.is = zi->wordIsam; - parms.pos = scan_info_array[j0].list[before-1-ptr[j0]].isam_p; - rset = rset_create (rset_kind_isam, &parms); + rset = rset_create_isamx + (zi, scan_info_array[j0].list[before-1-ptr[j0]].isam_p); ptr[j0]++; @@ -1736,13 +1749,11 @@ int rpn_scan (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, (tst=scan_info_array[j].list[before-1-ptr[j]].term) && !strcmp (tst, mterm)) { - rset_isam_parms parms; rset_bool_parms bool_parms; RSET rset2; - parms.is = zi->wordIsam; - parms.pos = scan_info_array[j].list[before-1-ptr[j]].isam_p; - rset2 = rset_create (rset_kind_isam, &parms); + rset2 = rset_create_isamx (zi, + scan_info_array[j].list[before-1-ptr[j]].isam_p); bool_parms.key_size = sizeof(struct it_key); bool_parms.cmp = key_compare; diff --git a/index/zserver.c b/index/zserver.c index faae520..7bc66ae 100644 --- a/index/zserver.c +++ b/index/zserver.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zserver.c,v $ - * Revision 1.40 1996-06-04 10:19:02 adam + * Revision 1.41 1996-10-29 14:09:56 adam + * Use of cisam system - enabled if setting isamc is 1. + * + * Revision 1.40 1996/06/04 10:19:02 adam * Minor changes - removed include of ctype.h. * * Revision 1.39 1996/05/31 09:07:05 quinn @@ -189,18 +192,32 @@ static int register_lock (ZServerInfo *zi) if (zi->records) { zebTargetInfo_close (zi->zti, 0); - dict_close (zi->wordDict); - is_close (zi->wordIsam); + dict_close (zi->dict); + if (zi->isam) + is_close (zi->isam); + if (zi->isamc) + isc_close (zi->isamc); rec_close (&zi->records); } bf_cache (state); zi->registerState = state; zi->records = rec_open (0); - if (!(zi->wordDict = dict_open (FNAME_WORD_DICT, 40, 0))) + if (!(zi->dict = dict_open (FNAME_DICT, 40, 0))) return -1; - if (!(zi->wordIsam = is_open (FNAME_WORD_ISAM, key_compare, 0, + zi->isam = NULL; + zi->isamc = NULL; + if (res_get_match (common_resource, "isam", "c", NULL)) + { + if (!(zi->isamc = isc_open (FNAME_ISAMC, 0, key_isamc_m()))) + return -1; + + } + else + { + if (!(zi->isam = is_open (FNAME_ISAM, key_compare, 0, sizeof (struct it_key)))) - return -1; + return -1; + } zi->zti = zebTargetInfo_open (zi->records, 0); init_charmap (); return 0; @@ -246,16 +263,14 @@ bend_initresult *bend_init (bend_initrequest *q) logf (LOG_FATAL, "Cannot open resource `%s'", sob->configname); exit (1); } - bf_lockDir (res_get (common_resource, "lockPath")); - data1_tabpath = res_get(common_resource, "profilePath"); + bf_lockDir (res_get (common_resource, "lockDir")); + data1_set_tabpath (res_get(common_resource, "profilePath")); } server_info.sets = NULL; server_info.registerState = -1; /* trigger open of registers! */ server_info.registerChange = 0; server_info.records = NULL; - server_info.wordDict = NULL; - server_info.wordIsam = NULL; server_info.odr = odr_createmem (ODR_ENCODE); return &r; } @@ -475,8 +490,11 @@ void bend_close (void *handle) { if (server_info.records) { - dict_close (server_info.wordDict); - is_close (server_info.wordIsam); + dict_close (server_info.dict); + if (server_info.isam) + is_close (server_info.isam); + if (server_info.isamc) + isc_close (server_info.isamc); rec_close (&server_info.records); register_unlock (&server_info); } diff --git a/index/zserver.h b/index/zserver.h index e6636c7..0b7f310 100644 --- a/index/zserver.h +++ b/index/zserver.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zserver.h,v $ - * Revision 1.20 1996-06-04 10:19:02 adam + * Revision 1.21 1996-10-29 14:09:58 adam + * Use of cisam system - enabled if setting isamc is 1. + * + * Revision 1.20 1996/06/04 10:19:02 adam * Minor changes - removed include of ctype.h. * * Revision 1.19 1996/05/14 11:34:01 adam @@ -92,8 +95,9 @@ typedef struct { int registerState; /* 0 (no commit pages), 1 (use commit pages) */ time_t registerChange; ZServerSet *sets; - Dict wordDict; - ISAM wordIsam; + Dict dict; + ISAM isam; + ISAMC isamc; Records records; int errCode; char *errString;