X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=index%2Frpnsearch.c;h=f5815122e125ca0d20bf124bb5b47239e385bea4;hb=e1352999e1be86b0ce5c2698bb62f9fc7d598a4f;hp=95295737a0e4eab04fffd6b8f9b3e206a91c3f9f;hpb=4aae319a0b820d1e8d3ab5d82c48f5047c9995f9;p=idzebra-moved-to-github.git diff --git a/index/rpnsearch.c b/index/rpnsearch.c index 9529573..f581512 100644 --- a/index/rpnsearch.c +++ b/index/rpnsearch.c @@ -1,5 +1,5 @@ -/* $Id: rpnsearch.c,v 1.3 2006-11-30 10:33:19 adam Exp $ - Copyright (C) 1995-2006 +/* $Id: rpnsearch.c,v 1.7 2007-01-16 15:31:23 adam Exp $ + Copyright (C) 1995-2007 Index Data ApS This file is part of the Zebra server. @@ -78,19 +78,25 @@ struct grep_info { ISAM_P *isam_p_buf; int isam_p_size; int isam_p_indx; + int trunc_max; ZebraHandle zh; int reg_type; ZebraSet termset; }; -static void add_isam_p(const char *name, const char *info, - struct grep_info *p) +static int add_isam_p(const char *name, const char *info, + struct grep_info *p) { if (!log_level_set) { log_level_rpn = yaz_log_module_level("rpn"); log_level_set = 1; } + /* we may have to stop this madness.. NOTE: -1 so that if + truncmax == trunxlimit we do *not* generate result sets */ + if (p->isam_p_indx >= p->trunc_max - 1) + return 1; + if (p->isam_p_indx == p->isam_p_size) { ISAM_P *new_isam_p_buf; @@ -140,12 +146,12 @@ static void add_isam_p(const char *name, const char *info, index_name, term_tmp); } (p->isam_p_indx)++; + return 0; } static int grep_handle(char *name, const char *info, void *p) { - add_isam_p(name, info, (struct grep_info *) p); - return 0; + return add_isam_p(name, info, (struct grep_info *) p); } static int term_pre(ZebraMaps zebra_maps, int reg_type, const char **src, @@ -1177,7 +1183,9 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, grep_info, &max_pos, ord_len /* number of "exact" chars */, grep_handle); - if (r) + if (r == 1) + zebra_set_partial_result(zh); + else if (r) yaz_log(YLOG_WARN, "dict_lookup_grep fail %d", r); } if (!bases_ok) @@ -1209,6 +1217,7 @@ static ZEBRA_RES grep_info_prepare(ZebraHandle zh, #ifdef TERM_COUNT grep_info->term_no = 0; #endif + grep_info->trunc_max = atoi(res_get_def(zh->res, "truncmax", "10000")); grep_info->isam_p_size = 0; grep_info->isam_p_buf = NULL; grep_info->zh = zh; @@ -1692,7 +1701,10 @@ static int numeric_relation(ZebraHandle zh, Z_AttributesPlusTerm *zapt, yaz_log(log_level_rpn, "dict_lookup_grep: %s", term_tmp); r = dict_lookup_grep(zh->reg->dict, term_dict, 0, grep_info, max_pos, 0, grep_handle); - if (r) + + if (r == 1) + zebra_set_partial_result(zh); + else if (r) yaz_log(YLOG_WARN, "dict_lookup_grep fail, rel = gt: %d", r); yaz_log(log_level_rpn, "%d positions", grep_info->isam_p_indx); return 1;