2 * Copyright (C) 1994-1999, Index Data
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.6 1999-02-02 14:51:35 adam
8 * Updated WIN32 code specific sections. Changed header.
10 * Revision 1.5 1998/03/05 08:36:28 adam
11 * New result set model.
13 * Revision 1.4 1997/12/18 10:54:25 adam
14 * New method result set method rs_hits that returns the number of
15 * hits in result-set (if known). The ranked result set returns real
16 * number of hits but only when not combined with other operands.
18 * Revision 1.3 1997/10/31 12:37:01 adam
19 * Code calls xfree() instead of free().
21 * Revision 1.2 1996/11/08 11:15:57 adam
22 * Compressed isam fully supported.
24 * Revision 1.1 1996/10/29 13:41:48 adam
34 static void *r_create(RSET ct, const struct rset_control *sel, void *parms);
35 static RSFD r_open (RSET ct, int flag);
36 static void r_close (RSFD rfd);
37 static void r_delete (RSET ct);
38 static void r_rewind (RSFD rfd);
39 static int r_count (RSET ct);
40 static int r_read (RSFD rfd, void *buf, int *term_index);
41 static int r_write (RSFD rfd, const void *buf);
43 static const struct rset_control control =
56 const struct rset_control *rset_kind_isamc = &control;
60 struct rset_pp_info *next;
61 struct rset_isamc_info *info;
64 struct rset_isamc_info {
67 struct rset_pp_info *ispt_list;
70 static void *r_create(RSET ct, const struct rset_control *sel, void *parms)
72 rset_isamc_parms *pt = parms;
73 struct rset_isamc_info *info;
75 ct->flags |= RSET_FLAG_VOLATILE;
76 info = xmalloc (sizeof(*info));
79 info->ispt_list = NULL;
80 ct->no_rset_terms = 1;
81 ct->rset_terms = xmalloc (sizeof(*ct->rset_terms));
82 ct->rset_terms[0] = pt->rset_term;
86 RSFD r_open (RSET ct, int flag)
88 struct rset_isamc_info *info = ct->buf;
89 struct rset_pp_info *ptinfo;
91 logf (LOG_DEBUG, "risamc_open");
92 if (flag & RSETF_WRITE)
94 logf (LOG_FATAL, "ISAMC set type is read-only");
97 ptinfo = xmalloc (sizeof(*ptinfo));
98 ptinfo->next = info->ispt_list;
99 info->ispt_list = ptinfo;
100 ptinfo->pt = isc_pp_open (info->is, info->pos);
102 if (ct->rset_terms[0]->nn < 0)
103 ct->rset_terms[0]->nn = isc_pp_num (ptinfo->pt);
107 static void r_close (RSFD rfd)
109 struct rset_isamc_info *info = ((struct rset_pp_info*) rfd)->info;
110 struct rset_pp_info **ptinfop;
112 for (ptinfop = &info->ispt_list; *ptinfop; ptinfop = &(*ptinfop)->next)
115 isc_pp_close ((*ptinfop)->pt);
116 *ptinfop = (*ptinfop)->next;
120 logf (LOG_FATAL, "r_close but no rfd match!");
124 static void r_delete (RSET ct)
126 struct rset_isamc_info *info = ct->buf;
128 logf (LOG_DEBUG, "rsisamc_delete");
129 assert (info->ispt_list == NULL);
130 rset_term_destroy (ct->rset_terms[0]);
131 xfree (ct->rset_terms);
135 static void r_rewind (RSFD rfd)
137 logf (LOG_DEBUG, "rsisamc_rewind");
141 static int r_count (RSET ct)
146 static int r_read (RSFD rfd, void *buf, int *term_index)
149 return isc_pp_read( ((struct rset_pp_info*) rfd)->pt, buf);
152 static int r_write (RSFD rfd, const void *buf)
154 logf (LOG_FATAL, "ISAMC set type is read-only");