-/* $Id: zrpn.c,v 1.167 2005-01-15 19:38:29 adam Exp $
+/* $Id: zrpn.c,v 1.171 2005-03-11 17:56:34 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
} AttrType;
-static int log_level_set=0;
-static int log_level_rpn=0;
+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)
{
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)
+ struct grep_info *p)
{
if (!log_level_set)
{
log_level_rpn = yaz_log_module_level("rpn");
- log_level_set=1;
+ log_level_set = 1;
}
if (p->isam_p_indx == p->isam_p_size)
{
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,
return *s0;
}
+
+static void esc_str(char *out_buf, int out_size,
+ const char *in_buf, int in_size)
+{
+ int k;
+
+ assert(out_buf);
+ assert(in_buf);
+ assert(out_size > 20);
+ *out_buf = '\0';
+ for (k = 0; k<in_size; k++)
+ {
+ int c = in_buf[k] & 0xff;
+ int pc;
+ if (c < 32 || c > 126)
+ pc = '?';
+ else
+ pc = c;
+ sprintf(out_buf +strlen(out_buf), "%02X:%c ", c, pc);
+ if (strlen(out_buf) > out_size-20)
+ {
+ strcat(out_buf, "..");
+ break;
+ }
+ }
+}
+
#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)
{
- const char *s0, *s1;
+ const char *s0;
const char **map;
int i = 0;
int j = 0;
s0 = *src;
while (*s0)
{
- s1 = s0;
- map = zebra_maps_input(zebra_maps, reg_type, &s0, strlen(s0), 0);
+ const char *s1 = s0;
+ int q_map_match = 0;
+ map = zebra_maps_search(zebra_maps, reg_type, &s0, strlen(s0),
+ &q_map_match);
if (space_split)
{
if (**map == *CHR_SPACE)
space_start = space_end = 0;
}
}
- /* add non-space char */
- while (s1 < s0)
- {
- if (strchr(REGEX_CHARS, *s1))
- dst[i++] = '\\';
- dst_term[j++] = *s1;
- dst[i++] = *s1++;
- }
+ /* add non-space char */
+ memcpy(dst_term+j, s1, s0 - s1);
+ j += (s0 - s1);
+ if (!q_map_match)
+ {
+ while (s1 < s0)
+ {
+ if (strchr(REGEX_CHARS, *s1))
+ dst[i++] = '\\';
+ dst[i++] = *s1++;
+ }
+ }
+ else
+ {
+ char tmpbuf[80];
+ esc_str(tmpbuf, sizeof(tmpbuf), map[0], strlen(map[0]));
+
+ strcpy(dst + i, map[0]);
+ i += strlen(map[0]);
+ }
}
dst[i] = '\0';
dst_term[j] = '\0';
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)
{
- const char *s0, *s1;
+ const char *s0;
const char **map;
int i = 0;
int j = 0;
}
else
{
- s1 = s0;
- map = zebra_maps_input(zebra_maps, reg_type, &s0, strlen(s0), 0);
+ const char *s1 = s0;
+ int q_map_match = 0;
+ map = zebra_maps_search(zebra_maps, reg_type, &s0, strlen(s0),
+ &q_map_match);
if (space_split && **map == *CHR_SPACE)
break;
- while (s1 < s0)
- {
- if (strchr(REGEX_CHARS, *s1))
- dst[i++] = '\\';
- dst_term[j++] = *s1;
- dst[i++] = *s1++;
- }
+
+ /* add non-space char */
+ memcpy(dst_term+j, s1, s0 - s1);
+ j += (s0 - s1);
+ if (!q_map_match)
+ {
+ while (s1 < s0)
+ {
+ if (strchr(REGEX_CHARS, *s1))
+ dst[i++] = '\\';
+ dst[i++] = *s1++;
+ }
+ }
+ else
+ {
+ char tmpbuf[80];
+ esc_str(tmpbuf, sizeof(tmpbuf), map[0], strlen(map[0]));
+
+ strcpy(dst + i, map[0]);
+ i += strlen(map[0]);
+ }
}
}
dst[i] = '\0';
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)
{
int i = 0;
int j = 0;
- const char *s0, *s1;
+ const char *s0;
const char **map;
if (!term_pre(zebra_maps, reg_type, src, "^\\()[].*+?|", "(", !space_split))
}
else
{
- s1 = s0;
- map = zebra_maps_input(zebra_maps, reg_type, &s0, strlen(s0), 0);
- if (**map == *CHR_SPACE)
+ const char *s1 = s0;
+ int q_map_match = 0;
+ map = zebra_maps_search(zebra_maps, reg_type, &s0, strlen(s0),
+ &q_map_match);
+ if (space_split && **map == *CHR_SPACE)
break;
- while (s1 < s0)
- {
- if (strchr(REGEX_CHARS, *s1))
- dst[i++] = '\\';
- dst_term[j++] = *s1;
- dst[i++] = *s1++;
- }
+
+ /* add non-space char */
+ memcpy(dst_term+j, s1, s0 - s1);
+ j += (s0 - s1);
+ if (!q_map_match)
+ {
+ while (s1 < s0)
+ {
+ if (strchr(REGEX_CHARS, *s1))
+ dst[i++] = '\\';
+ dst[i++] = *s1++;
+ }
+ }
+ else
+ {
+ char tmpbuf[80];
+ esc_str(tmpbuf, sizeof(tmpbuf), map[0], strlen(map[0]));
+
+ strcpy(dst + i, map[0]);
+ i += strlen(map[0]);
+ }
}
}
dst[i] = '\0';
dst_term[j] = '\0';
*src = s0;
+
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)
dst[i++] = '.';
dst_term[j++] = *s0++;
}
+ else
{
s1 = s0;
map = zebra_maps_input(zebra_maps, reg_type, &s0, strlen(s0), 0);
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)
dst[i++] = '.';
dst_term[j++] = *s0++;
}
+ else
{
s1 = s0;
map = zebra_maps_input(zebra_maps, reg_type, &s0, strlen(s0), 0);
{
/* 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
use_value = 1016;
for (base_no = 0; base_no < num_bases; base_no++)
{
+ int ord = -1;
int attr_ok = 0;
int regex_range = 0;
int init_pos = 0;
}
if (xpath_use > 0 && use_value == -2)
{
- use_value = xpath_use;
+ /* xpath mode and we have a string attribute */
attp.local_attributes = &id_xpath_attr;
attp.attset_ordinal = VAL_IDXPATH;
id_xpath_attr.next = 0;
+
+ use_value = xpath_use; /* xpath_use as use-attribute now */
id_xpath_attr.local = use_value;
}
- else if (curAttributeSet == VAL_IDXPATH)
+ else if (curAttributeSet == VAL_IDXPATH && use_value >= 0)
{
+ /* X-Path attribute, use numeric value directly */
attp.local_attributes = &id_xpath_attr;
attp.attset_ordinal = VAL_IDXPATH;
id_xpath_attr.next = 0;
id_xpath_attr.local = use_value;
}
- else
+ else if (use_string &&
+ (ord = zebraExplain_lookup_attr_str(zh->reg->zei,
+ use_string)) >= 0)
+ {
+ /* we have a match for a raw string attribute */
+ char ord_buf[32];
+ int i, ord_len;
+
+ if (prefix_len)
+ term_dict[prefix_len++] = '|';
+ else
+ term_dict[prefix_len++] = '(';
+
+ ord_len = key_SU_encode (ord, ord_buf);
+ for (i = 0; i<ord_len; i++)
+ {
+ term_dict[prefix_len++] = 1;
+ term_dict[prefix_len++] = ord_buf[i];
+ }
+ attp.local_attributes = 0; /* no more attributes */
+ }
+ else
{
- if ((r=att_getentbyatt (zh, &attp, curAttributeSet, use_value,
- use_string)))
+ /* lookup in the .att files . Allow string as well */
+ if ((r = att_getentbyatt (zh, &attp, curAttributeSet, use_value,
+ use_string)))
{
yaz_log(YLOG_DEBUG, "att_getentbyatt fail. set=%d use=%d r=%d",
curAttributeSet, use_value, r);
continue;
}
}
- for (local_attr = attp.local_attributes; local_attr;
- local_attr = local_attr->next)
- {
- int ord;
- char ord_buf[32];
- int i, ord_len;
-
- ord = zebraExplain_lookupSU (zh->reg->zei, attp.attset_ordinal,
- local_attr->local);
- if (ord < 0)
- continue;
- if (prefix_len)
- term_dict[prefix_len++] = '|';
- else
- term_dict[prefix_len++] = '(';
-
- ord_len = key_SU_encode (ord, ord_buf);
- for (i = 0; i<ord_len; i++)
- {
- term_dict[prefix_len++] = 1;
- term_dict[prefix_len++] = ord_buf[i];
- }
- }
+ for (local_attr = attp.local_attributes; local_attr;
+ local_attr = local_attr->next)
+ {
+ char ord_buf[32];
+ int i, ord_len;
+
+ ord = zebraExplain_lookup_attr_su(zh->reg->zei,
+ attp.attset_ordinal,
+ local_attr->local);
+ if (ord < 0)
+ continue;
+ if (prefix_len)
+ term_dict[prefix_len++] = '|';
+ else
+ term_dict[prefix_len++] = '(';
+
+ ord_len = key_SU_encode (ord, ord_buf);
+ for (i = 0; i<ord_len; i++)
+ {
+ term_dict[prefix_len++] = 1;
+ term_dict[prefix_len++] = ord_buf[i];
+ }
+ }
if (!prefix_len)
{
#if 1
}
if (attr_ok)
{
+ char buf[80];
+ const char *input = term_dict + prefix_len;
+ esc_str(buf, sizeof(buf), input, strlen(input));
+ }
+ if (attr_ok)
+ {
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_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,
}
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,
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_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 ord_buf[32];
int i, ord_len;
- ord = zebraExplain_lookupSU (zh->reg->zei, attp.attset_ordinal,
- local_attr->local);
+ ord = zebraExplain_lookup_attr_su(zh->reg->zei,
+ attp.attset_ordinal,
+ local_attr->local);
if (ord < 0)
continue;
if (prefix_len)
}
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,
char term_dict[2048];
char ord_buf[32];
int prefix_len = 0;
- int ord = zebraExplain_lookupSU (zh->reg->zei, curAttributeSet, use);
+ int ord = zebraExplain_lookup_attr_su(zh->reg->zei, curAttributeSet, use);
int ord_len, i, r, max_pos;
int term_type = Z_Term_characterString;
const char *flags = "void";
grep_info.isam_p_indx = 0;
r = dict_lookup_grep(zh->reg->dict, term_dict, 0,
&grep_info, &max_pos, 0, grep_handle);
- yaz_log (YLOG_LOG, "%s %d positions", term,
+ yaz_log (YLOG_DEBUG, "%s %d positions", term,
grep_info.isam_p_indx);
rset = rset_trunc(zh, grep_info.isam_p_buf,
grep_info.isam_p_indx, term, strlen(term),
/ -> 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)
*/
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;
}
if (!log_level_set)
{
log_level_rpn = yaz_log_module_level("rpn");
- log_level_set=1;
+ 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 ?
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",
{
int ord;
- ord = zebraExplain_lookupSU (zh->reg->zei, attp.attset_ordinal,
- local_attr->local);
+ ord = zebraExplain_lookup_attr_su(zh->reg->zei,
+ attp.attset_ordinal,
+ local_attr->local);
if (ord > 0)
ords[ord_no++] = ord;
}
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);
}
-
+