X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzserver.c;h=b036efeb05d90f83922713a31f71e435607a7af6;hb=9ee84acdcad18fe55bced224f47e57eb057923f1;hp=863780af7af83946c43c8baa8921cffd9c3e75ac;hpb=2811f2e2fb2101a75e89e8b3e0358635e86ab71d;p=idzebra-moved-to-github.git diff --git a/index/zserver.c b/index/zserver.c index 863780a..b036efe 100644 --- a/index/zserver.c +++ b/index/zserver.c @@ -4,7 +4,23 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zserver.c,v $ - * Revision 1.9 1995-10-02 15:18:52 adam + * Revision 1.14 1995-10-09 16:18:37 adam + * Function dict_lookup_grep got extra client data parameter. + * + * 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 + * Scan added. 'occurrences' in scan entries not set yet. + * + * Revision 1.10 1995/10/02 16:43:32 quinn + * Set default resulting record type in fetch. + * + * Revision 1.9 1995/10/02 15:18:52 adam * New member in recRetrieveCtrl: diagnostic. * * Revision 1.8 1995/09/28 09:19:47 adam @@ -41,7 +57,6 @@ #include #include -#include #include #include "zserver.h" @@ -85,7 +100,7 @@ bend_initresult *bend_init (bend_initrequest *q) r.errstring = "is_open fail: wordisam"; return &r; } - server_info.recordBuf = NULL; + server_info.odr = odr_createmem (ODR_ENCODE); return &r; } @@ -97,6 +112,8 @@ bend_searchresult *bend_search (void *handle, bend_searchrequest *q, int *fd) r.errstring = 0; r.hits = 0; + odr_reset (server_info.odr); + server_info.errCode = 0; switch (q->query->which) { case Z_Query_type_1: @@ -115,7 +132,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) { @@ -148,9 +165,12 @@ 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 = input_format; + retrieveCtrl.input_format = retrieveCtrl.output_format = input_format; retrieveCtrl.diagnostic = 0; (*rt->retrieve)(&retrieveCtrl); *output_format = retrieveCtrl.output_format; @@ -170,8 +190,9 @@ bend_fetchresult *bend_fetch (void *handle, bend_fetchrequest *q, int *num) r.last_in_set = 0; r.basename = "base"; - xfree (server_info.recordBuf); - server_info.recordBuf = NULL; + odr_reset (server_info.odr); + server_info.errCode = 0; + positions[0] = q->number; records = resultSetSysnoGet (&server_info, q->setname, 1, positions); if (!records) @@ -186,7 +207,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; } @@ -198,22 +220,19 @@ bend_deleteresult *bend_delete (void *handle, bend_deleterequest *q, int *num) bend_scanresult *bend_scan (void *handle, bend_scanrequest *q, int *num) { - static struct scan_entry list[200]; - static char buf[200][200]; static bend_scanresult r; - int i; + int status; + odr_reset (server_info.odr); + server_info.errCode = 0; + + r.errstring = 0; r.term_position = q->term_position; r.num_entries = q->num_entries; - r.entries = list; - for (i = 0; i < r.num_entries; i++) - { - list[i].term = buf[i]; - sprintf(list[i].term, "term-%d", i+1); - list[i].occurrences = rand() % 100000; - } - r.errcode = 0; - r.errstring = 0; + r.errcode = rpn_scan (&server_info, server_info.odr, q->term, + &r.term_position, + &r.num_entries, &r.entries, &status); + r.status = status; return &r; } @@ -223,8 +242,6 @@ void bend_close (void *handle) dict_close (server_info.wordDict); is_close (server_info.wordIsam); close (server_info.sys_idx_fd); - xfree (server_info.recordBuf); - server_info.recordBuf = NULL; return; }