2 * Copyright (C) 1994-1999, Index Data
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.7 1999-05-26 07:49:14 adam
10 * Revision 1.6 1999/02/02 14:51:35 adam
11 * Updated WIN32 code specific sections. Changed header.
13 * Revision 1.5 1998/03/05 08:36:28 adam
14 * New result set model.
16 * Revision 1.4 1997/12/18 10:54:25 adam
17 * New method result set method rs_hits that returns the number of
18 * hits in result-set (if known). The ranked result set returns real
19 * number of hits but only when not combined with other operands.
21 * Revision 1.3 1997/10/31 12:37:01 adam
22 * Code calls xfree() instead of free().
24 * Revision 1.2 1996/11/08 11:15:57 adam
25 * Compressed isam fully supported.
27 * Revision 1.1 1996/10/29 13:41:48 adam
37 static void *r_create(RSET ct, const struct rset_control *sel, void *parms);
38 static RSFD r_open (RSET ct, int flag);
39 static void r_close (RSFD rfd);
40 static void r_delete (RSET ct);
41 static void r_rewind (RSFD rfd);
42 static int r_count (RSET ct);
43 static int r_read (RSFD rfd, void *buf, int *term_index);
44 static int r_write (RSFD rfd, const void *buf);
46 static const struct rset_control control =
59 const struct rset_control *rset_kind_isamc = &control;
63 struct rset_pp_info *next;
64 struct rset_isamc_info *info;
67 struct rset_isamc_info {
70 struct rset_pp_info *ispt_list;
73 static void *r_create(RSET ct, const struct rset_control *sel, void *parms)
75 rset_isamc_parms *pt = (rset_isamc_parms *) parms;
76 struct rset_isamc_info *info;
78 ct->flags |= RSET_FLAG_VOLATILE;
79 info = (struct rset_isamc_info *) xmalloc (sizeof(*info));
82 info->ispt_list = NULL;
83 ct->no_rset_terms = 1;
84 ct->rset_terms = (RSET_TERM *) xmalloc (sizeof(*ct->rset_terms));
85 ct->rset_terms[0] = pt->rset_term;
89 RSFD r_open (RSET ct, int flag)
91 struct rset_isamc_info *info = (struct rset_isamc_info *) ct->buf;
92 struct rset_pp_info *ptinfo;
94 logf (LOG_DEBUG, "risamc_open");
95 if (flag & RSETF_WRITE)
97 logf (LOG_FATAL, "ISAMC set type is read-only");
100 ptinfo = (struct rset_pp_info *) xmalloc (sizeof(*ptinfo));
101 ptinfo->next = info->ispt_list;
102 info->ispt_list = ptinfo;
103 ptinfo->pt = isc_pp_open (info->is, info->pos);
105 if (ct->rset_terms[0]->nn < 0)
106 ct->rset_terms[0]->nn = isc_pp_num (ptinfo->pt);
110 static void r_close (RSFD rfd)
112 struct rset_isamc_info *info = ((struct rset_pp_info*) rfd)->info;
113 struct rset_pp_info **ptinfop;
115 for (ptinfop = &info->ispt_list; *ptinfop; ptinfop = &(*ptinfop)->next)
118 isc_pp_close ((*ptinfop)->pt);
119 *ptinfop = (*ptinfop)->next;
123 logf (LOG_FATAL, "r_close but no rfd match!");
127 static void r_delete (RSET ct)
129 struct rset_isamc_info *info = (struct rset_isamc_info *) ct->buf;
131 logf (LOG_DEBUG, "rsisamc_delete");
132 assert (info->ispt_list == NULL);
133 rset_term_destroy (ct->rset_terms[0]);
134 xfree (ct->rset_terms);
138 static void r_rewind (RSFD rfd)
140 logf (LOG_DEBUG, "rsisamc_rewind");
144 static int r_count (RSET ct)
149 static int r_read (RSFD rfd, void *buf, int *term_index)
152 return isc_pp_read( ((struct rset_pp_info*) rfd)->pt, buf);
155 static int r_write (RSFD rfd, const void *buf)
157 logf (LOG_FATAL, "ISAMC set type is read-only");