2 * Copyright (C) 1994-1995, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.11 1996-12-23 15:30:46 adam
9 * Bug fix: result sets weren't deleted after server shut down.
11 * Revision 1.10 1995/10/30 15:08:08 adam
14 * Revision 1.9 1995/10/17 18:02:14 adam
15 * New feature: databases. Implemented as prefix to words in dictionary.
17 * Revision 1.8 1995/10/10 13:59:25 adam
18 * Function rset_open changed its wflag parameter to general flags.
20 * Revision 1.7 1995/10/06 14:38:01 adam
21 * New result set method: r_score.
22 * Local no (sysno) and score is transferred to retrieveCtrl.
24 * Revision 1.6 1995/09/28 09:19:49 adam
25 * xfree/xmalloc used everywhere.
26 * Extract/retrieve method seems to work for text records.
28 * Revision 1.5 1995/09/27 16:17:32 adam
29 * More work on retrieve.
31 * Revision 1.4 1995/09/07 13:58:36 adam
32 * New parameter: result-set file descriptor (RSFD) to support multiple
33 * positions within the same result-set.
34 * Boolean operators: and, or, not implemented.
35 * Result-set references.
37 * Revision 1.3 1995/09/06 16:11:19 adam
38 * Option: only one word key per file.
40 * Revision 1.2 1995/09/06 10:33:04 adam
41 * More work on present. Some log messages removed.
43 * Revision 1.1 1995/09/05 15:28:40 adam
44 * More work on search engine.
54 ZServerSet *resultSetAdd (ZServerInfo *zi, const char *name, int ov, RSET rset)
58 for (s = zi->sets; s; s = s->next)
59 if (!strcmp (s->name, name))
63 rset_delete (s->rset);
67 s = xmalloc (sizeof(*s));
70 s->name = xmalloc (strlen(name)+1);
71 strcpy (s->name, name);
76 ZServerSet *resultSetGet (ZServerInfo *zi, const char *name)
80 for (s = zi->sets; s; s = s->next)
81 if (!strcmp (s->name, name))
86 void resultSetDestroy (ZServerInfo *zi)
90 for (s = zi->sets; s; s = s1)
93 rset_delete (s->rset);
100 ZServerSetSysno *resultSetSysnoGet (ZServerInfo *zi, const char *name,
101 int num, int *positions)
112 if (!(sset = resultSetGet (zi, name)))
114 if (!(rset = sset->rset))
116 logf (LOG_DEBUG, "resultSetRecordGet");
117 sr = xmalloc (sizeof(*sr) * num);
118 rfd = rset_open (rset, RSETF_READ|RSETF_SORT_RANK);
119 while (rset_read (rset, rfd, &key))
121 if (key.sysno != psysno)
125 assert (num_i < num);
126 if (position == positions[num_i])
128 sr[num_i].sysno = psysno;
129 rset_score (rset, rfd, &sr[num_i].score);
135 rset_close (rset, rfd);
144 void resultSetSysnoDel (ZServerInfo *zi, ZServerSetSysno *records, int num)