X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=rset%2Frsmultiandor.c;h=9a8853471399cf549152905cba3e2172e23ac44a;hb=73bedd5ba9152c9c107b502fae65723b551aff09;hp=fceb7727b7559d59862c57c7329dc7badb88e9fc;hpb=0229bb1ac74706a4e460a11a8a8712b4ea0f2ebe;p=idzebra-moved-to-github.git diff --git a/rset/rsmultiandor.c b/rset/rsmultiandor.c index fceb772..9a88534 100644 --- a/rset/rsmultiandor.c +++ b/rset/rsmultiandor.c @@ -1,4 +1,4 @@ -/* $Id: rsmultiandor.c,v 1.6 2004-10-15 10:07:34 heikki Exp $ +/* $Id: rsmultiandor.c,v 1.8 2004-10-26 15:32:11 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -55,11 +55,13 @@ static int r_forward_and(RSFD rfd, void *buf, TERMID *term, static int r_forward_or(RSFD rfd, void *buf, TERMID *term, const void *untilbuf); static void r_pos (RSFD rfd, double *current, double *total); +static void r_get_terms(RSET ct, TERMID *terms, int maxterms, int *curterm); static const struct rset_control control_or = { "multi-or", r_delete, + r_get_terms, r_open_or, r_close, r_forward_or, @@ -71,6 +73,7 @@ static const struct rset_control control_and = { "multi-and", r_delete, + r_get_terms, r_open_and, r_close, r_forward_and, @@ -559,17 +562,19 @@ static void r_pos (RSFD rfd, double *current, double *total) int i; for (i=0; ino_rsets; i++){ rset_pos(mrfd->items[i].fd, &cur, &tot); - logf(LOG_DEBUG, "r_pos: %d %0.1f %0.1f", i, cur,tot); + /*logf(LOG_LOG, "r_pos: %d %0.1f %0.1f", i, cur,tot); */ scur += cur; stot += tot; } if (stot <1.0) { /* nothing there */ *current=0; *total=0; + /* logf(LOG_LOG, "r_pos: NULL %0.1f %0.1f", *current, *total);*/ return; } *current=mrfd->hits; *total=*current*stot/scur; + /*logf(LOG_LOG, "r_pos: = %0.1f %0.1f", *current, *total);*/ } @@ -579,3 +584,24 @@ static int r_write (RSFD rfd, const void *buf) logf (LOG_FATAL, "multior set type is read-only"); return -1; } + +static void r_get_terms(RSET ct, TERMID *terms, int maxterms, int *curterm) + /* Special case: Some multi-ors have all terms pointing to the same */ + /* term. We do not want to duplicate those. Other multiors (and ands) */ + /* have different terms under them. Those we want. */ +{ + struct rset_multiandor_info *info = + (struct rset_multiandor_info *) ct->priv; + int firstterm= *curterm; + int i; + for (i=0;ino_rsets;i++) + { + rset_getterms(info->rsets[i], terms, maxterms, curterm); + if ( ( (*curterm) > firstterm+1 ) && + ( (*curterm) <= maxterms ) && + ( terms[(*curterm)-1] == terms[firstterm] ) ) + (*curterm)--; /* forget the term, seen that before */ + } +} + +