* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zrpn.c,v $
- * Revision 1.32 1995-10-27 14:00:11 adam
+ * Revision 1.37 1995-12-06 15:05:28 adam
+ * More verbose in count_set.
+ *
+ * Revision 1.36 1995/12/06 12:41:27 adam
+ * New command 'stat' for the index program.
+ * Filenames can be read from stdin by specifying '-'.
+ * Bug fix/enhancement of the transformation from terms to regular
+ * expressons in the search engine.
+ *
+ * Revision 1.35 1995/11/27 09:29:00 adam
+ * Bug fixes regarding conversion to regular expressions.
+ *
+ * Revision 1.34 1995/11/16 17:00:56 adam
+ * Better logging of rpn query.
+ *
+ * Revision 1.33 1995/11/01 13:58:28 quinn
+ * Moving data1 to yaz/retrieval
+ *
+ * Revision 1.32 1995/10/27 14:00:11 adam
* Implemented detection of database availability.
*
* Revision 1.31 1995/10/17 18:02:10 adam
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
+#include <ctype.h>
#include "zserver.h"
-#include <attribute.h>
+#include "attribute.h"
#include <rsisam.h>
#include <rstemp.h>
attp->local_attribute, basename);
}
-/*
- * attr_print: log attributes
- */
-static void attr_print (Z_AttributesPlusTerm *t)
-{
- int of, i;
- for (of = 0; of < t->num_attributes; of++)
- {
- Z_AttributeElement *element;
- element = t->attributeList[of];
-
- switch (element->which)
- {
- case Z_AttributeValue_numeric:
- logf (LOG_DEBUG, "attributeType=%d value=%d",
- *element->attributeType,
- *element->value.numeric);
- break;
- case Z_AttributeValue_complex:
- logf (LOG_DEBUG, "attributeType=%d complex",
- *element->attributeType);
- for (i = 0; i<element->value.complex->num_list; i++)
- {
- if (element->value.complex->list[i]->which ==
- Z_StringOrNumeric_string)
- logf (LOG_DEBUG, " string: '%s'",
- element->value.complex->list[i]->u.string);
- else if (element->value.complex->list[i]->which ==
- Z_StringOrNumeric_numeric)
- logf (LOG_DEBUG, " numeric: '%d'",
- *element->value.complex->list[i]->u.numeric);
- }
- break;
- default:
- assert (0);
- }
- }
-}
-
typedef struct {
int type;
int major;
return 1;
}
+static void verbatim_char (int ch, int *indx, char *dst)
+{
+ if (!isalnum (ch))
+ dst[(*indx)++] = '\\';
+ dst[(*indx)++] = ch;
+}
+
static int trunc_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt,
const char *term_sub,
oid_value attributeSet, struct grep_info *grep_info,
{
case -1: /* not specified */
case 100: /* do not truncate */
- strcat (term_dict, "(");
- strcat (term_dict, term_sub);
- strcat (term_dict, ")");
- logf (LOG_DEBUG, "dict_lookup_grep: %s", term_dict);
+ j = strlen(term_dict);
+ term_dict[j++] = '(';
+ for (i = 0; term_sub[i]; i++)
+ verbatim_char (term_sub[i], &j, term_dict);
+ strcpy (term_dict+j, ")");
r = dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info,
&max_pos, grep_handle);
if (r)
logf (LOG_WARN, "dict_lookup_grep err, trunc=none:%d", r);
break;
case 1: /* right truncation */
- strcat (term_dict, term_sub);
- strcat (term_dict, ".*");
+ j = strlen(term_dict);
+ term_dict[j++] = '(';
+ for (i = 0; term_sub[i]; i++)
+ verbatim_char (term_sub[i], &j, term_dict);
+ strcpy (term_dict+j, ".*)");
dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info,
&max_pos, grep_handle);
break;
zi->errCode = 120;
return -1;
case 101: /* process # in term */
- for (j = strlen(term_dict), i = 0; term_sub[i] && i < 2; i++)
- term_dict[j++] = term_sub[i];
- for (; term_sub[i]; i++)
- if (term_sub[i] == '#')
+ j = strlen(term_dict);
+ term_dict[j++] = '(';
+ for (i=0; term_sub[i]; i++)
+ if (term_sub[i] == '#' && i > 2)
{
term_dict[j++] = '.';
term_dict[j++] = '*';
}
else
- term_dict[j++] = term_sub[i];
- term_dict[j] = '\0';
+ verbatim_char (term_sub[i], &j, term_dict);
+ strcpy (term_dict+j, ")");
r = dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info,
&max_pos, grep_handle);
if (r)
r);
break;
case 102: /* regular expression */
- strcat (term_dict, "(");
- strcat (term_dict, term_sub);
- strcat (term_dict, ")");
- logf (LOG_DEBUG, "dict_lookup_grep: %s", term_dict);
+ sprintf (term_dict + strlen(term_dict), "(%s)", term_sub);
r = dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info,
&max_pos, grep_handle);
if (r)
break;
}
}
- logf (LOG_DEBUG, "max_pos = %d", max_pos);
if (max_pos <= strlen(basenames[base_no]))
{
zi->errCode = 109; /* Database unavailable */
static void count_set (RSET r, int *count)
{
int psysno = 0;
+ int kno = 0;
struct it_key key;
RSFD rfd;
psysno = key.sysno;
(*count)++;
}
+ kno++;
}
rset_close (r, rfd);
- logf (LOG_DEBUG, "%d distinct sysnos", *count);
+ logf (LOG_DEBUG, "%d keys, %d distinct sysnos", kno, *count);
}
int rpn_search (ZServerInfo *zi,
oident *attrset;
oid_value attributeSet;
+ zlog_rpn (rpn);
+
zi->errCode = 0;
zi->errString = NULL;
-
+
attrset = oid_getentbyoid (rpn->attributeSetId);
attributeSet = attrset->value;
-
rset = rpn_search_structure (zi, rpn->RPNStructure, attributeSet,
num_bases, basenames);
if (!rset)