X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzsets.c;h=929db7f5410df8b6f10eed713146d862267cecfa;hb=f8732597517aa3a238e5cd61e4b4ced2425cbd05;hp=15fa83c9934bae3744a0568efa9de0786b319820;hpb=5660e317ea2972ea6bb6a4f8a415f71579f71103;p=idzebra-moved-to-github.git diff --git a/index/zsets.c b/index/zsets.c index 15fa83c..929db7f 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -1,4 +1,4 @@ -/* $Id: zsets.c,v 1.52 2004-08-06 10:09:27 heikki Exp $ +/* $Id: zsets.c,v 1.56 2004-08-19 14:47:06 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, @@ -729,6 +733,7 @@ void resultSetRank (ZebraHandle zh, ZebraSet zebraSet, RSET rset) double cur,tot; zint est=-2; /* -2 not done, -1 can't do, >0 actual estimate*/ zint esthits; + double ratio; sort_info = zebraSet->sort_info; sort_info->num_entries = 0; @@ -777,18 +782,22 @@ 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; rset_pos(rset,rfd,&cur,&tot); if (tot>0) { - f=1.0*cur/tot; - est=(zint)(0.5+zebraSet->hits/f); - /* FIXME - round the guess to 3 digits */ + ratio=cur/tot; + est=(zint)(0.5+zebraSet->hits/ratio); logf(LOG_LOG, "Estimating hits (%s) " - "%0.1f->%d" + "%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,19 @@ 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", + { + if (est>0) + rset->rset_terms[i]->count = + est=(zint)(rset->rset_terms[i]->count/ratio); + 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); }