-/* $Id: zrpn.c,v 1.161 2004-11-19 10:27:06 heikki Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
- Index Data Aps
+/* $Id: zrpn.c,v 1.168 2005-01-15 20:47:15 adam Exp $
+ Copyright (C) 1995-2005
+ Index Data ApS
This file is part of the Zebra server.
#include <charmap.h>
#include <rset.h>
+/* maximum number of terms in an and/or/phrase item */
+#define TERM_LIST_LENGTH_MAX 256
static const struct key_control it_ctrl =
{
} AttrType;
+static int log_level_set = 0;
+static int log_level_rpn = 0;
+
static const char **rpn_char_map_handler(void *vp, const char **from, int len)
{
struct rpn_char_map_info *p = (struct rpn_char_map_info *) vp;
while (*src)
{
const char *cp = zebra_maps_output(zh->reg->zebra_maps,
- reg_type, &src);
+ reg_type, &src);
if (!cp && len < IT_MAX_WORD-1)
dst[len++] = *src++;
else
static void 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;
+ }
if (p->isam_p_indx == p->isam_p_size)
{
ISAMC_P *new_isam_p_buf;
p->isam_p_buf = new_isam_p_buf;
#ifdef TERM_COUNT
- new_term_no = (int *) xmalloc(sizeof(*new_term_no) *
- p->isam_p_size);
+ new_term_no = (int *) xmalloc(sizeof(*new_term_no) * p->isam_p_size);
if (p->term_no)
{
memcpy(new_term_no, p->isam_p_buf,
int len = key_SU_decode (&su_code, name);
term_untrans (p->zh, p->reg_type, term_tmp, name+len+1);
- yaz_log(YLOG_LOG, "grep: %d %c %s", su_code, name[len], term_tmp);
+ yaz_log(log_level_rpn, "grep: %d %c %s", su_code, name[len], term_tmp);
zebraExplain_lookup_ord (p->zh->reg->zei,
su_code, &db, &set, &use);
- yaz_log(YLOG_LOG, "grep: set=%d use=%d db=%s", set, use, db);
+ yaz_log(log_level_rpn, "grep: set=%d use=%d db=%s", set, use, db);
resultSetAddTerm(p->zh, p->termset, name[len], db,
set, use, term_tmp);
#define REGEX_CHARS " []()|.*+?!"
-/* term_100: handle term, where trunc=none(no operators at all) */
+/* term_100: handle term, where trunc = none(no operators at all) */
static int term_100(ZebraMaps zebra_maps, int reg_type,
const char **src, char *dst, int space_split,
char *dst_term)
return i;
}
-/* term_101: handle term, where trunc=Process # */
+/* term_101: handle term, where trunc = Process # */
static int term_101(ZebraMaps zebra_maps, int reg_type,
const char **src, char *dst, int space_split,
char *dst_term)
return i;
}
-/* term_103: handle term, where trunc=re-2 (regular expressions) */
+/* term_103: handle term, where trunc = re-2 (regular expressions) */
static int term_103(ZebraMaps zebra_maps, int reg_type, const char **src,
char *dst, int *errors, int space_split,
char *dst_term)
return 0;
s0 = *src;
if (errors && *s0 == '+' && s0[1] && s0[2] == '+' && s0[3] &&
- isdigit(s0[1]))
+ isdigit(((const unsigned char *)s0)[1]))
{
*errors = s0[1] - '0';
s0 += 3;
return i;
}
-/* term_103: handle term, where trunc=re-1 (regular expressions) */
+/* term_103: handle term, where trunc = re-1 (regular expressions) */
static int term_102 (ZebraMaps zebra_maps, int reg_type, const char **src,
char *dst, int space_split, char *dst_term)
{
}
-/* term_104: handle term, where trunc=Process # and ! */
+/* term_104: handle term, where trunc = Process # and ! */
static int term_104(ZebraMaps zebra_maps, int reg_type,
const char **src, char *dst, int space_split,
char *dst_term)
return i;
}
-/* term_105/106: handle term, where trunc=Process * and ! and right trunc */
+/* term_105/106: handle term, where trunc = Process * and ! and right trunc */
static int term_105 (ZebraMaps zebra_maps, int reg_type,
const char **src, char *dst, int space_split,
char *dst_term, int right_truncate)
{
/* match everything less than 10^(pos-1) */
strcat(dst, "0*");
- for (i=1; i<pos; i++)
+ for (i = 1; i<pos; i++)
strcat(dst, "[0-9]?");
}
else
term_sub, term_component,
space_split, term_dst))
return 0;
- yaz_log(YLOG_DEBUG, "Relation <");
+ yaz_log(log_level_rpn, "Relation <");
*term_tmp++ = '(';
for (i = 0; term_component[i]; )
term_sub, term_component,
space_split, term_dst))
return 0;
- yaz_log(YLOG_DEBUG, "Relation <=");
+ yaz_log(log_level_rpn, "Relation <=");
*term_tmp++ = '(';
for (i = 0; term_component[i]; )
if (!term_100 (zh->reg->zebra_maps, reg_type,
term_sub, term_component, space_split, term_dst))
return 0;
- yaz_log(YLOG_DEBUG, "Relation >");
+ yaz_log(log_level_rpn, "Relation >");
*term_tmp++ = '(';
for (i = 0; term_component[i];)
if (!term_100 (zh->reg->zebra_maps, reg_type, term_sub,
term_component, space_split, term_dst))
return 0;
- yaz_log(YLOG_DEBUG, "Relation >=");
+ yaz_log(log_level_rpn, "Relation >=");
*term_tmp++ = '(';
for (i = 0; term_component[i];)
break;
case 3:
default:
- yaz_log(YLOG_DEBUG, "Relation =");
+ yaz_log(log_level_rpn, "Relation =");
if (!term_100 (zh->reg->zebra_maps, reg_type, term_sub,
term_component, space_split, term_dst))
return 0;
term_dst, xpath_use);
if (r < 1)
return 0;
- yaz_log(YLOG_DEBUG, "term: %s", term_dst);
+ yaz_log(log_level_rpn, "term: %s", term_dst);
return rset_trunc(zh, grep_info->isam_p_buf,
grep_info->isam_p_indx, term_dst,
strlen(term_dst), rank_type, 1 /* preserve pos */,
rpn_char_map_prepare (zh->reg, reg_type, &rcmi);
attr_init (&use, zapt, 1);
use_value = attr_find_ex (&use, &curAttributeSet, &use_string);
- yaz_log(YLOG_DEBUG, "string_term, use value %d", use_value);
+ yaz_log(log_level_rpn, "string_term, use value %d", use_value);
attr_init (&truncation, zapt, 5);
truncation_value = attr_find (&truncation, NULL);
- yaz_log(YLOG_DEBUG, "truncation value %d", truncation_value);
+ yaz_log(log_level_rpn, "truncation value %d", truncation_value);
if (use_value == -1) /* no attribute - assumy "any" */
use_value = 1016;
}
else
{
- if ((r=att_getentbyatt (zh, &attp, curAttributeSet, use_value,
+ if ((r = att_getentbyatt (zh, &attp, curAttributeSet, use_value,
use_string)))
{
yaz_log(YLOG_DEBUG, "att_getentbyatt fail. set=%d use=%d r=%d",
term_dict[prefix_len++] = ')';
term_dict[prefix_len++] = 1;
term_dict[prefix_len++] = reg_type;
- yaz_log(YLOG_DEBUG, "reg_type = %d", term_dict[prefix_len-1]);
+ yaz_log(log_level_rpn, "reg_type = %d", term_dict[prefix_len-1]);
term_dict[prefix_len] = '\0';
j = prefix_len;
switch (truncation_value)
}
if (attr_ok)
{
- yaz_log(YLOG_DEBUG, "dict_lookup_grep: %s", term_dict+prefix_len);
+ yaz_log(log_level_rpn, "dict_lookup_grep: %s", term_dict+prefix_len);
r = dict_lookup_grep(zh->reg->dict, term_dict, regex_range,
grep_info, &max_pos, init_pos,
grep_handle);
}
else
termset_name = termset_value_string;
- yaz_log(YLOG_LOG, "creating termset set %s", termset_name);
+ yaz_log(log_level_rpn, "creating termset set %s", termset_name);
grep_info->termset = resultSetAdd (zh, termset_name, 1);
if (!grep_info->termset)
{
NMEM rset_nmem)
{
char term_dst[IT_MAX_WORD+1];
- RSET rset[60], result;
- int rset_no = 0;
+ RSET rset[TERM_LIST_LENGTH_MAX], result;
+ size_t rset_no = 0;
struct grep_info grep_info;
char *termz = normalize_term(zh, zapt, termz_org, stream, reg_type);
const char *termp = termz;
*term_dst = 0;
if (grep_info_prepare (zh, zapt, &grep_info, reg_type, stream))
return 0;
- while (1)
+ for (; rset_no < sizeof(rset)/sizeof(*rset); rset_no++)
{
- yaz_log(YLOG_DEBUG, "APT_phrase termp=%s", termp);
+ yaz_log(log_level_rpn, "APT_phrase termp=%s", termp);
rset[rset_no] = term_trunc(zh, zapt, &termp, attributeSet,
stream, &grep_info,
reg_type, complete_flag,
xpath_use,rset_nmem);
if (!rset[rset_no])
break;
- if (++rset_no >= (int) (sizeof(rset)/sizeof(*rset)))
- break;
}
grep_info_delete (&grep_info);
if (rset_no == 0)
NMEM rset_nmem)
{
char term_dst[IT_MAX_WORD+1];
- RSET rset[60];
- int rset_no = 0;
+ RSET rset[TERM_LIST_LENGTH_MAX];
+ size_t rset_no = 0;
struct grep_info grep_info;
char *termz = normalize_term(zh, zapt, termz_org, stream, reg_type);
const char *termp = termz;
if (grep_info_prepare (zh, zapt, &grep_info, reg_type, stream))
return 0;
- while (1)
+ for (; rset_no < sizeof(rset)/sizeof(*rset); rset_no++)
{
- yaz_log(YLOG_DEBUG, "APT_or_list termp=%s", termp);
+ yaz_log(log_level_rpn, "APT_or_list termp=%s", termp);
rset[rset_no] = term_trunc(zh, zapt, &termp, attributeSet,
stream, &grep_info,
reg_type, complete_flag,
xpath_use,rset_nmem);
if (!rset[rset_no])
break;
- if (++rset_no >= (int) (sizeof(rset)/sizeof(*rset)))
- break;
}
grep_info_delete (&grep_info);
if (rset_no == 0)
return rsnull_create (rset_nmem,key_it_ctrl);
- return rsmultior_create(rset_nmem, key_it_ctrl,key_it_ctrl->scope,
- rset_no, rset);
+ return rsmulti_or_create(rset_nmem, key_it_ctrl,key_it_ctrl->scope,
+ rset_no, rset);
}
static RSET rpn_search_APT_and_list (ZebraHandle zh,
NMEM rset_nmem)
{
char term_dst[IT_MAX_WORD+1];
- RSET rset[60]; /* FIXME - bug 160 - should be dynamic somehow */
- int rset_no = 0;
+ RSET rset[TERM_LIST_LENGTH_MAX];
+ size_t rset_no = 0;
struct grep_info grep_info;
char *termz = normalize_term(zh, zapt, termz_org, stream, reg_type);
const char *termp = termz;
if (grep_info_prepare (zh, zapt, &grep_info, reg_type, stream))
return 0;
- while (1)
+ for (; rset_no < sizeof(rset)/sizeof(*rset); rset_no++)
{
- yaz_log(YLOG_DEBUG, "APT_and_list termp=%s", termp);
+ yaz_log(log_level_rpn, "APT_and_list termp=%s", termp);
rset[rset_no] = term_trunc(zh, zapt, &termp, attributeSet,
stream, &grep_info,
reg_type, complete_flag,
xpath_use, rset_nmem);
if (!rset[rset_no])
break;
- assert (rset[rset_no]);
- if (++rset_no >= (int) (sizeof(rset)/sizeof(*rset)))
- break;
}
grep_info_delete (&grep_info);
if (rset_no == 0)
- return rsnull_create (rset_nmem,key_it_ctrl);
-
- return rsmultiand_create( rset_nmem, key_it_ctrl, key_it_ctrl->scope,
- rset_no, rset);
+ return rsnull_create(rset_nmem,key_it_ctrl);
+
+ return rsmulti_and_create(rset_nmem, key_it_ctrl, key_it_ctrl->scope,
+ rset_no, rset);
}
static int numeric_relation (ZebraHandle zh, Z_AttributesPlusTerm *zapt,
attr_init (&relation, zapt, 2);
relation_value = attr_find (&relation, NULL);
- yaz_log(YLOG_DEBUG, "numeric relation value=%d", relation_value);
+ yaz_log(log_level_rpn, "numeric relation value=%d", relation_value);
if (!term_100 (zh->reg->zebra_maps, reg_type, term_sub, term_tmp, 1,
term_dst))
switch (relation_value)
{
case 1:
- yaz_log(YLOG_DEBUG, "Relation <");
+ yaz_log(log_level_rpn, "Relation <");
gen_regular_rel (term_tmp, term_value-1, 1);
break;
case 2:
- yaz_log(YLOG_DEBUG, "Relation <=");
+ yaz_log(log_level_rpn, "Relation <=");
gen_regular_rel (term_tmp, term_value, 1);
break;
case 4:
- yaz_log(YLOG_DEBUG, "Relation >=");
+ yaz_log(log_level_rpn, "Relation >=");
gen_regular_rel (term_tmp, term_value, 0);
break;
case 5:
- yaz_log(YLOG_DEBUG, "Relation >");
+ yaz_log(log_level_rpn, "Relation >");
gen_regular_rel (term_tmp, term_value+1, 0);
break;
case 3:
default:
- yaz_log(YLOG_DEBUG, "Relation =");
+ yaz_log(log_level_rpn, "Relation =");
sprintf (term_tmp, "(0*%d)", term_value);
}
- yaz_log(YLOG_DEBUG, "dict_lookup_grep: %s", term_tmp);
+ 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)
- yaz_log(YLOG_WARN, "dict_lookup_grep fail, rel=gt: %d", r);
- yaz_log(YLOG_DEBUG, "%d positions", grep_info->isam_p_indx);
+ 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;
}
}
else
{
- if ((r=att_getentbyatt (zh, &attp, curAttributeSet, use_value,
+ if ((r = att_getentbyatt (zh, &attp, curAttributeSet, use_value,
use_string)))
{
yaz_log(YLOG_DEBUG, "att_getentbyatt fail. set=%d use=%d r=%d",
{
char term_dst[IT_MAX_WORD+1];
const char *termp = termz;
- RSET rset[60]; /* FIXME - hard-coded magic number */
- int r, rset_no = 0;
+ RSET rset[TERM_LIST_LENGTH_MAX];
+ int r;
+ size_t rset_no = 0;
struct grep_info grep_info;
- yaz_log(YLOG_DEBUG, "APT_numeric t='%s'",termz);
+ yaz_log(log_level_rpn, "APT_numeric t='%s'",termz);
if (grep_info_prepare (zh, zapt, &grep_info, reg_type, stream))
return 0;
- while (1)
+ for (; rset_no < sizeof(rset)/sizeof(*rset); rset_no++)
{
yaz_log(YLOG_DEBUG, "APT_numeric termp=%s", termp);
grep_info.isam_p_indx = 0;
0 /* preserve position */,
zapt->term->which, rset_nmem,
key_it_ctrl,key_it_ctrl->scope);
- assert (rset[rset_no]);
- if (++rset_no >= (int) (sizeof(rset)/sizeof(*rset)))
- break;
+ if (!rset[rset_no])
+ break;
}
grep_info_delete (&grep_info);
if (rset_no == 0)
- return rsnull_create (rset_nmem,key_it_ctrl);
+ return rsnull_create(rset_nmem,key_it_ctrl);
if (rset_no == 1)
return rset[0];
- return rsmultiand_create(rset_nmem,key_it_ctrl,key_it_ctrl->scope,
- rset_no, rset);
+ return rsmulti_and_create(rset_nmem,key_it_ctrl,key_it_ctrl->scope,
+ rset_no, rset);
}
static RSET rpn_search_APT_local (ZebraHandle zh, Z_AttributesPlusTerm *zapt,
if (xpath_len < 0)
return rset;
- yaz_log (YLOG_LOG, "len=%d", xpath_len);
+ yaz_log (YLOG_DEBUG, "xpath len=%d", xpath_len);
for (i = 0; i<xpath_len; i++)
{
- yaz_log (YLOG_LOG, "XPATH %d %s", i, xpath[i].part);
+ yaz_log (log_level_rpn, "XPATH %d %s", i, xpath[i].part);
}
/ -> none
- a[@attr=value]/b[@other=othervalue]
+ a[@attr = value]/b[@other = othervalue]
/e/@a val range(e/,range(@a,freetext(w,1015,val),@a),e/)
/a/b val range(b/a/,freetext(w,1016,val),b/a/)
/a/b/@c val range(b/a/,range(@c,freetext(w,1016,val),@c),b/a/)
- /a/b[@c=y] val range(b/a/,freetext(w,1016,val),b/a/,@c=y)
- /a[@c=y]/b val range(a/,range(b/a/,freetext(w,1016,val),b/a/),a/,@c=y)
- /a[@c=x]/b[@c=y] range(a/,range(b/a/,freetext(w,1016,val),b/a/,@c=y),a/,@c=x)
+ /a/b[@c = y] val range(b/a/,freetext(w,1016,val),b/a/,@c = y)
+ /a[@c = y]/b val range(a/,range(b/a/,freetext(w,1016,val),b/a/),a/,@c = y)
+ /a[@c = x]/b[@c = y] range(a/,range(b/a/,freetext(w,1016,val),b/a/,@c = y),a/,@c = x)
*/
if (!first_path)
continue;
}
- yaz_log (YLOG_LOG, "xpath_rev (%d) = %s", level, xpath_rev);
+ yaz_log (log_level_rpn, "xpath_rev (%d) = %s", level, xpath_rev);
if (strlen(xpath_rev))
{
rset_start_tag = xpath_trunc(zh, stream, '0',
rset_end_tag = xpath_trunc(zh, stream, '0',
xpath_rev, 2, curAttributeSet, rset_nmem);
- /*
- parms.key_size = sizeof(struct it_key);
- parms.cmp = key_compare_it;
- parms.rset_l = rset_start_tag;
- parms.rset_m = rset;
- parms.rset_r = rset_end_tag;
- parms.rset_attr = rset_attr;
- parms.printer = key_print_it;
- rset = rset_create (rset_kind_between, &parms);
- */
- rset=rsbetween_create( rset_nmem,key_it_ctrl,key_it_ctrl->scope,
- rset_start_tag, rset, rset_end_tag, rset_attr);
+ rset = rsbetween_create(rset_nmem, key_it_ctrl,
+ key_it_ctrl->scope,
+ rset_start_tag, rset,
+ rset_end_tag, rset_attr);
}
first_path = 0;
}
int xpath_use = 0;
struct xpath_location_step xpath[10];
+ if (!log_level_set)
+ {
+ log_level_rpn = yaz_log_module_level("rpn");
+ log_level_set = 1;
+ }
zebra_maps_attr (zh->reg->zebra_maps, zapt, ®_id, &search_type,
rank_type, &complete_flag, &sort_flag);
switch (zop->which)
{
case Z_Operator_and:
- r=rsmultiand_create(rset_nmem, key_it_ctrl, key_it_ctrl->scope,
- 2, rsets);
+ r = rsmulti_and_create(rset_nmem, key_it_ctrl, key_it_ctrl->scope,
+ 2, rsets);
break;
case Z_Operator_or:
- r=rsmultior_create(rset_nmem, key_it_ctrl, key_it_ctrl->scope,
- 2, rsets);
+ r = rsmulti_or_create(rset_nmem, key_it_ctrl, key_it_ctrl->scope,
+ 2, rsets);
break;
case Z_Operator_and_not:
r = rsbool_create_not(rset_nmem,key_it_ctrl, key_it_ctrl->scope,
else
{
/* new / old prox */
- r=rsprox_create(rset_nmem,key_it_ctrl,key_it_ctrl->scope,
+ r = rsprox_create(rset_nmem,key_it_ctrl,key_it_ctrl->scope,
2, rsets,
*zop->u.prox->ordered,
(!zop->u.prox->exclusion ?
}
-RSET rpn_search (ZebraHandle zh, NMEM nmem, NMEM rset_nmem,
- Z_RPNQuery *rpn, int num_bases, char **basenames,
- const char *setname,
- ZebraSet sset)
+RSET rpn_search(ZebraHandle zh, NMEM nmem, NMEM rset_nmem,
+ Z_RPNQuery *rpn, int num_bases, char **basenames,
+ const char *setname,
+ ZebraSet sset)
{
RSET rset;
oident *attrset;
char rank_type[128];
int complete_flag;
int sort_flag;
- NMEM rset_nmem=NULL;
+ NMEM rset_nmem = NULL;
*list = 0;
attent attp;
data1_local_attribute *local_attr;
- if ((r=att_getentbyatt (zh, &attp, attributeset, use_value,
+ if ((r = att_getentbyatt (zh, &attp, attributeset, use_value,
use_string)))
{
yaz_log(YLOG_DEBUG, "att_getentbyatt fail. set=%d use=%d",
}
if (ord_no == 0)
{
- char val_str[32];
- sprintf (val_str, "%d", use_value);
- zh->errCode = 114;
- zh->errString = odr_strdup (stream, val_str);
-
*num_entries = 0;
return;
}
if (trans_scan_term(zh, zapt, termz+prefix_len, reg_id))
return ;
-
+
dict_scan(zh->reg->dict, termz, &before_tmp, &after_tmp,
scan_info, scan_handle);
}
for (j = 0; j < ord_no; j++)
{
if (ptr[j] < before+after &&
- (tst=scan_info_array[j].list[ptr[j]].term) &&
+ (tst = scan_info_array[j].list[ptr[j]].term) &&
(!mterm || strcmp (tst, mterm) < 0))
{
j0 = j;
scan_term_untrans (zh, stream->mem, reg_id,
&glist[i+before].term, mterm);
rset = rset_trunc(zh, &scan_info_array[j0].list[ptr[j0]].isam_p, 1,
- glist[i+before].term, strlen(glist[i+before].term),
- NULL, 0, zapt->term->which, rset_nmem,
- key_it_ctrl,key_it_ctrl->scope);
+ glist[i+before].term, strlen(glist[i+before].term),
+ NULL, 0, zapt->term->which, rset_nmem,
+ key_it_ctrl,key_it_ctrl->scope);
ptr[j0]++;
for (j = j0+1; j<ord_no; j++)
{
if (ptr[j] < before+after &&
- (tst=scan_info_array[j].list[ptr[j]].term) &&
+ (tst = scan_info_array[j].list[ptr[j]].term) &&
!strcmp (tst, mterm))
{
- RSET rset2;
-
- rset2 =
- rset_trunc(zh, &scan_info_array[j].list[ptr[j]].isam_p, 1,
- glist[i+before].term,
- strlen(glist[i+before].term), NULL, 0,
- zapt->term->which,rset_nmem,
- key_it_ctrl, key_it_ctrl->scope);
- rset = rsbool_create_or(rset_nmem,key_it_ctrl,
- key_it_ctrl->scope, rset, rset2);
- /* FIXME - Use a proper multi-or */
-
+ RSET rsets[2];
+
+ rsets[0] = rset;
+ rsets[1] =
+ rset_trunc(zh, &scan_info_array[j].list[ptr[j]].isam_p, 1,
+ glist[i+before].term,
+ strlen(glist[i+before].term), NULL, 0,
+ zapt->term->which,rset_nmem,
+ key_it_ctrl, key_it_ctrl->scope);
+ rset = rsmulti_or_create(rset_nmem, key_it_ctrl,
+ 2, key_it_ctrl->scope, rsets);
ptr[j]++;
}
}
if (limit_set)
- rset = rsbool_create_and(rset_nmem,key_it_ctrl,key_it_ctrl->scope,
- rset, rset_dup(limit_set));
- count_set (rset, &glist[i+before].occurrences);
- rset_delete (rset);
+ {
+ RSET rsets[2];
+ rsets[0] = rset;
+ rsets[1] = rset_dup(limit_set);
+
+ rset = rsmulti_and_create(rset_nmem, key_it_ctrl,
+ key_it_ctrl->scope, 2, rsets);
+ }
+ count_set(rset, &glist[i+before].occurrences);
+ rset_delete(rset);
}
if (i < after)
{
- *num_entries -= (after-i);
- *is_partial = 1;
+ *num_entries -= (after-i);
+ *is_partial = 1;
}
-
+
/* consider terms before main term */
for (i = 0; i<ord_no; i++)
- ptr[i] = 0;
-
+ ptr[i] = 0;
+
for (i = 0; i<before; i++)
{
- int j, j0 = -1;
- const char *mterm = NULL;
- const char *tst;
- RSET rset;
-
- for (j = 0; j <ord_no; j++)
- {
- if (ptr[j] < before &&
- (tst=scan_info_array[j].list[before-1-ptr[j]].term) &&
- (!mterm || strcmp (tst, mterm) > 0))
- {
- j0 = j;
- mterm = tst;
- }
- }
- if (j0 == -1)
- break;
-
- scan_term_untrans (zh, stream->mem, reg_id,
- &glist[before-1-i].term, mterm);
-
- rset = rset_trunc
- (zh, &scan_info_array[j0].list[before-1-ptr[j0]].isam_p, 1,
- glist[before-1-i].term, strlen(glist[before-1-i].term),
- NULL, 0, zapt->term->which,rset_nmem,
- key_it_ctrl,key_it_ctrl->scope);
-
- ptr[j0]++;
-
- for (j = j0+1; j<ord_no; j++)
- {
- if (ptr[j] < before &&
- (tst=scan_info_array[j].list[before-1-ptr[j]].term) &&
- !strcmp (tst, mterm))
- {
- RSET rset2;
-
- rset2 = rset_trunc(
+ int j, j0 = -1;
+ const char *mterm = NULL;
+ const char *tst;
+ RSET rset;
+
+ for (j = 0; j <ord_no; j++)
+ {
+ if (ptr[j] < before &&
+ (tst = scan_info_array[j].list[before-1-ptr[j]].term) &&
+ (!mterm || strcmp (tst, mterm) > 0))
+ {
+ j0 = j;
+ mterm = tst;
+ }
+ }
+ if (j0 == -1)
+ break;
+
+ scan_term_untrans (zh, stream->mem, reg_id,
+ &glist[before-1-i].term, mterm);
+
+ rset = rset_trunc
+ (zh, &scan_info_array[j0].list[before-1-ptr[j0]].isam_p, 1,
+ glist[before-1-i].term, strlen(glist[before-1-i].term),
+ NULL, 0, zapt->term->which,rset_nmem,
+ key_it_ctrl,key_it_ctrl->scope);
+
+ ptr[j0]++;
+
+ for (j = j0+1; j<ord_no; j++)
+ {
+ if (ptr[j] < before &&
+ (tst = scan_info_array[j].list[before-1-ptr[j]].term) &&
+ !strcmp (tst, mterm))
+ {
+ RSET rsets[2];
+
+ rsets[0] = rset;
+ rsets[1] = rset_trunc(
zh,
&scan_info_array[j].list[before-1-ptr[j]].isam_p, 1,
glist[before-1-i].term,
strlen(glist[before-1-i].term), NULL, 0,
zapt->term->which, rset_nmem,
key_it_ctrl, key_it_ctrl->scope);
- rset = rsbool_create_and(rset_nmem,key_it_ctrl,
- key_it_ctrl->scope, rset, rset2);
- /* FIXME - multi-and ?? */
- ptr[j]++;
- }
- }
+ rset = rsmulti_or_create(rset_nmem, key_it_ctrl,
+ 2, key_it_ctrl->scope, rsets);
+
+ ptr[j]++;
+ }
+ }
if (limit_set)
- rset = rsbool_create_and(rset_nmem,key_it_ctrl,key_it_ctrl->scope,
- rset, rset_dup(limit_set));
- count_set (rset, &glist[before-1-i].occurrences);
- rset_delete (rset);
+ {
+ RSET rsets[2];
+ rsets[0] = rset;
+ rsets[1] = rset_dup(limit_set);
+
+ rset = rsmulti_and_create(rset_nmem, key_it_ctrl,
+ key_it_ctrl->scope, 2, rsets);
+ }
+ count_set (rset, &glist[before-1-i].occurrences);
+ rset_delete (rset);
}
i = before-i;
if (i)
*position -= i;
*num_entries -= i;
}
-
+
nmem_destroy(rset_nmem);
*list = glist + i; /* list is set to first 'real' entry */
yaz_log(YLOG_DEBUG, "position = %d, num_entries = %d",
- *position, *num_entries);
+ *position, *num_entries);
if (zh->errCode)
yaz_log(YLOG_DEBUG, "scan error: %d", zh->errCode);
}
-
+