From: Adam Dickmeiss Date: Fri, 6 Oct 1995 14:37:53 +0000 (+0000) Subject: New result set method: r_score. X-Git-Tag: ZEBRA.1.0~714 X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=commitdiff_plain;h=40ca1d08c1d83b92e0b90951d918b252c61c63b2 New result set method: r_score. Local no (sysno) and score is transferred to retrieveCtrl. --- diff --git a/include/recctrl.h b/include/recctrl.h index aa34765..3bd4557 100644 --- a/include/recctrl.h +++ b/include/recctrl.h @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: recctrl.h,v $ - * Revision 1.8 1995-10-02 15:43:35 adam + * Revision 1.9 1995-10-06 14:37:53 adam + * New result set method: r_score. + * Local no (sysno) and score is transferred to retrieveCtrl. + * + * Revision 1.8 1995/10/02 15:43:35 adam * Extract uses file descriptors instead of FILE pointers. * * Revision 1.7 1995/10/02 15:18:09 adam @@ -67,6 +71,8 @@ struct recRetrieveCtrl { int fd; /* File descriptor and read function */ int (*readf)(int fd, char *buf, size_t count); oid_value input_format; /* Preferred record syntax */ + int localno; /* local id of record */ + int score; /* score 0-1000 or -1 if none */ /* response */ oid_value output_format; diff --git a/include/rset.h b/include/rset.h index 2a86097..79b4ae6 100644 --- a/include/rset.h +++ b/include/rset.h @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rset.h,v $ - * Revision 1.7 1995-09-07 13:58:08 adam + * Revision 1.8 1995-10-06 14:37:53 adam + * New result set method: r_score. + * Local no (sysno) and score is transferred to retrieveCtrl. + * + * Revision 1.7 1995/09/07 13:58:08 adam * New parameter: result-set file descriptor (RSFD) to support multiple * positions within the same result-set. * Boolean operators: and, or, not implemented. @@ -49,6 +53,7 @@ typedef struct rset_control int (*f_count)(struct rset_control *ct); int (*f_read)(RSFD rfd, void *buf); int (*f_write)(RSFD rfd, const void *buf); + int (*f_score)(RSFD rfd, int *score); } rset_control; typedef struct rset @@ -78,4 +83,7 @@ void rset_delete(RSET rs); /* int rset_write(RSET rs, const void *buf); */ #define rset_write(rs, fd, buf) ((*(rs)->control->f_write)((fd), (buf))) +/* int rset_score(RSET rs, int *buf); */ +#define rset_score(rs, fd, score) ((*(rs)->control->f_score)((fd), (score))) + #endif diff --git a/index/zserver.c b/index/zserver.c index 797a884..0aa0b12 100644 --- a/index/zserver.c +++ b/index/zserver.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zserver.c,v $ - * Revision 1.12 1995-10-06 13:52:06 adam + * Revision 1.13 1995-10-06 14:38:00 adam + * New result set method: r_score. + * Local no (sysno) and score is transferred to retrieveCtrl. + * + * Revision 1.12 1995/10/06 13:52:06 adam * Bug fixes. Handler may abort further scanning. * * Revision 1.11 1995/10/06 10:43:57 adam @@ -125,7 +129,7 @@ static int record_read (int fd, char *buf, size_t count) return read (fd, buf, count); } -static int record_fetch (ZServerInfo *zi, int sysno, ODR stream, +static int record_fetch (ZServerInfo *zi, int sysno, int score, ODR stream, oid_value input_format, oid_value *output_format, char **rec_bufp, int *rec_lenp) { @@ -158,6 +162,9 @@ static int record_fetch (ZServerInfo *zi, int sysno, ODR stream, logf (LOG_FATAL|LOG_ERRNO, "Retrieve: Open record file %s", fname); exit (1); } + logf (LOG_DEBUG, "retrieve localno=%d score=%d", sysno, score); + retrieveCtrl.localno = sysno; + retrieveCtrl.score = score; retrieveCtrl.odr = stream; retrieveCtrl.readf = record_read; retrieveCtrl.input_format = retrieveCtrl.output_format = input_format; @@ -197,7 +204,8 @@ bend_fetchresult *bend_fetch (void *handle, bend_fetchrequest *q, int *num) logf (LOG_DEBUG, "Out of range. pos=%d", q->number); return &r; } - r.errcode = record_fetch (&server_info, records[0].sysno, q->stream, + r.errcode = record_fetch (&server_info, records[0].sysno, + records[0].score, q->stream, q->format, &r.format, &r.record, &r.len); return &r; } diff --git a/index/zserver.h b/index/zserver.h index 3c144a6..3859376 100644 --- a/index/zserver.h +++ b/index/zserver.h @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zserver.h,v $ - * Revision 1.8 1995-10-06 13:52:06 adam + * Revision 1.9 1995-10-06 14:38:01 adam + * New result set method: r_score. + * Local no (sysno) and score is transferred to retrieveCtrl. + * + * Revision 1.8 1995/10/06 13:52:06 adam * Bug fixes. Handler may abort further scanning. * * Revision 1.7 1995/10/06 10:43:57 adam @@ -42,6 +46,7 @@ typedef struct { typedef struct { int sysno; + int score; } ZServerSetSysno; typedef struct ZServerSet_ { diff --git a/index/zsets.c b/index/zsets.c index 75d5c6c..bf8e139 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zsets.c,v $ - * Revision 1.6 1995-09-28 09:19:49 adam + * Revision 1.7 1995-10-06 14:38:01 adam + * New result set method: r_score. + * Local no (sysno) and score is transferred to retrieveCtrl. + * + * Revision 1.6 1995/09/28 09:19:49 adam * xfree/xmalloc used everywhere. * Extract/retrieve method seems to work for text records. * @@ -94,6 +98,7 @@ ZServerSetSysno *resultSetSysnoGet (ZServerInfo *zi, const char *name, if (position == positions[num_i]) { sr[num_i].sysno = psysno; + rset_score (rset, rfd, &sr[num_i].score); num_i++; if (++num_i == num) break; @@ -117,85 +122,3 @@ void resultSetRecordDel (ZServerInfo *zi, ZServerRecord *records, int num) xfree (records[i].buf); xfree (records); } - - -#if 0 -ZServerSetSysno *resultSetSysno (ZServerInfo *zi, const char *name, - int num, int *positions) -{ - ZServerSet *sset; - ZServerRecord *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]) - { - FILE *inf; - char fname[SYS_IDX_ENTRY_LEN]; - - sr[num_i].buf = NULL; - if (lseek (zi->sys_idx_fd, psysno * SYS_IDX_ENTRY_LEN, - SEEK_SET) == -1) - { - logf (LOG_FATAL|LOG_ERRNO, "lseek of sys_idx"); - exit (1); - } - if (read (zi->sys_idx_fd, fname, SYS_IDX_ENTRY_LEN) == -1) - { - logf (LOG_FATAL|LOG_ERRNO, "read of sys_idx"); - exit (1); - } - if (!(inf = fopen (fname, "r"))) - logf (LOG_WARN, "fopen: %s", fname); - else - { - long size; - - fseek (inf, 0L, SEEK_END); - size = ftell (inf); - fseek (inf, 0L, SEEK_SET); - logf (LOG_DEBUG, "get sysno=%d, fname=%s, size=%ld", - psysno, fname, (long) size); - sr[num_i].buf = xmalloc (size+1); - sr[num_i].size = size; - sr[num_i].buf[size] = '\0'; - if (fread (sr[num_i].buf, size, 1, inf) != 1) - { - logf (LOG_FATAL|LOG_ERRNO, "fread %s", fname); - exit (1); - } - fclose (inf); - } - num_i++; - if (num_i == num) - break; - } - } - } - rset_close (rset, rfd); - while (num_i < num) - { - sr[num_i].buf = NULL; - sr[num_i].size = 0; - num_i++; - } - return sr; -} -#endif diff --git a/rset/rsbool.c b/rset/rsbool.c index f34a61f..c9c254a 100644 --- a/rset/rsbool.c +++ b/rset/rsbool.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rsbool.c,v $ - * Revision 1.5 1995-09-08 14:52:41 adam + * Revision 1.6 1995-10-06 14:38:05 adam + * New result set method: r_score. + * Local no (sysno) and score is transferred to retrieveCtrl. + * + * Revision 1.5 1995/09/08 14:52:41 adam * Work on relevance feedback. * * Revision 1.4 1995/09/08 08:54:04 adam @@ -39,6 +43,7 @@ static int r_read_and (RSFD rfd, void *buf); static int r_read_or (RSFD rfd, void *buf); static int r_read_not (RSFD rfd, void *buf); static int r_write (RSFD rfd, const void *buf); +static int r_score (RSFD rfd, int *score); static const rset_control control_and = { @@ -51,7 +56,8 @@ static const rset_control control_and = r_rewind, r_count, r_read_and, - r_write + r_write, + r_score }; static const rset_control control_or = @@ -65,7 +71,8 @@ static const rset_control control_or = r_rewind, r_count, r_read_or, - r_write + r_write, + r_score }; static const rset_control control_not = @@ -79,7 +86,8 @@ static const rset_control control_not = r_rewind, r_count, r_read_not, - r_write + r_write, + r_score }; @@ -320,3 +328,10 @@ static int r_write (RSFD rfd, const void *buf) logf (LOG_FATAL, "bool set type is read-only"); return -1; } + +static int r_score (RSFD rfd, int *score) +{ + *score = -1; + return -1; +} + diff --git a/rset/rsisam.c b/rset/rsisam.c index 371b7c7..ec1e203 100644 --- a/rset/rsisam.c +++ b/rset/rsisam.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rsisam.c,v $ - * Revision 1.10 1995-09-08 14:52:42 adam + * Revision 1.11 1995-10-06 14:38:05 adam + * New result set method: r_score. + * Local no (sysno) and score is transferred to retrieveCtrl. + * + * Revision 1.10 1995/09/08 14:52:42 adam * Work on relevance feedback. * * Revision 1.9 1995/09/07 13:58:43 adam @@ -48,6 +52,7 @@ static void r_rewind (RSFD rfd); static int r_count (rset_control *ct); static int r_read (RSFD rfd, void *buf); static int r_write (RSFD rfd, const void *buf); +static int r_score (RSFD rfd, int *score); static const rset_control control = { @@ -60,7 +65,8 @@ static const rset_control control = r_rewind, r_count, r_read, - r_write + r_write, + r_score }; const rset_control *rset_kind_isam = &control; @@ -162,3 +168,9 @@ static int r_write (RSFD rfd, const void *buf) logf (LOG_FATAL, "ISAM set type is read-only"); return -1; } + +static int r_score (RSFD rfd, int *score) +{ + *score = -1; + return -1; +} diff --git a/rset/rsnull.c b/rset/rsnull.c index d46c9aa..136617f 100644 --- a/rset/rsnull.c +++ b/rset/rsnull.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rsnull.c,v $ - * Revision 1.3 1995-09-08 14:52:42 adam + * Revision 1.4 1995-10-06 14:38:06 adam + * New result set method: r_score. + * Local no (sysno) and score is transferred to retrieveCtrl. + * + * Revision 1.3 1995/09/08 14:52:42 adam * Work on relevance feedback. * * Revision 1.2 1995/09/07 13:58:43 adam @@ -29,6 +33,7 @@ static void r_rewind (RSFD rfd); static int r_count (rset_control *ct); static int r_read (RSFD rfd, void *buf); static int r_write (RSFD rfd, const void *buf); +static int r_score (RSFD rfd, int *score); static const rset_control control = { @@ -41,7 +46,8 @@ static const rset_control control = r_rewind, r_count, r_read, - r_write + r_write, + r_score }; const rset_control *rset_kind_null = &control; @@ -94,3 +100,10 @@ static int r_write (RSFD rfd, const void *buf) logf (LOG_FATAL, "NULL set type is read-only"); return -1; } + +static int r_score (RSFD rfd, int *score) +{ + *score = -1; + return -1; +} + diff --git a/rset/rsrel.c b/rset/rsrel.c index 9fc32d4..0d52250 100644 --- a/rset/rsrel.c +++ b/rset/rsrel.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rsrel.c,v $ - * Revision 1.4 1995-09-14 07:48:56 adam + * Revision 1.5 1995-10-06 14:38:06 adam + * New result set method: r_score. + * Local no (sysno) and score is transferred to retrieveCtrl. + * + * Revision 1.4 1995/09/14 07:48:56 adam * Other score calculation. * * Revision 1.3 1995/09/11 15:23:40 adam @@ -35,6 +39,7 @@ static void r_rewind (RSFD rfd); static int r_count (rset_control *ct); static int r_read (RSFD rfd, void *buf); static int r_write (RSFD rfd, const void *buf); +static int r_score (RSFD rfd, int *score); static const rset_control control = { @@ -47,7 +52,8 @@ static const rset_control control = r_rewind, r_count, r_read, - r_write + r_write, + r_score }; const rset_control *rset_kind_relevance = &control; @@ -281,14 +287,23 @@ static int r_read (RSFD rfd, void *buf) if (p->position <= 0) return 0; --(p->position); - logf (LOG_DEBUG, "score: %f", - info->score_buf[info->sort_idx[p->position]]); memcpy ((char*) buf, info->key_buf + info->key_size * info->sort_idx[p->position], info->key_size); return 1; } +static int r_score (RSFD rfd, int *score) +{ + struct rset_rel_rfd *p = rfd; + struct rset_rel_info *info = p->info; + + if (p->position < 0) + return 0; + *score = (int) (1000*info->score_buf[info->sort_idx[p->position]]); + return 1; +} + static int r_write (RSFD rfd, const void *buf) { logf (LOG_FATAL, "relevance set type is read-only"); diff --git a/rset/rstemp.c b/rset/rstemp.c index 39456ef..2103959 100644 --- a/rset/rstemp.c +++ b/rset/rstemp.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rstemp.c,v $ - * Revision 1.12 1995-09-28 09:52:11 adam + * Revision 1.13 1995-10-06 14:38:06 adam + * New result set method: r_score. + * Local no (sysno) and score is transferred to retrieveCtrl. + * + * Revision 1.12 1995/09/28 09:52:11 adam * xfree/xmalloc used everywhere. * * Revision 1.11 1995/09/18 14:17:56 adam @@ -61,6 +65,7 @@ static void r_rewind (RSFD rfd); static int r_count (rset_control *ct); static int r_read (RSFD rfd, void *buf); static int r_write (RSFD rfd, const void *buf); +static int r_score (RSFD rfd, int *score); static const rset_control control = { @@ -73,7 +78,8 @@ static const rset_control control = r_rewind, r_count, r_read, - r_write + r_write, + r_score }; const rset_control *rset_kind_temp = &control; @@ -318,3 +324,8 @@ static int r_write (RSFD rfd, const void *buf) return 1; } +static int r_score (RSFD rfd, int *score) +{ + *score = -1; + return -1; +}