X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzrpn.c;h=a5eac1e2e32c4779eb7a4e62be1113dd9de69b33;hb=3db15cf883ad80b6a4b0e960f3c3b59c86b59c6b;hp=8ede14783154f7a9d46b0737efa34177cd09be9b;hpb=221024eb6b10e45d6479bb4154dd7de7fca1d477;p=idzebra-moved-to-github.git diff --git a/index/zrpn.c b/index/zrpn.c index 8ede147..a5eac1e 100644 --- a/index/zrpn.c +++ b/index/zrpn.c @@ -1,10 +1,19 @@ /* - * Copyright (C) 1994-1997, Index Data I/S + * Copyright (C) 1995-1998, Index Data I/S * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * * $Log: zrpn.c,v $ - * Revision 1.71 1997-12-18 10:54:24 adam + * Revision 1.74 1998-02-10 12:03:06 adam + * Implemented Sort. + * + * Revision 1.73 1998/01/29 13:40:11 adam + * Better logging for scan service. + * + * Revision 1.72 1998/01/07 13:53:41 adam + * Queries using simple ranked operands returns right number of hits. + * + * Revision 1.71 1997/12/18 10:54:24 adam * New method result set method rs_hits that returns the number of * hits in result-set (if known). The ranked result set returns real * number of hits but only when not combined with other operands. @@ -362,8 +371,7 @@ static void add_isam_p (const char *info, struct grep_info *p) ISAM_P *new_isam_p_buf; #ifdef TERM_COUNT int *new_term_no; -#endif - +#endif p->isam_p_size = 2*p->isam_p_size + 100; new_isam_p_buf = xmalloc (sizeof(*new_isam_p_buf) * p->isam_p_size); @@ -1266,7 +1274,7 @@ static RSET rpn_search_ref (ZServerInfo *zi, Z_ResultSetId *resultSetId) } static RSET rpn_search_structure (ZServerInfo *zi, Z_RPNStructure *zs, - oid_value attributeSet, + oid_value attributeSet, ODR stream, int num_bases, char **basenames) { RSET r = NULL; @@ -1278,14 +1286,14 @@ static RSET rpn_search_structure (ZServerInfo *zi, Z_RPNStructure *zs, bool_parms.rset_l = rpn_search_structure (zi, zs->u.complex->s1, - attributeSet, + attributeSet, stream, num_bases, basenames); if (bool_parms.rset_l == NULL) return NULL; if (rset_is_ranked(bool_parms.rset_l)) soft = 1; bool_parms.rset_r = rpn_search_structure (zi, zs->u.complex->s2, - attributeSet, + attributeSet, stream, num_bases, basenames); if (bool_parms.rset_r == NULL) { @@ -1316,7 +1324,7 @@ static RSET rpn_search_structure (ZServerInfo *zi, Z_RPNStructure *zs, } if (*zop->u.prox->proximityUnitCode != Z_ProxUnit_word) { - char *val = odr_malloc (zi->odr, 16); + char *val = odr_malloc (stream, 16); zi->errCode = 132; zi->errString = val; sprintf (val, "%d", *zop->u.prox->proximityUnitCode); @@ -1420,7 +1428,7 @@ static void count_set (RSET r, int *count) logf (LOG_DEBUG, "%d keys, %d distinct sysnos", kno, *count); } -int rpn_search (ZServerInfo *zi, +int rpn_search (ZServerInfo *zi, ODR stream, Z_RPNQuery *rpn, int num_bases, char **basenames, const char *setname, int *hits) { @@ -1436,7 +1444,7 @@ int rpn_search (ZServerInfo *zi, attrset = oid_getentbyoid (rpn->attributeSetId); attributeSet = attrset->value; - rset = rpn_search_structure (zi, rpn->RPNStructure, attributeSet, + rset = rpn_search_structure (zi, rpn->RPNStructure, attributeSet, stream, num_bases, basenames); if (!rset) return zi->errCode; @@ -1485,10 +1493,10 @@ static int scan_handle (char *name, const char *info, int pos, void *client) } -static void scan_term_untrans (ZServerInfo *zi, int reg_type, +static void scan_term_untrans (ZServerInfo *zi, ODR stream, int reg_type, char **dstp, const char *src) { - char *dst = odr_malloc (zi->odr, strlen(src)*2+1); + char *dst = odr_malloc (stream, strlen(src)*2+1); *dstp = dst; while (*src) @@ -1500,7 +1508,7 @@ static void scan_term_untrans (ZServerInfo *zi, int reg_type, *dst = '\0'; } -int rpn_scan (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, +int rpn_scan (ZServerInfo *zi, ODR stream, Z_AttributesPlusTerm *zapt, oid_value attributeset, int num_bases, char **basenames, int *position, int *num_entries, struct scan_entry **list, @@ -1524,14 +1532,14 @@ int rpn_scan (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, char *search_type = NULL; int complete_flag; - logf (LOG_DEBUG, "scan, position = %d, num = %d", pos, num); - if (attributeset == VAL_NONE) attributeset = VAL_BIB1; + + zlog_scan (zapt, attributeset); + logf (LOG_DEBUG, "position = %d, num = %d", pos, num); attr_init (&use, zapt, 1); use_value = attr_find (&use, &attributeset); - logf (LOG_DEBUG, "use value %d", use_value); if (zebra_maps_attr (zi->zebra_maps, zapt, ®_type, &search_type, &complete_flag)) @@ -1577,7 +1585,7 @@ int rpn_scan (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, return zi->errCode = 113; before = pos-1; after = 1+num-pos; - scan_info_array = odr_malloc (zi->odr, ord_no * sizeof(*scan_info_array)); + scan_info_array = odr_malloc (stream, ord_no * sizeof(*scan_info_array)); for (i = 0; i < ord_no; i++) { int j, prefix_len = 0; @@ -1589,9 +1597,9 @@ int rpn_scan (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, scan_info->before = before; scan_info->after = after; - scan_info->odr = zi->odr; + scan_info->odr = stream; - scan_info->list = odr_malloc (zi->odr, (before+after)* + scan_info->list = odr_malloc (stream, (before+after)* sizeof(*scan_info->list)); for (j = 0; jlist[j].term = NULL; @@ -1605,7 +1613,7 @@ int rpn_scan (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, dict_scan (zi->dict, termz, &before_tmp, &after_tmp, scan_info, scan_handle); } - glist = odr_malloc (zi->odr, (before+after)*sizeof(*glist)); + glist = odr_malloc (stream, (before+after)*sizeof(*glist)); for (i = 0; i < ord_no; i++) ptr[i] = before; @@ -1629,7 +1637,8 @@ int rpn_scan (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, } if (j0 == -1) break; - scan_term_untrans (zi, reg_type, &glist[i+before].term, mterm); + scan_term_untrans (zi, stream, reg_type, + &glist[i+before].term, mterm); rset = rset_trunc (zi, &scan_info_array[j0].list[ptr[j0]].isam_p, 1); ptr[j0]++; @@ -1687,7 +1696,8 @@ int rpn_scan (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, if (j0 == -1) break; - scan_term_untrans (zi, reg_type, &glist[before-1-i].term, mterm); + scan_term_untrans (zi, stream, reg_type, + &glist[before-1-i].term, mterm); rset = rset_trunc (zi, &scan_info_array[j0].list[before-1-ptr[j0]].isam_p, 1);