2 * Copyright (C) 1994-1998, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.18 1998-03-05 08:36:28 adam
8 * New result set model.
10 * Revision 1.17 1997/12/18 10:54:25 adam
11 * New method result set method rs_hits that returns the number of
12 * hits in result-set (if known). The ranked result set returns real
13 * number of hits but only when not combined with other operands.
15 * Revision 1.16 1997/10/31 12:37:01 adam
16 * Code calls xfree() instead of free().
18 * Revision 1.15 1996/10/29 13:55:22 adam
19 * Include of zebrautl.h instead of alexutil.h.
21 * Revision 1.14 1995/12/11 09:15:24 adam
22 * New set types: sand/sor/snot - ranked versions of and/or/not in
23 * ranked/semi-ranked result sets.
24 * Note: the snot not finished yet.
25 * New rset member: flag.
26 * Bug fix: r_delete in rsrel.c did free bad memory block.
28 * Revision 1.13 1995/10/12 12:41:56 adam
29 * Private info (buf) moved from struct rset_control to struct rset.
30 * Bug fixes in relevance.
32 * Revision 1.12 1995/10/10 14:00:04 adam
33 * Function rset_open changed its wflag parameter to general flags.
35 * Revision 1.11 1995/10/06 14:38:05 adam
36 * New result set method: r_score.
37 * Local no (sysno) and score is transferred to retrieveCtrl.
39 * Revision 1.10 1995/09/08 14:52:42 adam
40 * Work on relevance feedback.
42 * Revision 1.9 1995/09/07 13:58:43 adam
43 * New parameter: result-set file descriptor (RSFD) to support multiple
44 * positions within the same result-set.
45 * Boolean operators: and, or, not implemented.
47 * Revision 1.8 1995/09/06 16:11:56 adam
48 * More work on boolean sets.
50 * Revision 1.7 1995/09/06 10:35:44 adam
51 * Null set implemented.
53 * Revision 1.6 1995/09/05 11:43:24 adam
54 * Complete version of temporary sets. Not tested yet though.
56 * Revision 1.5 1995/09/04 12:33:56 adam
57 * Various cleanup. YAZ util used instead.
59 * Revision 1.4 1995/09/04 09:10:55 adam
62 * Revision 1.3 1994/11/22 13:15:37 quinn
65 * Revision 1.2 1994/11/04 14:53:12 quinn
75 static void *r_create(RSET ct, const struct rset_control *sel, void *parms);
76 static RSFD r_open (RSET ct, int flag);
77 static void r_close (RSFD rfd);
78 static void r_delete (RSET ct);
79 static void r_rewind (RSFD rfd);
80 static int r_count (RSET ct);
81 static int r_read (RSFD rfd, void *buf, int *term_index);
82 static int r_write (RSFD rfd, const void *buf);
84 static const struct rset_control control =
97 const struct rset_control *rset_kind_isam = &control;
99 struct rset_ispt_info {
101 struct rset_ispt_info *next;
102 struct rset_isam_info *info;
105 struct rset_isam_info {
108 struct rset_ispt_info *ispt_list;
111 static void *r_create(RSET ct, const struct rset_control *sel, void *parms)
113 rset_isam_parms *pt = parms;
114 struct rset_isam_info *info;
116 ct->flags |= RSET_FLAG_VOLATILE;
117 info = xmalloc (sizeof(struct rset_isam_info));
120 info->ispt_list = NULL;
122 ct->no_rset_terms = 1;
123 ct->rset_terms = xmalloc (sizeof(*ct->rset_terms));
124 ct->rset_terms[0] = pt->rset_term;
128 RSFD r_open (RSET ct, int flag)
130 struct rset_isam_info *info = ct->buf;
131 struct rset_ispt_info *ptinfo;
133 logf (LOG_DEBUG, "risam_open");
134 if (flag & RSETF_WRITE)
136 logf (LOG_FATAL, "ISAM set type is read-only");
139 ptinfo = xmalloc (sizeof(*ptinfo));
140 ptinfo->next = info->ispt_list;
141 info->ispt_list = ptinfo;
142 ptinfo->pt = is_position (info->is, info->pos);
145 if (ct->rset_terms[0]->nn < 0)
146 ct->rset_terms[0]->nn = is_numkeys (ptinfo->pt);
150 static void r_close (RSFD rfd)
152 struct rset_isam_info *info = ((struct rset_ispt_info*) rfd)->info;
153 struct rset_ispt_info **ptinfop;
155 for (ptinfop = &info->ispt_list; *ptinfop; ptinfop = &(*ptinfop)->next)
158 is_pt_free ((*ptinfop)->pt);
159 *ptinfop = (*ptinfop)->next;
163 logf (LOG_FATAL, "r_close but no rfd match!");
167 static void r_delete (RSET ct)
169 struct rset_isam_info *info = ct->buf;
171 logf (LOG_DEBUG, "rsisam_delete");
172 assert (info->ispt_list == NULL);
173 rset_term_destroy (ct->rset_terms[0]);
174 xfree (ct->rset_terms);
178 static void r_rewind (RSFD rfd)
180 logf (LOG_DEBUG, "rsisam_rewind");
181 is_rewind( ((struct rset_ispt_info*) rfd)->pt);
184 static int r_count (RSET ct)
189 static int r_read (RSFD rfd, void *buf, int *term_index)
192 return is_readkey( ((struct rset_ispt_info*) rfd)->pt, buf);
195 static int r_write (RSFD rfd, const void *buf)
197 logf (LOG_FATAL, "ISAM set type is read-only");