X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=index%2Fzsets.c;h=b24840029739595b2b1d6b8aae195d220157316f;hb=8e1f2d86ffca33a892160b77147deb37f95d75d1;hp=69d659075059b7361c2eff1cc801a74a413b4890;hpb=4da0cd2978c9a902be772e95302e6522175402fd;p=idzebra-moved-to-github.git diff --git a/index/zsets.c b/index/zsets.c index 69d6590..b248400 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -1,4 +1,4 @@ -/* $Id: zsets.c,v 1.51 2004-08-06 09:43:03 heikki Exp $ +/* $Id: zsets.c,v 1.55 2004-08-10 08:19:15 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -46,7 +46,7 @@ struct zebra_set { char *name; RSET rset; NMEM nmem; - int hits; + zint hits; int num_bases; char **basenames; Z_RPNQuery *rpn; @@ -111,6 +111,7 @@ void resultSetAddTerm (ZebraHandle zh, ZebraSet s, int reg_type, const char *db, int set, int use, const char *term) { + assert(zh); /* compiler shut up */ if (!s->nmem) s->nmem = nmem_create (); if (!s->term_entries) @@ -136,7 +137,7 @@ void resultSetAddTerm (ZebraHandle zh, ZebraSet s, int reg_type, int zebra_resultSetTerms (ZebraHandle zh, const char *setname, - int no, int *count, + int no, zint *count, int *type, char *out, size_t *len) { ZebraSet s = resultSetGet (zh, setname); @@ -432,6 +433,7 @@ ZebraPosSet zebraPosSetCreate (ZebraHandle zh, const char *name, void zebraPosSetDestroy (ZebraHandle zh, ZebraPosSet records, int num) { + assert(zh); /* compiler shut up about unused arg */ xfree (records); } @@ -521,6 +523,7 @@ void resultSetInsertRank (ZebraHandle zh, struct zset_sort_info *sort_info, { struct zset_sort_entry *new_entry = NULL; int i, j; + assert(zh); /* compiler shut up about unused arg */ i = sort_info->num_entries; while (--i >= 0) @@ -617,6 +620,7 @@ void resultSetSortSingle (ZebraHandle zh, NMEM nmem, RSFD rfd; yaz_log (LOG_LOG, "resultSetSortSingle start"); + assert(nmem); /* compiler shut up about unused param */ sset->sort_info->num_entries = 0; sset->hits = 0; @@ -697,7 +701,7 @@ void resultSetSortSingle (ZebraHandle zh, NMEM nmem, rset_close (rset, rfd); for (i = 0; i < rset->no_rset_terms; i++) - yaz_log (LOG_LOG, "term=\"%s\" nn=%d type=%s count=%d", + yaz_log (LOG_LOG, "term=\"%s\" nn=" ZINT_FORMAT " type=%s count=" ZINT_FORMAT, rset->rset_terms[i]->name, rset->rset_terms[i]->nn, rset->rset_terms[i]->flags, @@ -726,7 +730,7 @@ void resultSetRank (ZebraHandle zh, ZebraSet zebraSet, RSET rset) 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; @@ -777,18 +781,23 @@ void resultSetRank (ZebraHandle zh, ZebraSet zebraSet, RSET rset) (*rc->add) (handle, this_sys, term_index); if ( (est==-2) && (zebraSet->hits==esthits)) { /* time to estimate the hits */ - float f; + double f; rset_pos(rset,rfd,&cur,&tot); if (tot>0) { - f=1.0*cur/tot; - est=(zint)(zebraSet->hits/f); - /* FIXME - round the guess to 3 digits */ + f=cur/tot; + est=(zint)(0.5+zebraSet->hits/f); logf(LOG_LOG, "Estimating hits (%s) " - ZINT_FORMAT"->%d" - "; "ZINT_FORMAT"->"ZINT_FORMAT, + "%0.1f->"ZINT_FORMAT + "; %0.1f->"ZINT_FORMAT, rset->control->desc, cur, zebraSet->hits, tot,est); + i=0; /* round to 3 significant digits */ + while (est>1000) { + est/=10; + i++; + } + while (i--) est*=10; zebraSet->hits=est; } } @@ -802,13 +811,13 @@ void resultSetRank (ZebraHandle zh, ZebraSet zebraSet, RSET rset) rset_close (rset, rfd); for (i = 0; i < rset->no_rset_terms; i++) - yaz_log (LOG_LOG, "term=\"%s\" nn=%d type=%s count=%d", + yaz_log (LOG_LOG, "term=\"%s\" nn=" ZINT_FORMAT " type=%s count=" ZINT_FORMAT, rset->rset_terms[i]->name, rset->rset_terms[i]->nn, rset->rset_terms[i]->flags, rset->rset_terms[i]->count); - yaz_log (LOG_LOG, ZINT_FORMAT " keys, %d distinct sysnos", + yaz_log (LOG_LOG, ZINT_FORMAT " keys, "ZINT_FORMAT" distinct sysnos", kno, zebraSet->hits); }