From: Heikki Levanto Date: Wed, 14 Jul 1999 13:21:34 +0000 (+0000) Subject: Added isam-d files. Compiles (almost) clean. Doesn't work at all X-Git-Tag: ZEBRA.1.0~71 X-Git-Url: http://lists.indexdata.dk/cgi-bin?a=commitdiff_plain;h=e8f4cf34c75ffdc7bbfaf3fa232f29cc1384b60c;p=idzebra-moved-to-github.git Added isam-d files. Compiles (almost) clean. Doesn't work at all --- diff --git a/include/isamd.h b/include/isamd.h index acd2024..cf3c0cc 100644 --- a/include/isamd.h +++ b/include/isamd.h @@ -12,8 +12,8 @@ * */ -#ifndef ISAMH_H -#define ISAMH_H +#ifndef ISAMD_H +#define ISAMD_H #include @@ -21,22 +21,22 @@ extern "C" { #endif -typedef struct ISAMH_s *ISAMH; -typedef int ISAMH_P; -typedef struct ISAMH_PP_s *ISAMH_PP; +typedef struct ISAMD_s *ISAMD; +typedef int ISAMD_P; +typedef struct ISAMD_PP_s *ISAMD_PP; -typedef struct ISAMH_filecat_s { /* filecategories, mostly block sizes */ +typedef struct ISAMD_filecat_s { /* filecategories, mostly block sizes */ int bsize; /* block size */ int mblocks; /* maximum keys before switching to larger sizes */ -} *ISAMH_filecat; +} *ISAMD_filecat; -typedef struct ISAMH_M_s { - ISAMH_filecat filecat; +typedef struct ISAMD_M_s { + ISAMD_filecat filecat; int (*compare_item)(const void *a, const void *b); -#define ISAMH_DECODE 0 -#define ISAMH_ENCODE 1 +#define ISAMD_DECODE 0 +#define ISAMD_ENCODE 1 void *(*code_start)(int mode); void (*code_stop)(int mode, void *p); void (*code_item)(int mode, void *p, char **dst, char **src); @@ -44,46 +44,49 @@ typedef struct ISAMH_M_s { int max_blocks_mem; int debug; -} *ISAMH_M; +} *ISAMD_M; -typedef struct ISAMH_I_s { /* encapsulation of input data */ +typedef struct ISAMD_I_s { /* encapsulation of input data */ int (*read_item)(void *clientData, char **dst, int *insertMode); void *clientData; -} *ISAMH_I; +} *ISAMD_I; -ISAMH_M isamd_getmethod (void); +ISAMD_M isamd_getmethod (ISAMD_M me); -ISAMH isamd_open (BFiles bfs, const char *name, int writeflag, ISAMH_M method); -int isamd_close (ISAMH is); -ISAMH_P isamd_append (ISAMH is, ISAMH_P pos, ISAMH_I data); +ISAMD isamd_open (BFiles bfs, const char *name, int writeflag, ISAMD_M method); +int isamd_close (ISAMD is); +ISAMD_P isamd_append (ISAMD is, ISAMD_P pos, ISAMD_I data); /* corresponds to isc_merge */ -ISAMH_PP isamd_pp_open (ISAMH is, ISAMH_P pos); -void isamd_pp_close (ISAMH_PP pp); -int isamd_read_item (ISAMH_PP pp, char **dst); -int isamd_pp_read (ISAMH_PP pp, void *buf); -int isamd_pp_num (ISAMH_PP pp); +ISAMD_PP isamd_pp_open (ISAMD is, ISAMD_P pos); +void isamd_pp_close (ISAMD_PP pp); +int isamd_read_item (ISAMD_PP pp, char **dst); +int isamd_pp_read (ISAMD_PP pp, void *buf); +int isamd_pp_num (ISAMD_PP pp); -int isamd_block_used (ISAMH is, int type); -int isamd_block_size (ISAMH is, int type); +int isamd_block_used (ISAMD is, int type); +int isamd_block_size (ISAMD is, int type); #define isamd_type(x) ((x) & 7) #define isamd_block(x) ((x) >> 3) #define isamd_addr(blk,typ) (((blk)<<3)+(typ)) -void isamd_buildfirstblock(ISAMH_PP pp); -void isamd_buildlaterblock(ISAMH_PP pp); +void isamd_buildfirstblock(ISAMD_PP pp); +void isamd_buildlaterblock(ISAMD_PP pp); #ifdef __cplusplus } #endif -#endif /* ISAMH_H */ +#endif /* ISAMD_H */ /* - * $Log: $ + * $Log: isamd.h,v $ + * Revision 1.1 1999/07/14 12:34:43 heikki + * Copied from isamh, starting to change things... + * * */ diff --git a/index/index.h b/index/index.h index b3f906d..e7c61de 100644 --- a/index/index.h +++ b/index/index.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -102,6 +103,7 @@ void key_input (BFiles bfs, int nkeys, int cache); ISAMC_M key_isamc_m (Res res, ISAMC_M me); ISAMS_M key_isams_m (Res res, ISAMS_M me); ISAMH_M key_isamh_m (Res res); +ISAMD_M key_isamd_m (Res res, ISAMD_M me); int merge_sort (char **buf, int from, int to); int key_SU_code (int ch, char *out); @@ -110,6 +112,7 @@ int key_SU_code (int ch, char *out); #define FNAME_ISAMC "isamc" #define FNAME_ISAMS "isams" #define FNAME_ISAMH "isamh" +#define FNAME_ISAMD "isamd" #define FNAME_CONFIG "zebra.cfg" #define GMATCH_DICT "gmatch" @@ -158,7 +161,10 @@ extern Res common_resource; /* * $Log: index.h,v $ - * Revision 1.65 1999-07-14 10:59:26 adam + * Revision 1.66 1999-07-14 13:21:34 heikki + * Added isam-d files. Compiles (almost) clean. Doesn't work at all + * + * Revision 1.65 1999/07/14 10:59:26 adam * Changed functions isc_getmethod, isams_getmethod. * Improved fatal error handling (such as missing EXPLAIN schema). * diff --git a/index/kcompare.c b/index/kcompare.c index ec85430..39ee853 100644 --- a/index/kcompare.c +++ b/index/kcompare.c @@ -1,123 +1,13 @@ /* * Copyright (C) 1994-1999, Index Data * All rights reserved. - * Sebastian Hammer, Adam Dickmeiss - * - * $Log: kcompare.c,v $ - * Revision 1.33 1999-07-14 10:59:26 adam - * Changed functions isc_getmethod, isams_getmethod. - * Improved fatal error handling (such as missing EXPLAIN schema). - * - * Revision 1.32 1999/07/13 13:21:15 heikki - * Managing negative deltas - * - * Revision 1.31 1999/07/06 09:37:04 heikki - * Working on isamh - not ready yet. - * - * Revision 1.30 1999/06/30 15:07:23 heikki - * Adding isamh stuff - * - * Revision 1.29 1999/06/30 09:08:23 adam - * Added coder to reset. - * - * Revision 1.28 1999/05/26 07:49:13 adam - * C++ compilation. - * - * Revision 1.27 1999/05/12 13:08:06 adam - * First version of ISAMS. - * - * Revision 1.26 1999/02/02 14:50:54 adam - * Updated WIN32 code specific sections. Changed header. - * - * Revision 1.25 1998/06/08 15:26:06 adam - * Minor changes. - * - * Revision 1.24 1998/06/08 14:43:12 adam - * Added suport for EXPLAIN Proxy servers - added settings databasePath - * and explainDatabase to facilitate this. Increased maximum number - * of databases and attributes in one register. - * - * Revision 1.23 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.22 1997/09/22 12:39:06 adam - * Added get_pos method for the ranked result sets. - * - * Revision 1.21 1997/09/17 12:19:13 adam - * Zebra version corresponds to YAZ version 1.4. - * Changed Zebra server so that it doesn't depend on global common_resource. - * - * Revision 1.20 1996/12/23 15:30:44 adam - * Work on truncation. - * Bug fix: result sets weren't deleted after server shut down. - * - * Revision 1.19 1996/12/11 12:08:00 adam - * Added better compression. - * - * 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 - * Work on compaction of set/use bytes in dictionary. - * - * Revision 1.15 1995/11/20 16:59:46 adam - * New update method: the 'old' keys are saved for each records. - * - * Revision 1.14 1995/10/30 15:08:08 adam - * Bug fixes. - * - * Revision 1.13 1995/10/27 14:00:11 adam - * Implemented detection of database availability. - * - * Revision 1.12 1995/10/17 18:02:08 adam - * New feature: databases. Implemented as prefix to words in dictionary. - * - * Revision 1.11 1995/10/06 16:33:37 adam - * Use attribute mappings. - * - * Revision 1.10 1995/09/29 14:01:41 adam - * Bug fixes. - * - * Revision 1.9 1995/09/28 12:10:32 adam - * Bug fixes. Field prefix used in queries. - * - * Revision 1.8 1995/09/28 09:19:42 adam - * xfree/xmalloc used everywhere. - * Extract/retrieve method seems to work for text records. - * - * Revision 1.7 1995/09/27 12:22:28 adam - * More work on extract in record control. - * Field name is not in isam keys but in prefix in dictionary words. - * - * Revision 1.6 1995/09/14 07:48:23 adam - * Record control management. - * - * Revision 1.5 1995/09/11 13:09:34 adam - * More work on relevance feedback. - * - * Revision 1.4 1995/09/08 14:52:27 adam - * Minor changes. Dictionary is lower case now. - * - * Revision 1.3 1995/09/07 13:58:36 adam - * New parameter: result-set file descriptor (RSFD) to support multiple - * positions within the same result-set. - * Boolean operators: and, or, not implemented. - * Result-set references. - * - * Revision 1.2 1995/09/06 16:11:17 adam - * Option: only one word key per file. - * - * Revision 1.1 1995/09/04 09:10:36 adam - * More work on index add/del/update. - * Merge sort implemented. - * Initial work on z39 server. + * Sebastian Hammer, Adam Dickmeiss, Heikki Levanto + * log at the end * + * $Id */ + #include #include #include @@ -363,6 +253,23 @@ ISAMH_M key_isamh_m (Res res) return me; } +ISAMD_M key_isamd_m (Res res,ISAMD_M me) +{ + + me = isamd_getmethod (me); + + me->compare_item = key_compare; + + me->code_start = iscz1_code_start; + me->code_item = iscz1_code_item; + me->code_stop = iscz1_code_stop; + me->code_reset = iscz1_code_reset; + + me->debug = atoi(res_get_def (res, "isamdDebug", "0")); + + return me; +} + int key_SU_code (int ch, char *out) { @@ -377,3 +284,123 @@ int key_SU_code (int ch, char *out) } return i; } + + +/* + * $Log: kcompare.c,v $ + * Revision 1.34 1999-07-14 13:21:34 heikki + * Added isam-d files. Compiles (almost) clean. Doesn't work at all + * + * Revision 1.33 1999/07/14 10:59:26 adam + * Changed functions isc_getmethod, isams_getmethod. + * Improved fatal error handling (such as missing EXPLAIN schema). + * + * Revision 1.32 1999/07/13 13:21:15 heikki + * Managing negative deltas + * + * Revision 1.31 1999/07/06 09:37:04 heikki + * Working on isamh - not ready yet. + * + * Revision 1.30 1999/06/30 15:07:23 heikki + * Adding isamh stuff + * + * Revision 1.29 1999/06/30 09:08:23 adam + * Added coder to reset. + * + * Revision 1.28 1999/05/26 07:49:13 adam + * C++ compilation. + * + * Revision 1.27 1999/05/12 13:08:06 adam + * First version of ISAMS. + * + * Revision 1.26 1999/02/02 14:50:54 adam + * Updated WIN32 code specific sections. Changed header. + * + * Revision 1.25 1998/06/08 15:26:06 adam + * Minor changes. + * + * Revision 1.24 1998/06/08 14:43:12 adam + * Added suport for EXPLAIN Proxy servers - added settings databasePath + * and explainDatabase to facilitate this. Increased maximum number + * of databases and attributes in one register. + * + * Revision 1.23 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.22 1997/09/22 12:39:06 adam + * Added get_pos method for the ranked result sets. + * + * Revision 1.21 1997/09/17 12:19:13 adam + * Zebra version corresponds to YAZ version 1.4. + * Changed Zebra server so that it doesn't depend on global common_resource. + * + * Revision 1.20 1996/12/23 15:30:44 adam + * Work on truncation. + * Bug fix: result sets weren't deleted after server shut down. + * + * Revision 1.19 1996/12/11 12:08:00 adam + * Added better compression. + * + * 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 + * Work on compaction of set/use bytes in dictionary. + * + * Revision 1.15 1995/11/20 16:59:46 adam + * New update method: the 'old' keys are saved for each records. + * + * Revision 1.14 1995/10/30 15:08:08 adam + * Bug fixes. + * + * Revision 1.13 1995/10/27 14:00:11 adam + * Implemented detection of database availability. + * + * Revision 1.12 1995/10/17 18:02:08 adam + * New feature: databases. Implemented as prefix to words in dictionary. + * + * Revision 1.11 1995/10/06 16:33:37 adam + * Use attribute mappings. + * + * Revision 1.10 1995/09/29 14:01:41 adam + * Bug fixes. + * + * Revision 1.9 1995/09/28 12:10:32 adam + * Bug fixes. Field prefix used in queries. + * + * Revision 1.8 1995/09/28 09:19:42 adam + * xfree/xmalloc used everywhere. + * Extract/retrieve method seems to work for text records. + * + * Revision 1.7 1995/09/27 12:22:28 adam + * More work on extract in record control. + * Field name is not in isam keys but in prefix in dictionary words. + * + * Revision 1.6 1995/09/14 07:48:23 adam + * Record control management. + * + * Revision 1.5 1995/09/11 13:09:34 adam + * More work on relevance feedback. + * + * Revision 1.4 1995/09/08 14:52:27 adam + * Minor changes. Dictionary is lower case now. + * + * Revision 1.3 1995/09/07 13:58:36 adam + * New parameter: result-set file descriptor (RSFD) to support multiple + * positions within the same result-set. + * Boolean operators: and, or, not implemented. + * Result-set references. + * + * Revision 1.2 1995/09/06 16:11:17 adam + * Option: only one word key per file. + * + * Revision 1.1 1995/09/04 09:10:36 adam + * More work on index add/del/update. + * Merge sort implemented. + * Initial work on z39 server. + * + */ diff --git a/index/kinput.c b/index/kinput.c index b2cf034..9a2d6c1 100644 --- a/index/kinput.c +++ b/index/kinput.c @@ -208,6 +208,7 @@ struct heap_info { ISAMC isamc; ISAMS isams; ISAMH isamh; + ISAMD isamd; }; struct heap_info *key_heap_init (int nkeys, @@ -478,6 +479,60 @@ int heap_inph (struct heap_info *hi) return 0; } +int heap_inpd (struct heap_info *hi) +{ + struct heap_cread_info hci; + ISAMD_I isamd_i = (ISAMD_I) xmalloc (sizeof(*isamd_i)); + + hci.key = (char *) xmalloc (KEY_SIZE); + hci.mode = 1; + hci.hi = hi; + hci.more = heap_read_one (hi, hci.cur_name, hci.key); + + isamd_i->clientData = &hci; + isamd_i->read_item = heap_cread_item; + + while (hci.more) + { + char this_name[INP_NAME_MAX]; + ISAMD_P isamd_p, isamd_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))) + { + memcpy (&isamd_p, dict_info+1, sizeof(ISAMD_P)); + isamd_p2 = isamd_append (hi->isamd, isamd_p, isamd_i); + if (!isamd_p2) + { + no_deletions++; + if (!dict_delete (hi->dict, this_name)) + abort(); + } + else + { + no_updates++; + if (isamd_p2 != isamd_p) + dict_insert (hi->dict, this_name, + sizeof(ISAMD_P), &isamd_p2); + } + } + else + { + isamd_p = isamd_append (hi->isamd, 0, isamd_i); + no_insertions++; + dict_insert (hi->dict, this_name, sizeof(ISAMD_P), &isamd_p); + } + } + xfree (isamd_i); + return 0; +} + + + + int heap_inp (struct heap_info *hi) { char *info; @@ -591,6 +646,7 @@ void key_input (BFiles bfs, int nkeys, int cache) ISAMC isamc = NULL; ISAMS isams = NULL; ISAMH isamh = NULL; + ISAMD isamd = NULL; struct key_file **kf; char rbuf[1024]; int i, r; @@ -648,6 +704,17 @@ void key_input (BFiles bfs, int nkeys, int cache) exit (1); } } + else if (res_get_match (common_resource, "isam", "d", NULL)) + { + struct ISAMD_M_s isamd_m; + isamd = isamd_open (bfs, FNAME_ISAMD, 1, + key_isamd_m (common_resource,&isamd_m)); + if (!isamd) + { + logf (LOG_FATAL, "isamd_open fail"); + exit (1); + } + } else { struct ISAMC_M_s isamc_m; @@ -678,6 +745,7 @@ void key_input (BFiles bfs, int nkeys, int cache) hi->isamc = isamc; hi->isams = isams; hi->isamh = isamh; + hi->isamd = isamd; for (i = 1; i<=nkeys; i++) if ((r = key_file_read (kf[i], rbuf))) @@ -690,6 +758,8 @@ void key_input (BFiles bfs, int nkeys, int cache) heap_inp (hi); else if (isamh) heap_inph (hi); + else if (isamd) + heap_inpd (hi); dict_close (dict); if (isam) @@ -700,6 +770,8 @@ void key_input (BFiles bfs, int nkeys, int cache) isams_close (isams); if (isamh) isamh_close (isamh); + if (isamd) + isamd_close (isamd); for (i = 1; i<=nkeys; i++) { @@ -717,7 +789,10 @@ void key_input (BFiles bfs, int nkeys, int cache) /* * $Log: kinput.c,v $ - * Revision 1.36 1999-07-14 10:59:26 adam + * Revision 1.37 1999-07-14 13:21:34 heikki + * Added isam-d files. Compiles (almost) clean. Doesn't work at all + * + * Revision 1.36 1999/07/14 10:59:26 adam * Changed functions isc_getmethod, isams_getmethod. * Improved fatal error handling (such as missing EXPLAIN schema). * diff --git a/isamc/Makefile.in b/isamc/Makefile.in index e925140..316c008 100644 --- a/isamc/Makefile.in +++ b/isamc/Makefile.in @@ -1,7 +1,7 @@ # Copyright (C) 1996-1998, Index Data # All rights reserved. # Sebastian Hammer, Adam Dickmeiss -# $Id: Makefile.in,v 1.5 1999-06-30 15:03:55 heikki Exp $ +# $Id: Makefile.in,v 1.6 1999-07-14 13:21:34 heikki Exp $ SHELL=/bin/sh @@ -18,7 +18,7 @@ INCLUDE=-I../include $(YAZINC) TPROG1=isamctst DEFS=$(CDEFS) $(INCLUDE) LIB=../lib/isamc.a -PO = isamc.o isamh.o merge.o isams.o +PO = isamc.o isamh.o isamd.o merge.o merge-d.o isams.o all: $(LIB) @@ -37,7 +37,7 @@ $(LIB): $(PO) $(CC) -c $(DEFS) $(CFLAGS) $< clean: - rm -f *.[oa] $(TPROG1) core mon.out gmon.out errlist + rm -f *.[oa] $(TPROG1) core mon.out gmon.out errlist *~ depend: sed '/^#Depend/q' Makefile.tmp diff --git a/isamc/isamd-p.h b/isamc/isamd-p.h index 0c62419..81d1530 100644 --- a/isamc/isamd-p.h +++ b/isamc/isamd-p.h @@ -16,12 +16,12 @@ extern "C" { typedef struct { int lastblock; int freelist; -} ISAMH_head; +} ISAMD_head; -typedef unsigned ISAMH_BLOCK_SIZE; +typedef unsigned ISAMD_BLOCK_SIZE; -typedef struct ISAMH_file_s { - ISAMH_head head; +typedef struct ISAMD_file_s { + ISAMD_head head; BFile bf; int head_is_dirty; @@ -45,44 +45,44 @@ typedef struct ISAMH_file_s { int fc_max; int *fc_list; -} *ISAMH_file; +} *ISAMD_file; -struct ISAMH_s { +struct ISAMD_s { int no_files; int max_cat; // char *merge_buf; char *startblock; /* start of the chain, update lastptr and numKeys here */ char *lastblock; /* end of the chain, append here */ - ISAMH_M method; - ISAMH_file files; + ISAMD_M method; + ISAMD_file files; }; -struct ISAMH_PP_s { +struct ISAMD_PP_s { char *buf; - ISAMH_BLOCK_SIZE offset; - ISAMH_BLOCK_SIZE size; + ISAMD_BLOCK_SIZE offset; + ISAMD_BLOCK_SIZE size; int cat; /* category of this block */ int pos; /* block number of this block */ int next; /* number of the next block */ - ISAMH is; + ISAMD is; void *decodeClientData; int deleteFlag; int numKeys; - ISAMH_BLOCK_SIZE lastblock; /* last block in chain */ + ISAMD_BLOCK_SIZE lastblock; /* last block in chain */ }; -#define ISAMH_BLOCK_OFFSET_N (sizeof(int) + \ - sizeof(ISAMH_BLOCK_SIZE)) +#define ISAMD_BLOCK_OFFSET_N (sizeof(int) + \ + sizeof(ISAMD_BLOCK_SIZE)) /* == 8 */ -#define ISAMH_BLOCK_OFFSET_1 (sizeof(int) + \ - sizeof(ISAMH_BLOCK_SIZE) + \ +#define ISAMD_BLOCK_OFFSET_1 (sizeof(int) + \ + sizeof(ISAMD_BLOCK_SIZE) + \ sizeof(int) + \ - sizeof(ISAMH_BLOCK_SIZE)) + sizeof(ISAMD_BLOCK_SIZE)) /* == 16 */ -int isamd_alloc_block (ISAMH is, int cat); -void isamd_release_block (ISAMH is, int cat, int pos); -int isamd_read_block (ISAMH is, int cat, int pos, char *dst); -int isamd_write_block (ISAMH is, int cat, int pos, char *src); +int isamd_alloc_block (ISAMD is, int cat); +void isamd_release_block (ISAMD is, int cat, int pos); +int isamd_read_block (ISAMD is, int cat, int pos, char *dst); +int isamd_write_block (ISAMD is, int cat, int pos, char *src); #ifdef __cplusplus } @@ -92,7 +92,10 @@ int isamd_write_block (ISAMH is, int cat, int pos, char *src); /* * $Log: isamd-p.h,v $ - * Revision 1.1 1999-07-14 12:34:43 heikki + * Revision 1.2 1999-07-14 13:21:34 heikki + * Added isam-d files. Compiles (almost) clean. Doesn't work at all + * + * Revision 1.1 1999/07/14 12:34:43 heikki * Copied from isamh, starting to change things... * *