-/* $Id: isamb.h,v 1.12 2004-08-04 09:59:03 heikki Exp $
+/* $Id: isamb.h,v 1.13 2004-08-06 10:09:27 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
int isamb_pp_forward (ISAMB_PP pp, void *buf, const void *untilbuf);
-void isamb_pp_pos (ISAMB_PP pp, zint *current, zint *total);
+void isamb_pp_pos (ISAMB_PP pp, double *current, double *total);
void isamb_pp_close (ISAMB_PP pp);
-/* $Id: rset.h,v 1.25 2004-08-06 09:43:03 heikki Exp $
+/* $Id: rset.h,v 1.26 2004-08-06 10:09:27 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
int (*f_forward)(RSET ct, RSFD rfd, void *buf, int *term_index,
int (*cmpfunc)(const void *p1, const void *p2),
const void *untilbuf);
- void (*f_pos)(RSFD rfd, zint *current, zint *total);
+ void (*f_pos)(RSFD rfd, double *current, double *total);
/* returns -1,-1 if pos function not implemented for this type */
int (*f_read)(RSFD rfd, void *buf, int *term_index);
int (*f_write)(RSFD rfd, const void *buf);
int rset_default_forward(RSET ct, RSFD rfd, void *buf, int *term_index,
int (*cmpfunc)(const void *p1, const void *p2),
const void *untilbuf);
-void rset_default_pos(RSFD rfd, zint *current, zint *total);
+void rset_default_pos(RSFD rfd, double *current, double *total);
struct rset_term {
char *name;
#define rset_forward(rs, fd, buf, indx, cmpfunc, untilbuf) \
(*(rs)->control->f_forward)((rs), (fd), (buf), (indx), (cmpfunc), (untilbuf))
-/* int rset_pos(RSET rs, RSFD fd, zint *current, zint *total); */
+/* int rset_pos(RSET rs, RSFD fd, double *current, double *total); */
#define rset_pos(rs,fd,cur,tot) \
(*(rs)->control->f_pos)( (fd),(cur),(tot))
-/* $Id: zsets.c,v 1.51 2004-08-06 09:43:03 heikki Exp $
+/* $Id: zsets.c,v 1.52 2004-08-06 10:09:27 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
struct rank_control *rc;
struct zset_sort_info *sort_info;
const char *rank_handler_name = res_get_def(zh->res, "rank", "rank-1");
- zint cur,tot;
+ double cur,tot;
zint est=-2; /* -2 not done, -1 can't do, >0 actual estimate*/
zint esthits;
rset_pos(rset,rfd,&cur,&tot);
if (tot>0) {
f=1.0*cur/tot;
- est=(zint)(zebraSet->hits/f);
+ est=(zint)(0.5+zebraSet->hits/f);
/* FIXME - round the guess to 3 digits */
logf(LOG_LOG, "Estimating hits (%s) "
- ZINT_FORMAT"->%d"
- "; "ZINT_FORMAT"->"ZINT_FORMAT,
+ "%0.1f->%d"
+ "; %0.1f->"ZINT_FORMAT,
rset->control->desc,
cur, zebraSet->hits,
tot,est);
-/* $Id: isamb.c,v 1.50 2004-08-06 09:43:03 heikki Exp $
+/* $Id: isamb.c,v 1.51 2004-08-06 10:09:27 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
}
static void isamb_pp_leaf_pos( ISAMB_PP pp,
- zint *current, zint *total, void *dummybuf )
+ double *current, double *total,
+ void *dummybuf )
{
struct ISAMB_block *p = pp->block[pp->level];
const char *src=p->bytes;
(*current)++;
}
#if ISAMB_DEBUG
- logf(LOG_DEBUG, "isamb_pp_leaf_pos: cur="ZINT_FORMAT" tot="ZINT_FORMAT
+ logf(LOG_DEBUG, "isamb_pp_leaf_pos: cur= %0.1f tot=%0.1f "
" ofs=%d sz=%d lev=%d",
*current, *total, p->offset, p->size, pp->level);
#endif
(pp->isamb->method->codec.stop)(decodeClientData);
}
-static void isamb_pp_upper_pos( ISAMB_PP pp, zint *current, zint *total,
+static void isamb_pp_upper_pos( ISAMB_PP pp, double *current, double *total,
zint size, int level )
{ /* estimates total/current occurrences from here up, excl leaf */
struct ISAMB_block *p = pp->block[level];
isamb_pp_upper_pos(pp, current, total, *total, level-1);
} /* upper_pos */
-void isamb_pp_pos( ISAMB_PP pp, zint *current, zint *total )
+void isamb_pp_pos( ISAMB_PP pp, double *current, double *total )
{ /* return an estimate of the current position and of the total number of */
/* occureences in the isam tree, based on the current leaf */
struct ISAMB_block *p = pp->block[pp->level];
-/* $Id: rsbool.c,v 1.34 2004-08-06 09:43:03 heikki Exp $
+/* $Id: rsbool.c,v 1.35 2004-08-06 10:09:28 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
static int r_forward(RSET ct, RSFD rfd, void *buf, int *term_index,
int (*cmpfunc)(const void *p1, const void *p2),
const void *untilbuf);
-static void r_pos (RSFD rfd, zint *current, zint *total);
+static void r_pos (RSFD rfd, double *current, double *total);
static int r_read_and (RSFD rfd, void *buf, int *term_index);
static int r_read_or (RSFD rfd, void *buf, int *term_index);
static int r_read_not (RSFD rfd, void *buf, int *term_index);
struct rset_bool_rfd *p = (struct rset_bool_rfd *) rfd;
struct rset_bool_info *info = p->info;
- { zint cur,tot; r_pos(rfd, &cur, &tot); }
-
while (p->more_l || p->more_r)
{
int cmp;
struct rset_bool_rfd *p = (struct rset_bool_rfd *) rfd;
struct rset_bool_info *info = p->info;
- { zint cur,tot; r_pos(rfd, &cur, &tot); }
while (p->more_l || p->more_r)
{
int cmp;
struct rset_bool_rfd *p = (struct rset_bool_rfd *) rfd;
struct rset_bool_info *info = p->info;
- { zint cur,tot; r_pos(rfd, &cur, &tot); }
while (p->more_l || p->more_r)
{
int cmp;
return -1;
}
-static void r_pos (RSFD rfd, zint *current, zint *total)
+static void r_pos (RSFD rfd, double *current, double *total)
{
struct rset_bool_rfd *p = (struct rset_bool_rfd *) rfd;
struct rset_bool_info *info = p->info;
- zint lcur,ltot;
- zint rcur,rtot;
- float r;
+ double lcur,ltot;
+ double rcur,rtot;
+ double r;
ltot=-1; rtot=-1;
rset_pos(info->rset_l, p->rfd_l, &lcur, <ot);
rset_pos(info->rset_r, p->rfd_r, &rcur, &rtot);
}
if ( rtot<0) { rtot=0; rcur=0;} /* if only one useful, use it */
if ( ltot<0) { ltot=0; lcur=0;}
- if ( rtot+ltot == 0 ) { /* empty rset */
+ if ( rtot+ltot < 1 ) { /* empty rset */
*current=0;
*total=0;
return;
}
r=1.0*(lcur+rcur)/(ltot+rtot); /* weighed average of l and r */
*current=p->hits;
- *total=(zint)(0.5+*current/r);
+ *total=*current/r ;
#if RSET_DEBUG
- yaz_log(LOG_DEBUG,"bool_pos: (%s/%s) "ZINT_FORMAT"/"ZINT_FORMAT"= %0.4f ",
+ yaz_log(LOG_DEBUG,"bool_pos: (%s/%s) %0.1f/%0.1f= %0.4f ",
info->rset_l->control->desc, info->rset_r->control->desc,
*current, *total, r);
#endif
-/* $Id: rset.c,v 1.22 2004-08-04 09:59:03 heikki Exp $
+/* $Id: rset.c,v 1.23 2004-08-06 10:09:28 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
return rs;
}
-void rset_default_pos (RSFD rfd, zint *current, zint *total)
-{ /* FIXME - This function should not be needed, only while */
- /* coding the pos functions. */
+void rset_default_pos (RSFD rfd, double *current, double *total)
+{ /* This should never really be needed, but it is still used in */
+ /* those rsets that we don't really plan to use, like isam-s */
assert(rfd);
assert(current);
assert(total);
-/* $Id: rsisamb.c,v 1.12 2004-08-06 09:43:04 heikki Exp $
+/* $Id: rsisamb.c,v 1.13 2004-08-06 10:09:28 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
static int r_forward(RSET ct, RSFD rfd, void *buf, int *term_index,
int (*cmpfunc)(const void *p1, const void *p2),
const void *untilbuf);
-static void r_pos (RSFD rfd, zint *current, zint *total);
+static void r_pos (RSFD rfd, double *current, double *total);
static int r_read (RSFD rfd, void *buf, int *term_index);
static int r_write (RSFD rfd, const void *buf);
return i;
}
-static void r_pos (RSFD rfd, zint *current, zint *total)
+static void r_pos (RSFD rfd, double *current, double *total)
{
struct rset_pp_info *pinfo = (struct rset_pp_info *) rfd;
assert(rfd);
isamb_pp_pos(pinfo->pt, current, total);
#if RSET_DEBUG
- logf(LOG_DEBUG,"isamb.r_pos returning "ZINT_FORMAT"/"ZINT_FORMAT,
+ logf(LOG_DEBUG,"isamb.r_pos returning %0.1f/%0.1f",
*current, *total);
#endif
}
-/* $Id: rsnull.c,v 1.19 2004-08-04 09:59:03 heikki Exp $
+/* $Id: rsnull.c,v 1.20 2004-08-06 10:09:28 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
static void r_close (RSFD rfd);
static void r_delete (RSET ct);
static void r_rewind (RSFD rfd);
-static void r_pos (RSFD rfd, zint *current, zint *total);
+static void r_pos (RSFD rfd, double *current, double *total);
static int r_read (RSFD rfd, void *buf, int *term_index);
static int r_write (RSFD rfd, const void *buf);
logf (LOG_DEBUG, "rsnull_rewind");
}
-static void r_pos (RSFD rfd, zint *current, zint *total)
+static void r_pos (RSFD rfd, double *current, double *total)
{
assert(rfd);
assert(current);
-/* $Id: rstemp.c,v 1.39 2004-08-06 09:43:04 heikki Exp $
+/* $Id: rstemp.c,v 1.40 2004-08-06 10:09:28 heikki Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
/* 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, zint *current, zint *total);
+static void r_pos (RSFD rfd, double *current, double *total);
static const struct rset_control control =
{
return 1;
}
-static void r_pos (RSFD rfd, zint *current, zint *total)
+static void r_pos (RSFD rfd, double *current, double *total)
{
struct rset_temp_rfd *mrfd = (struct rset_temp_rfd*) rfd;
*current=mrfd->cur;