From: Adam Dickmeiss Date: Wed, 16 Jun 2004 21:29:49 +0000 (+0000) Subject: Enabling rsprox. Tests OK X-Git-Tag: ZEBRA.1.3.16~37 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=b24dc9a2d7ed255ed3b4f4ba35f11656aa89ef03;p=idzebra-moved-to-github.git Enabling rsprox. Tests OK --- diff --git a/index/zrpn.c b/index/zrpn.c index 2a4b593..4ec577c 100644 --- a/index/zrpn.c +++ b/index/zrpn.c @@ -1,4 +1,4 @@ -/* $Id: zrpn.c,v 1.139 2004-06-02 12:29:03 adam Exp $ +/* $Id: zrpn.c,v 1.140 2004-06-16 21:29:49 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -38,6 +38,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include #include +#include struct rpn_char_map_info { ZebraMaps zm; @@ -1252,238 +1253,6 @@ static int trans_scan_term (ZebraHandle zh, Z_AttributesPlusTerm *zapt, return 0; } -static RSET rpn_prox (ZebraHandle zh, RSET *rset, int rset_no, - int ordered, int exclusion, int relation, int distance) -{ - int i; - RSFD *rsfd; - int *more; - struct it_key **buf; - RSET result; - char prox_term[1024]; - int length_prox_term = 0; - int min_nn = 10000000; - int term_index; - int term_type = Z_Term_characterString; - const char *flags = NULL; - - rsfd = (RSFD *) xmalloc (sizeof(*rsfd)*rset_no); - more = (int *) xmalloc (sizeof(*more)*rset_no); - buf = (struct it_key **) xmalloc (sizeof(*buf)*rset_no); - - *prox_term = '\0'; - for (i = 0; ino_rset_terms; j++) - { - const char *nflags = rset[i]->rset_terms[j]->flags; - char *term = rset[i]->rset_terms[j]->name; - int lterm = strlen(term); - if (lterm + length_prox_term < sizeof(prox_term)-1) - { - if (length_prox_term) - prox_term[length_prox_term++] = ' '; - strcpy (prox_term + length_prox_term, term); - length_prox_term += lterm; - } - if (min_nn > rset[i]->rset_terms[j]->nn) - min_nn = rset[i]->rset_terms[j]->nn; - flags = nflags; - term_type = rset[i]->rset_terms[j]->type; - - /* only if all term types are of type characterString .. */ - /* the resulting term is of that type */ - if (term_type != Z_Term_characterString) - term_type = Z_Term_general; - } - } - for (i = 0; inn = 0; - result = rset_create (rset_kind_null, &parms); - } - else if (ordered && relation == 3 && exclusion == 0 && distance == 1) - { - /* special proximity case = phrase search ... */ - rset_temp_parms parms; - RSFD rsfd_result; - - parms.rset_term = rset_term_create (prox_term, length_prox_term, - flags, term_type); - parms.rset_term->nn = min_nn; - parms.cmp = key_compare_it; - parms.key_size = sizeof (struct it_key); - parms.temp_path = res_get (zh->res, "setTmpDir"); - result = rset_create (rset_kind_temp, &parms); - rsfd_result = rset_open (result, RSETF_WRITE); - - while (*more) - { - for (i = 1; i 1) - { - more[i-1] = rset_read (rset[i-1], rsfd[i-1], - buf[i-1], &term_index); - break; - } - else if (cmp == 1) - { - if (buf[i-1]->seqno+1 != buf[i]->seqno) - { - more[i-1] = rset_read (rset[i-1], rsfd[i-1], - buf[i-1], &term_index); - break; - } - } - else - { - more[i] = rset_read (rset[i], rsfd[i], buf[i], - &term_index); - break; - } - } - if (i == rset_no) - { - rset_write (result, rsfd_result, buf[0]); - more[0] = rset_read (*rset, *rsfd, *buf, &term_index); - } - } - rset_close (result, rsfd_result); - } - else if (rset_no == 2) - { - /* generic proximity case (two input sets only) ... */ - rset_temp_parms parms; - RSFD rsfd_result; - - yaz_log (LOG_LOG, "generic prox, dist=%d, relation=%d, ordered=%d" - ", exclusion=%d", - distance, relation, ordered, exclusion); - parms.rset_term = rset_term_create (prox_term, length_prox_term, - flags, term_type); - parms.rset_term->nn = min_nn; - parms.cmp = key_compare_it; - parms.key_size = sizeof (struct it_key); - parms.temp_path = res_get (zh->res, "setTmpDir"); - result = rset_create (rset_kind_temp, &parms); - rsfd_result = rset_open (result, RSETF_WRITE); - - while (more[0] && more[1]) - { - int cmp = key_compare_it (buf[0], buf[1]); - if (cmp < -1) - more[0] = rset_read (rset[0], rsfd[0], buf[0], &term_index); - else if (cmp > 1) - more[1] = rset_read (rset[1], rsfd[1], buf[1], &term_index); - else - { - int sysno = buf[0]->sysno; - int seqno[500]; - int n = 0; - - seqno[n++] = buf[0]->seqno; - while ((more[0] = rset_read (rset[0], rsfd[0], buf[0], - &term_index)) && - sysno == buf[0]->sysno) - if (n < 500) - seqno[n++] = buf[0]->seqno; - do - { - for (i = 0; iseqno - seqno[i]; - int excl = exclusion; - if (!ordered && diff < 0) - diff = -diff; - switch (relation) - { - case 1: /* < */ - if (diff < distance && diff >= 0) - excl = !excl; - break; - case 2: /* <= */ - if (diff <= distance && diff >= 0) - excl = !excl; - break; - case 3: /* == */ - if (diff == distance && diff >= 0) - excl = !excl; - break; - case 4: /* >= */ - if (diff >= distance && diff >= 0) - excl = !excl; - break; - case 5: /* > */ - if (diff > distance && diff >= 0) - excl = !excl; - break; - case 6: /* != */ - if (diff != distance && diff >= 0) - excl = !excl; - break; - } - if (excl) - { - rset_write (result, rsfd_result, buf[1]); - break; - } - } - } while ((more[1] = rset_read (rset[1], rsfd[1], buf[1], - &term_index)) && - sysno == buf[1]->sysno); - } - } - rset_close (result, rsfd_result); - } - else - { - rset_null_parms parms; - - parms.rset_term = rset_term_create (prox_term, length_prox_term, - flags, term_type); - parms.rset_term->nn = 0; - result = rset_create (rset_kind_null, &parms); - } - for (i = 0; iu.prox->ordered, - (!zop->u.prox->exclusion ? 0 : - *zop->u.prox->exclusion), - *zop->u.prox->relationType, - *zop->u.prox->distance); - rset_delete (rsets[0]); - rset_delete (rsets[1]); + twosets[0] = bool_parms.rset_l; + twosets[1] = bool_parms.rset_r; + parms.rset = twosets; + parms.rset_no = 2; + parms.ordered = *zop->u.prox->ordered; + parms.exclusion = (!zop->u.prox->exclusion ? 0 : + *zop->u.prox->exclusion); + parms.relation = *zop->u.prox->relationType; + parms.distance = *zop->u.prox->distance; + parms.key_size = sizeof(struct it_key); + parms.cmp = key_compare_it; + parms.getseq = key_get_seq; + parms.log_item = key_logdump_txt; + r = rset_create(rset_kind_prox, &parms); } break; default: