From 083d994896c30d9c560580daa19c9ca370901e3a Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 27 Sep 1995 16:17:29 +0000 Subject: [PATCH] More work on retrieve. --- include/recctrl.h | 40 +++++++++++++++++------------ index/zserver.c | 13 +++++++--- index/zserver.h | 9 ++++++- index/zsets.c | 73 ++++++++++++++++++++++++++++++++++++++++++++--------- 4 files changed, 102 insertions(+), 33 deletions(-) diff --git a/include/recctrl.h b/include/recctrl.h index 8c6f2ab..5622096 100644 --- a/include/recctrl.h +++ b/include/recctrl.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: recctrl.h,v $ - * Revision 1.3 1995-09-27 12:21:25 adam + * Revision 1.4 1995-09-27 16:17:29 adam + * More work on retrieve. + * + * Revision 1.3 1995/09/27 12:21:25 adam * New function: recType_byName. * * Revision 1.2 1995/09/15 14:45:03 adam @@ -21,6 +24,7 @@ #include #include +/* single word entity */ typedef struct { int attrSet; int attrUse; @@ -35,31 +39,35 @@ typedef struct { int seqno; } RecWord; +/* Extract record control */ struct recExtractCtrl { - FILE *inf; - char *subType; - void (*init)(RecWord *p); - void (*add)(const RecWord *p); + /* input parameters ... */ + FILE *inf; /* Extract from this file */ + char *subType; /* Sub type - may be NULL */ + void (*init)(RecWord *p); /* Init of word spec */ + void (*add)(const RecWord *p); /* Addition of a single word */ }; +/* Retrieve record control */ struct recRetrieveCtrl { - ODR odr; - int fd; + /* Input parameters ... */ + ODR odr; /* ODR used to create response */ + int fd; /* File descriptor and read function */ int (*readf)(int fd, char *buf, size_t count); - oid_value input_format; + oid_value input_format; /* Preferred record syntax */ - /* response */ - oid_value output_format; - void *rec_buf; - size_t rec_len; + /* output parameters ... */ + oid_value output_format; /* Record syntax of returned record */ + void *rec_buf; /* Record buffer */ + size_t rec_len; /* Length of record */ }; typedef struct recType { - char *name; - void (*init)(void); - int (*extract)(struct recExtractCtrl *ctrl); - int (*retrieve)(struct recRetrieveCtrl *ctrl); + char *name; /* Name of record type */ + void (*init)(void); /* Init function - called once */ + int (*extract)(struct recExtractCtrl *ctrl); /* Extract proc */ + int (*retrieve)(struct recRetrieveCtrl *ctrl); /* Retrieve proc */ } *RecType; RecType recType_byName (const char *name); diff --git a/index/zserver.c b/index/zserver.c index c36ccaf..e1413f2 100644 --- a/index/zserver.c +++ b/index/zserver.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zserver.c,v $ - * Revision 1.6 1995-09-08 08:53:22 adam + * Revision 1.7 1995-09-27 16:17:32 adam + * More work on retrieve. + * + * Revision 1.6 1995/09/08 08:53:22 adam * Record buffer maintained in server_info. * * Revision 1.5 1995/09/06 16:11:18 adam @@ -104,7 +107,7 @@ bend_fetchresult *bend_fetch (void *handle, bend_fetchrequest *q, int *num) { static bend_fetchresult r; int positions[2]; - ZServerRecord *records; + ZServerSetSysno *records; r.errstring = 0; r.last_in_set = 0; @@ -113,25 +116,27 @@ bend_fetchresult *bend_fetch (void *handle, bend_fetchrequest *q, int *num) xfree (server_info.recordBuf); server_info.recordBuf = NULL; positions[0] = q->number; - records = resultSetRecordGet (&server_info, q->setname, 1, positions); + records = resultSetSysnoGet (&server_info, q->setname, 1, positions); if (!records) { logf (LOG_DEBUG, "resultSetRecordGet, error"); r.errcode = 13; return &r; } - if (!records[0].buf) + if (!records[0].sysno) { r.errcode = 13; logf (LOG_DEBUG, "Out of range. pos=%d", q->number); return &r; } +#if 0 r.len = records[0].size; server_info.recordBuf = r.record = xmalloc (r.len+1); strcpy (r.record, records[0].buf); resultSetRecordDel (&server_info, records, 1); r.format = VAL_SUTRS; r.errcode = 0; +#endif return &r; } diff --git a/index/zserver.h b/index/zserver.h index c686aae..afce157 100644 --- a/index/zserver.h +++ b/index/zserver.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zserver.h,v $ - * Revision 1.4 1995-09-14 11:53:28 adam + * Revision 1.5 1995-09-27 16:17:32 adam + * More work on retrieve. + * + * Revision 1.4 1995/09/14 11:53:28 adam * First work on regular expressions/truncations. * * Revision 1.3 1995/09/08 08:53:23 adam @@ -27,6 +30,10 @@ typedef struct { char *buf; } ZServerRecord; +typedef struct { + int sysno; +} ZServerSetSysno; + typedef struct ZServerSet_ { char *name; RSET rset; diff --git a/index/zsets.c b/index/zsets.c index 636c5e4..00258a0 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zsets.c,v $ - * Revision 1.4 1995-09-07 13:58:36 adam + * Revision 1.5 1995-09-27 16:17:32 adam + * More work on retrieve. + * + * Revision 1.4 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. @@ -59,8 +62,62 @@ ZServerSet *resultSetGet (ZServerInfo *zi, const char *name) return NULL; } -ZServerRecord *resultSetRecordGet (ZServerInfo *zi, const char *name, - int num, int *positions) +ZServerSetSysno *resultSetSysnoGet (ZServerInfo *zi, const char *name, + int num, int *positions) +{ + ZServerSet *sset; + ZServerSetSysno *sr; + RSET rset; + int num_i = 0; + int position = 0; + int psysno = 0; + struct it_key key; + RSFD rfd; + + if (!(sset = resultSetGet (zi, name))) + return NULL; + if (!(rset = sset->rset)) + return NULL; + logf (LOG_DEBUG, "resultSetRecordGet"); + sr = xmalloc (sizeof(*sr) * num); + rfd = rset_open (rset, 0); + while (rset_read (rset, rfd, &key)) + { + if (key.sysno != psysno) + { + psysno = key.sysno; + position++; + if (position == positions[num_i]) + { + sr[num_i].sysno = psysno; + num_i++; + if (++num_i == num) + break; + } + } + } + rset_close (rset, rfd); + while (num_i < num) + { + sr[num_i].sysno = 0; + num_i++; + } + return sr; +} + +void resultSetRecordDel (ZServerInfo *zi, ZServerRecord *records, int num) +{ + int i; + + for (i = 0; i