X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzsets.c;h=1e0a590a42c7573d5513aa8a1d9389d416c9d206;hb=0245f556af399689056b7810ed0e3de93021ad4a;hp=2963e4fd7878adf97369d6fc73c61a0c275ea1fb;hpb=e5652ee69c5a71f19ea16455b48d22a78fb5fcdd;p=idzebra-moved-to-github.git diff --git a/index/zsets.c b/index/zsets.c index 2963e4f..1e0a590 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -1,10 +1,33 @@ /* - * Copyright (C) 1995, Index Data I/S + * Copyright (C) 1994-1995, Index Data I/S * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * * $Log: zsets.c,v $ - * Revision 1.2 1995-09-06 10:33:04 adam + * Revision 1.8 1995-10-10 13:59:25 adam + * Function rset_open changed its wflag parameter to general flags. + * + * 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. + * + * 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. + * Result-set references. + * + * Revision 1.3 1995/09/06 16:11:19 adam + * Option: only one word key per file. + * + * Revision 1.2 1995/09/06 10:33:04 adam * More work on present. Some log messages removed. * * Revision 1.1 1995/09/05 15:28:40 adam @@ -50,16 +73,17 @@ 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; - ZServerRecord *sr; + 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; @@ -67,8 +91,8 @@ ZServerRecord *resultSetRecordGet (ZServerInfo *zi, const char *name, return NULL; logf (LOG_DEBUG, "resultSetRecordGet"); sr = xmalloc (sizeof(*sr) * num); - rset_open (rset, 0); - while (rset_read (rset, &key)) + rfd = rset_open (rset, RSETF_READ|RSETF_SORT_RANK); + while (rset_read (rset, rfd, &key)) { if (key.sysno != psysno) { @@ -76,53 +100,18 @@ ZServerRecord *resultSetRecordGet (ZServerInfo *zi, const char *name, 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); - } + sr[num_i].sysno = psysno; + rset_score (rset, rfd, &sr[num_i].score); num_i++; - if (num_i == num) + if (++num_i == num) break; } } } - rset_close (rset); + rset_close (rset, rfd); while (num_i < num) { - sr[num_i].buf = NULL; - sr[num_i].size = 0; + sr[num_i].sysno = 0; num_i++; } return sr; @@ -133,6 +122,6 @@ void resultSetRecordDel (ZServerInfo *zi, ZServerRecord *records, int num) int i; for (i = 0; i