From 0d1685e5db9bf74ff80a4b483754532a73fcbb74 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 16 Nov 1995 15:34:54 +0000 Subject: [PATCH] Uses new record management system in both indexer and server. --- index/extract.c | 8 +++++--- index/index.h | 10 +++++++++- index/recindex.c | 15 ++++++++++----- index/zserver.c | 30 +++++++++++++++++++++++++++++- index/zserver.h | 15 +++++++++++++-- 5 files changed, 66 insertions(+), 12 deletions(-) diff --git a/index/extract.c b/index/extract.c index abe3c88..7b12e39 100644 --- a/index/extract.c +++ b/index/extract.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: extract.c,v $ - * Revision 1.24 1995-11-15 19:13:08 adam + * Revision 1.25 1995-11-16 15:34:54 adam + * Uses new record management system in both indexer and server. + * + * Revision 1.24 1995/11/15 19:13:08 adam * Work on record management. * * Revision 1.23 1995/10/27 14:00:10 adam @@ -91,8 +94,6 @@ #include #include "index.h" -#define RECORD_BASE 1 - #if RECORD_BASE #include "recindex.h" #endif @@ -432,6 +433,7 @@ void file_extract (int cmd, const char *fname, const char *kname, rec->info[0] = rec_strdup (file_type); rec->info[1] = rec_strdup (kname); rec_put (records, rec); + rec_rm (rec); #else sysno = sysno_next++; dict_insert (file_idx, kname, sizeof(sysno), &sysno); diff --git a/index/index.h b/index/index.h index f9e4825..9ebf430 100644 --- a/index/index.h +++ b/index/index.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: index.h,v $ - * Revision 1.20 1995-11-15 14:46:18 adam + * Revision 1.21 1995-11-16 15:34:55 adam + * Uses new record management system in both indexer and server. + * + * Revision 1.20 1995/11/15 14:46:18 adam * Started work on better record management system. * * Revision 1.19 1995/10/27 14:00:11 adam @@ -109,8 +112,13 @@ int merge_sort (char **buf, int from, int to); #define FNAME_WORD_DICT "worddict" #define FNAME_WORD_ISAM "wordisam" #define FNAME_FILE_DICT "filedict" + +#define RECORD_BASE 1 + +#if !RECORD_BASE #define FNAME_SYS_IDX "sysidx" #define SYS_IDX_ENTRY_LEN 120 +#endif struct strtab *strtab_mk (void); int strtab_src (struct strtab *t, const char *name, void ***infop); diff --git a/index/recindex.c b/index/recindex.c index b8ccae7..6b8f1f7 100644 --- a/index/recindex.c +++ b/index/recindex.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: recindex.c,v $ - * Revision 1.2 1995-11-15 19:13:08 adam + * Revision 1.3 1995-11-16 15:34:55 adam + * Uses new record management system in both indexer and server. + * + * Revision 1.2 1995/11/15 19:13:08 adam * Work on record management. * * Revision 1.1 1995/11/15 14:46:20 adam @@ -134,6 +137,7 @@ Records rec_open (int rw) logf (LOG_FATAL|LOG_ERRNO, "read %s", p->index_fname); exit (1); case 0: + memcpy (p->head.magic, REC_HEAD_MAGIC, sizeof(p->head.magic)); p->head.index_free = 0; p->head.index_last = 1; p->head.no_records = 0; @@ -162,7 +166,7 @@ Records rec_open (int rw) logf (LOG_FATAL|LOG_ERRNO, "open %s", p->data_fname); exit (1); } - p->cache_max = 100; + p->cache_max = 10; p->cache_cur = 0; if (!(p->record_cache = malloc (sizeof(*p->record_cache)*p->cache_max))) { @@ -264,7 +268,6 @@ static void rec_write_single (Records p, Record rec) logf (LOG_FATAL|LOG_ERRNO, "write of %s", p->data_fname); exit (1); } - got += r; } } @@ -306,7 +309,7 @@ static void rec_cache_insert (Records p, Record rec, int dirty) assert (p->cache_cur < p->cache_max); e = p->record_cache + (p->cache_cur)++; - e->dirty = 1; + e->dirty = dirty; e->rec = rec_cp (rec); } @@ -317,6 +320,9 @@ void rec_close (Records *p) rec_cache_flush (*p); free ((*p)->record_cache); + if ((*p)->rw) + rec_write_head (*p); + if ((*p)->index_fd != -1) close ((*p)->index_fd); @@ -374,7 +380,6 @@ Record rec_get (Records p, int sysno) logf (LOG_FATAL|LOG_ERRNO, "read of %s", p->data_fname); exit (1); } - got += r; } rec->sysno = sysno; diff --git a/index/zserver.c b/index/zserver.c index 8e537a5..82df2c4 100644 --- a/index/zserver.c +++ b/index/zserver.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zserver.c,v $ - * Revision 1.21 1995-11-01 16:25:52 quinn + * Revision 1.22 1995-11-16 15:34:55 adam + * Uses new record management system in both indexer and server. + * + * Revision 1.21 1995/11/01 16:25:52 quinn * *** empty log message *** * * Revision 1.20 1995/10/27 14:00:12 adam @@ -97,6 +100,9 @@ bend_initresult *bend_init (bend_initrequest *q) logf (LOG_DEBUG, "bend_init"); data1_tabpath = res_get(common_resource, "data1_tabpath"); server_info.sets = NULL; +#if RECORD_BASE + server_info.records = rec_open (0); +#else if (!(server_info.sys_idx_fd = open (FNAME_SYS_IDX, O_RDONLY))) { logf (LOG_WARN|LOG_ERRNO, "sys_idx open fail"); @@ -104,6 +110,7 @@ bend_initresult *bend_init (bend_initrequest *q) r.errstring = "sys_idx open fail"; return &r; } +#endif if (!(server_info.fileDict = dict_open (FNAME_FILE_DICT, 10, 0))) { logf (LOG_WARN, "dict_open fail: fname dict"); @@ -168,11 +175,20 @@ static int record_fetch (ZServerInfo *zi, int sysno, int score, ODR stream, oid_value *output_format, char **rec_bufp, int *rec_lenp) { +#if RECORD_BASE + Record rec; +#else char record_info[SYS_IDX_ENTRY_LEN]; +#endif char *fname, *file_type; RecType rt; struct recRetrieveCtrl retrieveCtrl; +#if RECORD_BASE + rec = rec_get (zi->records, sysno); + file_type = rec->info[0]; + fname = rec->info[1]; +#else if (lseek (zi->sys_idx_fd, sysno * SYS_IDX_ENTRY_LEN, SEEK_SET) == -1) { @@ -186,6 +202,8 @@ static int record_fetch (ZServerInfo *zi, int sysno, int score, ODR stream, } file_type = record_info; fname = record_info + strlen(record_info) + 1; +#endif + if (!(rt = recType_byName (file_type))) { logf (LOG_FATAL|LOG_ERRNO, "Retrieve: Cannot handle type %s", @@ -200,6 +218,9 @@ static int record_fetch (ZServerInfo *zi, int sysno, int score, ODR stream, *output_format = VAL_SUTRS; *rec_bufp = msg; *rec_lenp = strlen (msg); +#if RECORD_BASE + rec_rm (rec); +#endif return 0; /* or 14: System error in presenting records */ } retrieveCtrl.localno = sysno; @@ -214,6 +235,9 @@ static int record_fetch (ZServerInfo *zi, int sysno, int score, ODR stream, *rec_bufp = retrieveCtrl.rec_buf; *rec_lenp = retrieveCtrl.rec_len; close (retrieveCtrl.fd); +#if RECORD_BASE + rec_rm (rec); +#endif return retrieveCtrl.diagnostic; } @@ -281,7 +305,11 @@ void bend_close (void *handle) dict_close (server_info.fileDict); dict_close (server_info.wordDict); is_close (server_info.wordIsam); +#if RECORD_BASE + rec_close (&server_info.records); +#else close (server_info.sys_idx_fd); +#endif return; } diff --git a/index/zserver.h b/index/zserver.h index d6d6217..04547fb 100644 --- a/index/zserver.h +++ b/index/zserver.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zserver.h,v $ - * Revision 1.12 1995-10-27 14:00:12 adam + * Revision 1.13 1995-11-16 15:34:56 adam + * Uses new record management system in both indexer and server. + * + * Revision 1.12 1995/10/27 14:00:12 adam * Implemented detection of database availability. * * Revision 1.11 1995/10/17 18:02:12 adam @@ -44,10 +47,14 @@ * */ -#include "index.h" #include #include +#include "index.h" +#if RECORD_BASE +#include "recindex.h" +#endif + typedef struct { int sysno; int score; @@ -65,7 +72,11 @@ typedef struct { Dict wordDict; ISAM wordIsam; Dict fileDict; +#if RECORD_BASE + Records records; +#else int sys_idx_fd; +#endif int errCode; char *errString; ODR odr; -- 1.7.10.4