/*
- * Copyright (C) 1994-1997, Index Data I/S
+ * Copyright (C) 1995-1998, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zrpn.c,v $
- * Revision 1.68 1997-10-27 14:33:06 adam
+ * Revision 1.74 1998-02-10 12:03:06 adam
+ * Implemented Sort.
+ *
+ * Revision 1.73 1998/01/29 13:40:11 adam
+ * Better logging for scan service.
+ *
+ * Revision 1.72 1998/01/07 13:53:41 adam
+ * Queries using simple ranked operands returns right number of hits.
+ *
+ * Revision 1.71 1997/12/18 10:54:24 adam
+ * New method result set method rs_hits that returns the number of
+ * hits in result-set (if known). The ranked result set returns real
+ * number of hits but only when not combined with other operands.
+ *
+ * Revision 1.70 1997/10/31 12:34:43 adam
+ * Changed a few log statements.
+ *
+ * Revision 1.69 1997/10/29 12:05:02 adam
+ * Server produces diagnostic "Unsupported Attribute Set" when appropriate.
+ *
+ * Revision 1.68 1997/10/27 14:33:06 adam
* Moved towards generic character mapping depending on "structure"
* field in abstract syntax file. Fixed a few memory leaks. Fixed
* bug with negative integers when doing searches with relational
ISAM_P *new_isam_p_buf;
#ifdef TERM_COUNT
int *new_term_no;
-#endif
-
+#endif
p->isam_p_size = 2*p->isam_p_size + 100;
new_isam_p_buf = xmalloc (sizeof(*new_isam_p_buf) *
p->isam_p_size);
int max_pos, prefix_len = 0;
termp = *term_sub;
- if (!att_getentbyatt (zi, &attp, curAttributeSet, use_value))
+ if ((r=att_getentbyatt (zi, &attp, curAttributeSet, use_value)))
{
- logf (LOG_DEBUG, "att_getentbyatt fail. set=%d use=%d",
- curAttributeSet, use_value);
- zi->errCode = 114;
+ logf (LOG_DEBUG, "att_getentbyatt fail. set=%d use=%d r=%d",
+ curAttributeSet, use_value, r);
+ if (r == -1)
+ zi->errCode = 114;
+ else
+ zi->errCode = 121;
return -1;
}
if (zebTargetInfo_curDatabase (zi->zti, basenames[base_no]))
term_dict[prefix_len++] = ')';
term_dict[prefix_len++] = 1;
term_dict[prefix_len++] = reg_type;
- logf (LOG_LOG, "reg_type = %d", term_dict[prefix_len-1]);
+ logf (LOG_DEBUG, "reg_type = %d", term_dict[prefix_len-1]);
term_dict[prefix_len] = '\0';
if (!relational_term (zi, zapt, &termp, term_dict,
attributeSet, grep_info, &max_pos, reg_type))
int r;
parms.key_size = sizeof(struct it_key);
- parms.max_rec = 1000;
+ parms.max_rec = 200;
parms.cmp = key_compare_it;
parms.get_pos = key_get_pos;
parms.is = zi->isam;
parms.isc = zi->isamc;
parms.no_terms = 0;
+ parms.method = RSREL_METHOD_A;
if (zapt->term->which != Z_Term_general)
{
while (1)
{
- logf (LOG_LOG, "APT_phrase termp=%s", termp);
+ logf (LOG_DEBUG, "APT_phrase termp=%s", termp);
grep_info.isam_p_indx = 0;
r = field_term (zi, zapt, &termp, attributeSet, &grep_info,
reg_type, complete_flag, num_bases, basenames);
}
static RSET rpn_search_structure (ZServerInfo *zi, Z_RPNStructure *zs,
- oid_value attributeSet,
+ oid_value attributeSet, ODR stream,
int num_bases, char **basenames)
{
RSET r = NULL;
bool_parms.rset_l = rpn_search_structure (zi, zs->u.complex->s1,
- attributeSet,
+ attributeSet, stream,
num_bases, basenames);
if (bool_parms.rset_l == NULL)
return NULL;
if (rset_is_ranked(bool_parms.rset_l))
soft = 1;
bool_parms.rset_r = rpn_search_structure (zi, zs->u.complex->s2,
- attributeSet,
+ attributeSet, stream,
num_bases, basenames);
if (bool_parms.rset_r == NULL)
{
}
if (*zop->u.prox->proximityUnitCode != Z_ProxUnit_word)
{
- char *val = odr_malloc (zi->odr, 16);
+ char *val = odr_malloc (stream, 16);
zi->errCode = 132;
zi->errString = val;
sprintf (val, "%d", *zop->u.prox->proximityUnitCode);
RSFD rfd;
logf (LOG_DEBUG, "count_set");
+
*count = 0;
rfd = rset_open (r, RSETF_READ|RSETF_SORT_SYSNO);
while (rset_read (r, rfd, &key))
logf (LOG_DEBUG, "%d keys, %d distinct sysnos", kno, *count);
}
-int rpn_search (ZServerInfo *zi,
+int rpn_search (ZServerInfo *zi, ODR stream,
Z_RPNQuery *rpn, int num_bases, char **basenames,
const char *setname, int *hits)
{
+ int i;
RSET rset;
oident *attrset;
oid_value attributeSet;
attrset = oid_getentbyoid (rpn->attributeSetId);
attributeSet = attrset->value;
- rset = rpn_search_structure (zi, rpn->RPNStructure, attributeSet,
+ rset = rpn_search_structure (zi, rpn->RPNStructure, attributeSet, stream,
num_bases, basenames);
if (!rset)
return zi->errCode;
if (rset_is_volatile(rset))
- count_set_save(zi, &rset,hits);
+ count_set_save(zi, &rset, hits);
+ else if ((i = rset_hits (rset)) >= 0)
+ *hits = i;
else
count_set (rset, hits);
resultSetAdd (zi, setname, 1, rset);
}
-static void scan_term_untrans (ZServerInfo *zi, int reg_type,
+static void scan_term_untrans (ZServerInfo *zi, ODR stream, int reg_type,
char **dstp, const char *src)
{
- char *dst = odr_malloc (zi->odr, strlen(src)*2+1);
+ char *dst = odr_malloc (stream, strlen(src)*2+1);
*dstp = dst;
while (*src)
*dst = '\0';
}
-int rpn_scan (ZServerInfo *zi, Z_AttributesPlusTerm *zapt,
+int rpn_scan (ZServerInfo *zi, ODR stream, Z_AttributesPlusTerm *zapt,
oid_value attributeset,
int num_bases, char **basenames,
int *position, int *num_entries, struct scan_entry **list,
char *search_type = NULL;
int complete_flag;
- logf (LOG_DEBUG, "scan, position = %d, num = %d", pos, num);
-
if (attributeset == VAL_NONE)
attributeset = VAL_BIB1;
+
+ zlog_scan (zapt, attributeset);
+ logf (LOG_DEBUG, "position = %d, num = %d", pos, num);
attr_init (&use, zapt, 1);
use_value = attr_find (&use, &attributeset);
- logf (LOG_DEBUG, "use value %d", use_value);
if (zebra_maps_attr (zi->zebra_maps, zapt, ®_type, &search_type,
&complete_flag))
use_value = 1016;
for (base_no = 0; base_no < num_bases && ord_no < 32; base_no++)
{
+ int r;
attent attp;
data1_local_attribute *local_attr;
- if (!att_getentbyatt (zi, &attp, attributeset, use_value))
+ if ((r=att_getentbyatt (zi, &attp, attributeset, use_value)))
{
logf (LOG_DEBUG, "att_getentbyatt fail. set=%d use=%d",
attributeset, use_value);
- return zi->errCode = 114;
+ if (r == -1)
+ zi->errCode = 114;
+ else
+ zi->errCode = 121;
}
if (zebTargetInfo_curDatabase (zi->zti, basenames[base_no]))
{
return zi->errCode = 113;
before = pos-1;
after = 1+num-pos;
- scan_info_array = odr_malloc (zi->odr, ord_no * sizeof(*scan_info_array));
+ scan_info_array = odr_malloc (stream, ord_no * sizeof(*scan_info_array));
for (i = 0; i < ord_no; i++)
{
int j, prefix_len = 0;
scan_info->before = before;
scan_info->after = after;
- scan_info->odr = zi->odr;
+ scan_info->odr = stream;
- scan_info->list = odr_malloc (zi->odr, (before+after)*
+ scan_info->list = odr_malloc (stream, (before+after)*
sizeof(*scan_info->list));
for (j = 0; j<before+after; j++)
scan_info->list[j].term = NULL;
dict_scan (zi->dict, termz, &before_tmp, &after_tmp, scan_info,
scan_handle);
}
- glist = odr_malloc (zi->odr, (before+after)*sizeof(*glist));
+ glist = odr_malloc (stream, (before+after)*sizeof(*glist));
for (i = 0; i < ord_no; i++)
ptr[i] = before;
}
if (j0 == -1)
break;
- scan_term_untrans (zi, reg_type, &glist[i+before].term, mterm);
+ scan_term_untrans (zi, stream, reg_type,
+ &glist[i+before].term, mterm);
rset = rset_trunc (zi, &scan_info_array[j0].list[ptr[j0]].isam_p, 1);
ptr[j0]++;
if (j0 == -1)
break;
- scan_term_untrans (zi, reg_type, &glist[before-1-i].term, mterm);
+ scan_term_untrans (zi, stream, reg_type,
+ &glist[before-1-i].term, mterm);
rset = rset_trunc
(zi, &scan_info_array[j0].list[before-1-ptr[j0]].isam_p, 1);