X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=index%2Fzrpn.c;h=0f385e1cb7aced9288e2b8e156d85a6b0787c461;hb=04c1e64ee5203e17b2e9618d38ff28a72e0c83d8;hp=5b50a4f217aac5e5b9f3bd3b36afbc89b0a7fe08;hpb=2038fcec0ea77e3fdb854ff968423d3ef24d53a8;p=idzebra-moved-to-github.git diff --git a/index/zrpn.c b/index/zrpn.c index 5b50a4f..0f385e1 100644 --- a/index/zrpn.c +++ b/index/zrpn.c @@ -4,7 +4,13 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zrpn.c,v $ - * Revision 1.28 1995-10-13 12:26:43 adam + * Revision 1.30 1995-10-16 09:32:38 adam + * More work on relational op. + * + * Revision 1.29 1995/10/13 16:01:49 adam + * Work on relations. + * + * Revision 1.28 1995/10/13 12:26:43 adam * Optimization of truncation. * * Revision 1.27 1995/10/12 17:07:22 adam @@ -412,12 +418,14 @@ static RSET rset_trunc_r (ISAM isam, ISAM_P *isam_p, int from, int to, rset_write (result, result_rsfd, ti->heap[ti->ptr[1]]); #if 0 +/* section that preserve all keys */ heap_delete (ti); if (is_readkey (ispt[n], ti->tmpbuf)) heap_insert (ti, ti->tmpbuf, n); else is_pt_free (ispt[n]); #else +/* section that preserve all keys with unique sysnos */ while (1) { if (!is_readkey (ispt[n], ti->tmpbuf)) @@ -496,17 +504,70 @@ static int grep_handle (Dict_char *name, const char *info, void *p) return 0; } +static void gen_regular_ge (char *dst, int val) +{ + int dst_p = 1; + int w, d, i; + int pos = 0; + char numstr[20]; + + *dst = '('; + if (val < 0) + val = 0; + sprintf (numstr, "%d", val); + for (w = strlen(numstr); --w >= 0; pos++) + { + d = numstr[w]; + if (pos > 0) + { + if (d == '9') + continue; + d++; + } + + strcpy (dst + dst_p, numstr); + dst_p = strlen(dst) - pos - 1; + + if (d <= '8') + { + dst[dst_p++] = '['; + dst[dst_p++] = d; + dst[dst_p++] = '-'; + dst[dst_p++] = '9'; + dst[dst_p++] = ']'; + } + else + dst[dst_p++] = d; + + for (i = 0; ierrCode = 114; return -1; } - + switch (relation_value) + { + case 1: + case 2: + break; + case 4: + logf (LOG_LOG, "Relation ge"); + gen_regular_ge (term_dict + strlen(term_dict), atoi(term_sub)); + logf (LOG_LOG, "dict_lookup_grep: %s", term_dict); + r = dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info, + grep_handle); + if (r) + logf (LOG_WARN, "dict_lookup_grep fail, rel=ge: %d", r); + logf (LOG_LOG, "%d positions", grep_info->isam_p_indx); + return 0; + case 5: + logf (LOG_LOG, "Relation gt"); + gen_regular_ge (term_dict + strlen(term_dict), atoi(term_sub)+1); + logf (LOG_LOG, "dict_lookup_grep: %s", term_dict); + r = dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info, + grep_handle); + if (r) + logf (LOG_WARN, "dict_lookup_grep fail, rel=gt: %d", r); + logf (LOG_LOG, "%d positions", grep_info->isam_p_indx); + return 0; + } switch (truncation_value) { case -1: /* not specified */ @@ -558,11 +647,17 @@ static int trunc_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info, grep_handle); break; case 102: /* regular expression */ + strcat (term_dict, "("); strcat (term_dict, term_sub); - dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info, grep_handle); + strcat (term_dict, ")"); + logf (LOG_LOG, "dict_lookup_grep: %s", term_dict); + r = dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info, + grep_handle); + if (r) + logf (LOG_WARN, "dict_lookup_grep fail, truncation=regular: %d", r); break; } - logf (LOG_DEBUG, "%d positions", grep_info->isam_p_indx); + logf (LOG_LOG, "%d positions", grep_info->isam_p_indx); return 0; } @@ -851,7 +946,6 @@ static RSET rpn_search_APT_local (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, return result; } - static RSET rpn_search_APT (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, oid_value attributeSet) {