X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=rset%2Frsprox.c;h=9a9951a4ea4ce7d25ef6d827b62aa82cafe4c651;hp=fa35f3872a5a82d96da5476593918c7cf4fdf567;hb=96e4c5479e111511f5df3531b6648931251b9e5d;hpb=379800be28dc31b4a50747b9d5e0912d91ba8f87 diff --git a/rset/rsprox.c b/rset/rsprox.c index fa35f38..9a9951a 100644 --- a/rset/rsprox.c +++ b/rset/rsprox.c @@ -1,5 +1,5 @@ /* This file is part of the Zebra server. - Copyright (C) 1994-2009 Index Data + Copyright (C) 1994-2011 Index Data Zebra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -17,6 +17,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#if HAVE_CONFIG_H +#include +#endif #include #include #include @@ -313,39 +316,27 @@ static void r_pos(RSFD rfd, double *current, double *total) RSET ct = rfd->rset; struct rset_prox_rfd *p = (struct rset_prox_rfd *)(rfd->priv); int i; - double r = 0.0; - double cur, tot = -1.0; - double scur = 0.0, stot = 0.0; - - yaz_log(YLOG_DEBUG, "rsprox_pos"); - + double ratio = 0.0; + for (i = 0; i < ct->no_children; i++) { - rset_pos(p->rfd[i], &cur, &tot); - if (tot > 0) + double cur, tot; + rset_pos(p->rfd[i], &cur, &tot); + if (tot > 0.0) { - scur += cur; - stot += tot; + double nratio = cur / tot; + if (ratio < nratio) + ratio = nratio; } } - if (tot < 0) - { /* nothing found */ - *current = -1; - *total = -1; - } - else if (tot < 1) - { /* most likely tot==0 */ - *current = 0; - *total = 0; - } + *current = (double) p->hits; + if (ratio > 0.0) + *total = *current/ratio; else - { - r = scur/stot; - *current = (double) p->hits; - *total = *current/r ; - } - yaz_log(YLOG_DEBUG,"prox_pos: [%d] %0.1f/%0.1f= %0.4f ", - i,*current, *total, r); + *total = 0.0; + + yaz_log(YLOG_DEBUG, "prox_pos: [%d] %0.1f/%0.1f= %0.4f ", + i, *current, *total, ratio); } static void r_get_terms(RSET ct, TERMID *terms, int maxterms, int *curterm)