X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Frpnscan.c;h=6d575df76c9281dec3b63ad459fa06ca34d29564;hb=8896080000b8d31751ca253b59aaae425ebd9e48;hp=b4e9fa8e0afddcd182368d1b8a432c268deb3d1e;hpb=1aac6e217a6ff917fdacabec636aa00cbf2f3226;p=idzebra-moved-to-github.git diff --git a/index/rpnscan.c b/index/rpnscan.c index b4e9fa8..6d575df 100644 --- a/index/rpnscan.c +++ b/index/rpnscan.c @@ -1,4 +1,4 @@ -/* $Id: rpnscan.c,v 1.18 2007-11-01 14:10:03 adam Exp $ +/* $Id: rpnscan.c,v 1.22 2007-11-13 13:41:51 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -41,8 +41,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define RPN_MAX_ORDS 32 -int log_scan = YLOG_LOG; - /* convert APT SCAN term to internal cmap */ static ZEBRA_RES trans_scan_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, char *termz, zebra_map_t zm) @@ -280,8 +278,8 @@ static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem, } return 0; } - -static ZEBRA_RES rpn_scan_ver2(ZebraHandle zh, ODR stream, NMEM nmem, + +static ZEBRA_RES rpn_scan_norm(ZebraHandle zh, ODR stream, NMEM nmem, struct rset_key_control *kc, Z_AttributesPlusTerm *zapt, int *position, int *num_entries, @@ -292,7 +290,7 @@ static ZEBRA_RES rpn_scan_ver2(ZebraHandle zh, ODR stream, NMEM nmem, { struct scan2_info_entry *ar = nmem_malloc(nmem, sizeof(*ar) * ord_no); struct rpn_char_map_info rcmi; - zebra_map_t zm = zebra_map_get(zh->reg->zebra_maps, index_type); + zebra_map_t zm = zebra_map_get_or_add(zh->reg->zebra_maps, index_type); int i, dif; int after_pos; int pos = 0; @@ -473,7 +471,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, const Odr_oid *attributeset, int num_bases, char **basenames, int *position, int *num_entries, ZebraScanEntry **list, - int *is_partial, RSET limit_set) + int *is_partial, const char *set_name) { int base_no; int ords[RPN_MAX_ORDS], ord_no = 0; @@ -486,6 +484,7 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, NMEM nmem; ZEBRA_RES res; struct rset_key_control *kc = 0; + RSET limit_set = 0; *list = 0; *is_partial = 0; @@ -493,40 +492,41 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, if (!attributeset) attributeset = yaz_oid_attset_bib_1; - if (!limit_set) /* no limit set given already */ + if (!set_name) { /* see if there is a @attr 8=set */ AttrType termset; int termset_value_numeric; - const char *termset_value_string; + const char *termset_value_string = 0; attr_init_APT(&termset, zapt, 8); termset_value_numeric = attr_find_ex(&termset, NULL, &termset_value_string); if (termset_value_numeric != -1) { - char resname[32]; - const char *termset_name = 0; - if (termset_value_numeric != -2) { + char resname[32]; sprintf(resname, "%d", termset_value_numeric); - termset_name = resname; + set_name = odr_strdup(stream, resname); } else - termset_name = termset_value_string; - - limit_set = resultSetRef(zh, termset_name); - - if (!limit_set) - { - zebra_setError(zh, - YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST, - termset_name); - return ZEBRA_FAIL; - } + set_name = odr_strdup(stream, termset_value_string); } } + + if (set_name) + { + limit_set = resultSetRef(zh, set_name); + if (!limit_set) + { + zebra_setError(zh, + YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST, + set_name); + return ZEBRA_FAIL; + } + } + yaz_log(YLOG_DEBUG, "position = %d, num = %d", *position, *num_entries); @@ -542,7 +542,11 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, zebra_setError(zh, YAZ_BIB1_TOO_MANY_DATABASES_SPECIFIED, 0); return ZEBRA_FAIL; } - + if (sort_flag) + { + return rpn_facet(zh, stream, zapt, attributeset, position, num_entries, + list, is_partial, set_name); + } for (base_no = 0; base_no < num_bases; base_no++) { int ord; @@ -572,9 +576,9 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, nmem = nmem_create(); kc = zebra_key_control_create(zh); - res = rpn_scan_ver2(zh, stream, nmem, kc, zapt, position, num_entries, - list, - is_partial, limit_set, index_type, ord_no, ords); + res = rpn_scan_norm(zh, stream, nmem, kc, zapt, position, num_entries, + list, is_partial, limit_set, + index_type, ord_no, ords); nmem_destroy(nmem); (*kc->dec)(kc); return res;