-/* $Id: rstemp.c,v 1.36 2004-01-16 15:27:35 heikki Exp $
+/* $Id: rstemp.c,v 1.42 2004-08-06 12:55:03 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
static void r_close (RSFD rfd);
static void r_delete (RSET ct);
static void r_rewind (RSFD rfd);
-static int r_count (RSET ct);
+/* static int r_count (RSET ct);*/
static int r_read (RSFD rfd, void *buf, int *term_index);
static int r_write (RSFD rfd, const void *buf);
+static void r_pos (RSFD rfd, double *current, double *total);
static const struct rset_control control =
{
r_delete,
r_rewind,
rset_default_forward,
- r_count,
+ r_pos,
r_read,
r_write,
};
size_t pos_buf; /* position of first byte in window */
size_t pos_border; /* position of last byte+1 in window */
int dirty; /* window is dirty */
- int hits; /* no of hits */
+ zint hits; /* no of hits */
char *temp_path;
int (*cmp)(const void *p1, const void *p2);
struct rset_temp_rfd *rfd_list;
struct rset_temp_rfd {
struct rset_temp_info *info;
struct rset_temp_rfd *next;
- int *countp;
+ zint *countp;
void *buf;
size_t pos_cur; /* current position in set */
+ zint cur; /* number of the current hit */
};
static void *r_create(RSET ct, const struct rset_control *sel, void *parms)
info->pos_end = 0;
info->pos_buf = 0;
info->dirty = 0;
- info->hits = -1;
+ info->hits = 0;
info->cmp = temp_parms->cmp;
info->rfd_list = NULL;
((struct rset_temp_rfd *)rfd)->pos_cur = 0;
info->pos_buf = 0;
r_reread (rfd);
+ ((struct rset_temp_rfd *)rfd)->cur=0;
}
+/*
static int r_count (RSET ct)
{
struct rset_temp_info *info = (struct rset_temp_info *) ct->buf;
return info->pos_end / info->key_size;
}
-
+*/
static int r_read (RSFD rfd, void *buf, int *term_index)
{
struct rset_temp_rfd *mrfd = (struct rset_temp_rfd*) rfd;
memcpy (mrfd->buf, buf, mrfd->info->key_size);
(*mrfd->countp)++;
}
+ mrfd->cur++;
return 1;
}
mrfd->pos_cur = nc;
if (nc > info->pos_end)
info->pos_border = info->pos_end = nc;
+ info->hits++;
return 1;
}
+
+static void r_pos (RSFD rfd, double *current, double *total)
+{
+ struct rset_temp_rfd *mrfd = (struct rset_temp_rfd*) rfd;
+ *current=(double) mrfd->cur;
+ *total=(double) mrfd->info->hits;
+}