2 * Copyright (C) 1994-1998, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.5 1998-03-05 08:36:28 adam
8 * New result set model.
10 * Revision 1.4 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.3 1997/10/31 12:37:01 adam
16 * Code calls xfree() instead of free().
18 * Revision 1.2 1996/11/08 11:15:57 adam
19 * Compressed isam fully supported.
21 * Revision 1.1 1996/10/29 13:41:48 adam
31 static void *r_create(RSET ct, const struct rset_control *sel, void *parms);
32 static RSFD r_open (RSET ct, int flag);
33 static void r_close (RSFD rfd);
34 static void r_delete (RSET ct);
35 static void r_rewind (RSFD rfd);
36 static int r_count (RSET ct);
37 static int r_read (RSFD rfd, void *buf, int *term_index);
38 static int r_write (RSFD rfd, const void *buf);
40 static const struct rset_control control =
53 const struct rset_control *rset_kind_isamc = &control;
57 struct rset_pp_info *next;
58 struct rset_isamc_info *info;
61 struct rset_isamc_info {
64 struct rset_pp_info *ispt_list;
67 static void *r_create(RSET ct, const struct rset_control *sel, void *parms)
69 rset_isamc_parms *pt = parms;
70 struct rset_isamc_info *info;
72 ct->flags |= RSET_FLAG_VOLATILE;
73 info = xmalloc (sizeof(*info));
76 info->ispt_list = NULL;
77 ct->no_rset_terms = 1;
78 ct->rset_terms = xmalloc (sizeof(*ct->rset_terms));
79 ct->rset_terms[0] = pt->rset_term;
83 RSFD r_open (RSET ct, int flag)
85 struct rset_isamc_info *info = ct->buf;
86 struct rset_pp_info *ptinfo;
88 logf (LOG_DEBUG, "risamc_open");
89 if (flag & RSETF_WRITE)
91 logf (LOG_FATAL, "ISAMC set type is read-only");
94 ptinfo = xmalloc (sizeof(*ptinfo));
95 ptinfo->next = info->ispt_list;
96 info->ispt_list = ptinfo;
97 ptinfo->pt = isc_pp_open (info->is, info->pos);
99 if (ct->rset_terms[0]->nn < 0)
100 ct->rset_terms[0]->nn = isc_pp_num (ptinfo->pt);
104 static void r_close (RSFD rfd)
106 struct rset_isamc_info *info = ((struct rset_pp_info*) rfd)->info;
107 struct rset_pp_info **ptinfop;
109 for (ptinfop = &info->ispt_list; *ptinfop; ptinfop = &(*ptinfop)->next)
112 isc_pp_close ((*ptinfop)->pt);
113 *ptinfop = (*ptinfop)->next;
117 logf (LOG_FATAL, "r_close but no rfd match!");
121 static void r_delete (RSET ct)
123 struct rset_isamc_info *info = ct->buf;
125 logf (LOG_DEBUG, "rsisamc_delete");
126 assert (info->ispt_list == NULL);
127 rset_term_destroy (ct->rset_terms[0]);
128 xfree (ct->rset_terms);
132 static void r_rewind (RSFD rfd)
134 logf (LOG_DEBUG, "rsisamc_rewind");
138 static int r_count (RSET ct)
143 static int r_read (RSFD rfd, void *buf, int *term_index)
146 return isc_pp_read( ((struct rset_pp_info*) rfd)->pt, buf);
149 static int r_write (RSFD rfd, const void *buf)
151 logf (LOG_FATAL, "ISAMC set type is read-only");