* Sebastian Hammer, Adam Dickmeiss
*
* $Log: rset.h,v $
- * Revision 1.8 1995-10-06 14:37:53 adam
+ * Revision 1.9 1995-10-10 14:00:01 adam
+ * Function rset_open changed its wflag parameter to general flags.
+ *
+ * Revision 1.8 1995/10/06 14:37:53 adam
* New result set method: r_score.
* Local no (sysno) and score is transferred to retrieveCtrl.
*
rset_control *control;
} rset, *RSET;
+#define RSETF_READ 0
+#define RSETF_WRITE 1
+
+#define RSETF_SORT_SYSNO 0
+#define RSETF_SORT_RANK 2
+
RSET rset_create(const rset_control *sel, void *parms); /* parameters? */
/* int rset_open(RSET rs, int wflag); */
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: dir.c,v $
- * Revision 1.7 1995-09-28 09:19:40 adam
+ * Revision 1.8 1995-10-10 13:59:23 adam
+ * Function rset_open changed its wflag parameter to general flags.
+ *
+ * Revision 1.7 1995/09/28 09:19:40 adam
* xfree/xmalloc used everywhere.
* Extract/retrieve method seems to work for text records.
*
{
DIR *dir;
struct dirent *dent;
- size_t entry_max = 50;
+ size_t entry_max = 500;
size_t idx = 0;
struct dir_entry *entry;
{
struct dir_entry *entry_n;
- entry_n = xmalloc (sizeof(*entry) * (entry_max + 400));
+ entry_n = xmalloc (sizeof(*entry) * (entry_max + 1000));
memcpy (entry_n, entry, idx * sizeof(*entry));
xfree (entry);
entry = entry_n;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zrpn.c,v $
- * Revision 1.24 1995-10-09 16:18:37 adam
+ * Revision 1.25 1995-10-10 13:59:24 adam
+ * Function rset_open changed its wflag parameter to general flags.
+ *
+ * Revision 1.24 1995/10/09 16:18:37 adam
* Function dict_lookup_grep got extra client data parameter.
*
* Revision 1.23 1995/10/06 16:33:37 adam
ispt = xmalloc (sizeof(*ispt) * (to-from));
parms.key_size = sizeof (struct it_key);
result = rset_create (rset_kind_temp, &parms);
- rsfd = rset_open (result, 1);
+ rsfd = rset_open (result, RSETF_WRITE|RSETF_SORT_SYSNO);
ti = heap_init (to-from, sizeof(struct it_key),
key_compare);
for (i = 0; i<rset_no; i++)
{
buf[i] = xmalloc (sizeof(**buf));
- rsfd[i] = rset_open (rset[i], 0);
+ rsfd[i] = rset_open (rset[i], RSETF_READ|RSETF_SORT_SYSNO);
more[i] = rset_read (rset[i], rsfd[i], buf[i]);
}
parms.key_size = sizeof (struct it_key);
result = rset_create (rset_kind_temp, &parms);
- rsfd_result = rset_open (result, 1);
+ rsfd_result = rset_open (result, RSETF_WRITE|RSETF_SORT_SYSNO);
while (*more)
{
}
parms.key_size = sizeof (struct it_key);
result = rset_create (rset_kind_temp, &parms);
- rsfd = rset_open (result, 1);
+ rsfd = rset_open (result, RSETF_WRITE|RSETF_SORT_SYSNO);
trans_term (zi, zapt, termz);
key.sysno = atoi (termz);
logf (LOG_DEBUG, "rpn_save_set");
*count = 0;
- rfd = rset_open (r, 0);
+ rfd = rset_open (r, RSETF_READ|RSETF_SORT_SYSNO);
while (rset_read (r, rfd, &key))
{
if (key.sysno != psysno)
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zsets.c,v $
- * Revision 1.7 1995-10-06 14:38:01 adam
+ * Revision 1.8 1995-10-10 13:59:25 adam
+ * Function rset_open changed its wflag parameter to general flags.
+ *
+ * Revision 1.7 1995/10/06 14:38:01 adam
* New result set method: r_score.
* Local no (sysno) and score is transferred to retrieveCtrl.
*
return NULL;
logf (LOG_DEBUG, "resultSetRecordGet");
sr = xmalloc (sizeof(*sr) * num);
- rfd = rset_open (rset, 0);
+ rfd = rset_open (rset, RSETF_READ|RSETF_SORT_RANK);
while (rset_read (rset, rfd, &key))
{
if (key.sysno != psysno)
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: rsbool.c,v $
- * Revision 1.6 1995-10-06 14:38:05 adam
+ * Revision 1.7 1995-10-10 14:00:03 adam
+ * Function rset_open changed its wflag parameter to general flags.
+ *
+ * Revision 1.6 1995/10/06 14:38:05 adam
* New result set method: r_score.
* Local no (sysno) and score is transferred to retrieveCtrl.
*
#include <alexutil.h>
static rset_control *r_create(const struct rset_control *sel, void *parms);
-static RSFD r_open (rset_control *ct, int wflag);
+static RSFD r_open (rset_control *ct, int flag);
static void r_close (RSFD rfd);
static void r_delete (rset_control *ct);
static void r_rewind (RSFD rfd);
return newct;
}
-static RSFD r_open (rset_control *ct, int wflag)
+static RSFD r_open (rset_control *ct, int flag)
{
struct rset_bool_info *info = ct->buf;
struct rset_bool_rfd *rfd;
- if (wflag)
+ if (flag & RSETF_WRITE)
{
logf (LOG_FATAL, "bool set type is read-only");
return NULL;
rfd->buf_l = xmalloc (info->key_size);
rfd->buf_r = xmalloc (info->key_size);
- rfd->rfd_l = rset_open (info->rset_l, wflag);
- rfd->rfd_r = rset_open (info->rset_r, wflag);
+ rfd->rfd_l = rset_open (info->rset_l, flag);
+ rfd->rfd_r = rset_open (info->rset_r, flag);
rfd->more_l = rset_read (info->rset_l, rfd->rfd_l, rfd->buf_l);
rfd->more_r = rset_read (info->rset_r, rfd->rfd_r, rfd->buf_r);
rfd->info = info;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: rsisam.c,v $
- * Revision 1.11 1995-10-06 14:38:05 adam
+ * Revision 1.12 1995-10-10 14:00:04 adam
+ * Function rset_open changed its wflag parameter to general flags.
+ *
+ * Revision 1.11 1995/10/06 14:38:05 adam
* New result set method: r_score.
* Local no (sysno) and score is transferred to retrieveCtrl.
*
#include <alexutil.h>
static rset_control *r_create(const struct rset_control *sel, void *parms);
-static RSFD r_open (rset_control *ct, int wflag);
+static RSFD r_open (rset_control *ct, int flag);
static void r_close (RSFD rfd);
static void r_delete (rset_control *ct);
static void r_rewind (RSFD rfd);
return newct;
}
-RSFD r_open (rset_control *ct, int wflag)
+RSFD r_open (rset_control *ct, int flag)
{
struct rset_isam_info *info = ct->buf;
struct rset_ispt_info *ptinfo;
logf (LOG_DEBUG, "risam_open");
- if (wflag)
+ if (flag & RSETF_WRITE)
{
logf (LOG_FATAL, "ISAM set type is read-only");
return NULL;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: rsnull.c,v $
- * Revision 1.4 1995-10-06 14:38:06 adam
+ * Revision 1.5 1995-10-10 14:00:04 adam
+ * Function rset_open changed its wflag parameter to general flags.
+ *
+ * Revision 1.4 1995/10/06 14:38:06 adam
* New result set method: r_score.
* Local no (sysno) and score is transferred to retrieveCtrl.
*
#include <alexutil.h>
static rset_control *r_create(const struct rset_control *sel, void *parms);
-static RSFD r_open (rset_control *ct, int wflag);
+static RSFD r_open (rset_control *ct, int flag);
static void r_close (RSFD rfd);
static void r_delete (rset_control *ct);
static void r_rewind (RSFD rfd);
return newct;
}
-static RSFD r_open (rset_control *ct, int wflag)
+static RSFD r_open (rset_control *ct, int flag)
{
- if (wflag)
+ if (flag & RSETF_WRITE)
{
logf (LOG_FATAL, "NULL set type is read-only");
return NULL;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: rsrel.c,v $
- * Revision 1.5 1995-10-06 14:38:06 adam
+ * Revision 1.6 1995-10-10 14:00:04 adam
+ * Function rset_open changed its wflag parameter to general flags.
+ *
+ * Revision 1.5 1995/10/06 14:38:06 adam
* New result set method: r_score.
* Local no (sysno) and score is transferred to retrieveCtrl.
*
#include <alexutil.h>
static rset_control *r_create(const struct rset_control *sel, void *parms);
-static RSFD r_open (rset_control *ct, int wflag);
+static RSFD r_open (rset_control *ct, int flag);
static void r_close (RSFD rfd);
static void r_delete (rset_control *ct);
static void r_rewind (RSFD rfd);
int max_rec;
int no_rec;
int (*cmp)(const void *p1, const void *p2);
- char *key_buf;
- float *score_buf;
- int *sort_idx;
-
+ char *key_buf; /* key buffer */
+ float *score_buf; /* score buffer */
+ int *sort_idx; /* score sorted index */
+ int *sysno_idx; /* sysno sorted index (ring buffer) */
+ int sysno_idx_p; /* last sysno sort index */
struct rset_rel_rfd *rfd_list;
};
struct rset_rel_rfd {
int position;
+ int flag;
struct rset_rel_rfd *next;
struct rset_rel_info *info;
};
break;
}
if (info->no_rec < info->max_rec)
- {
+ { /* there is room for this entry */
for (j = info->no_rec; j > i; --j)
info->sort_idx[j] = info->sort_idx[j-1];
idx = info->sort_idx[j] = info->no_rec;
++(info->no_rec);
}
else if (i == 0)
- return;
+ return; /* score too low */
else
{
- idx = info->sort_idx[0];
+ idx = info->sort_idx[0]; /* remove this entry */
--i;
- for (j = 0; j < i; ++j)
+ for (j = 0; j < i; ++j) /* make room */
info->sort_idx[j] = info->sort_idx[j+1];
- info->sort_idx[j] = idx;
+ info->sort_idx[j] = idx; /* allocate sort entry */
}
+ info->sysno_idx[info->sysno_idx_p] = idx;
+ if (++(info->sysno_idx_p) == info->max_rec)
+ info->sysno_idx_p = 0;
+
memcpy (info->key_buf + idx*info->key_size, key, info->key_size);
info->score_buf[idx] = score;
}
info->key_buf = xmalloc (info->key_size * info->max_rec);
info->score_buf = xmalloc (sizeof(*info->score_buf) * info->max_rec);
info->sort_idx = xmalloc (sizeof(*info->sort_idx) * info->max_rec);
+ info->sysno_idx = xmalloc (sizeof(*info->sysno_idx) * info->max_rec);
+ info->sysno_idx_p = 0;
info->no_rec = 0;
info->rfd_list = NULL;
return newct;
}
-static RSFD r_open (rset_control *ct, int wflag)
+static RSFD r_open (rset_control *ct, int flag)
{
struct rset_rel_rfd *rfd;
struct rset_rel_info *info = ct->buf;
- if (wflag)
+ if (flag & RSETF_WRITE)
{
logf (LOG_FATAL, "relevance set type is read-only");
return NULL;
}
rfd = xmalloc (sizeof(*rfd));
+ rfd->flag = flag;
rfd->next = info->rfd_list;
info->rfd_list = rfd;
rfd->position = info->no_rec;
xfree (info->key_buf);
xfree (info->score_buf);
xfree (info->sort_idx);
+ xfree (info->sysno_idx);
xfree (info);
xfree (ct);
}
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: rstemp.c,v $
- * Revision 1.13 1995-10-06 14:38:06 adam
+ * Revision 1.14 1995-10-10 14:00:04 adam
+ * Function rset_open changed its wflag parameter to general flags.
+ *
+ * Revision 1.13 1995/10/06 14:38:06 adam
* New result set method: r_score.
* Local no (sysno) and score is transferred to retrieveCtrl.
*
#include <rstemp.h>
static rset_control *r_create(const struct rset_control *sel, void *parms);
-static RSFD r_open (rset_control *ct, int wflag);
+static RSFD r_open (rset_control *ct, int flag);
static void r_close (RSFD rfd);
static void r_delete (rset_control *ct);
static void r_rewind (RSFD rfd);
return newct;
}
-static RSFD r_open (struct rset_control *ct, int wflag)
+static RSFD r_open (struct rset_control *ct, int flag)
{
struct rset_temp_info *info = ct->buf;
struct rset_temp_rfd *rfd;
assert (info->fd == -1);
if (info->fname)
{
- if (wflag)
+ if (flag & RSETF_WRITE)
info->fd = open (info->fname, O_RDWR|O_CREAT, 0666);
else
info->fd = open (info->fname, O_RDONLY);