* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zrpn.c,v $
- * Revision 1.14 1995-09-28 12:10:32 adam
+ * Revision 1.19 1995-10-06 10:43:56 adam
+ * Scan added. 'occurrences' in scan entries not set yet.
+ *
+ * Revision 1.18 1995/10/04 16:57:20 adam
+ * Key input and merge sort in one pass.
+ *
+ * Revision 1.17 1995/10/04 12:55:17 adam
+ * Bug fix in ranked search. Use=Any keys inserted.
+ *
+ * Revision 1.16 1995/10/02 16:24:40 adam
+ * Use attribute actually used in search requests.
+ *
+ * Revision 1.15 1995/10/02 15:18:52 adam
+ * New member in recRetrieveCtrl: diagnostic.
+ *
+ * Revision 1.14 1995/09/28 12:10:32 adam
* Bug fixes. Field prefix used in queries.
*
* Revision 1.13 1995/09/18 14:17:50 adam
const char *info;
AttrType truncation;
int truncation_value;
+ AttrType use;
+ int use_value;
+ attr_init (&use, zapt, 1);
+ use_value = attr_find (&use);
+ logf (LOG_DEBUG, "use value %d", use_value);
attr_init (&truncation, zapt, 5);
truncation_value = attr_find (&truncation);
logf (LOG_DEBUG, "truncation value %d", truncation_value);
+
+ if (use_value == -1)
+ use_value = 1016;
+ i = index_word_prefix (term_dict, 1, use_value);
+
switch (truncation_value)
{
case -1: /* not specified */
case 100: /* do not truncate */
- strcpy (term_dict, term_sub);
+ strcat (term_dict, term_sub);
logf (LOG_DEBUG, "dict_lookup: %s", term_dict);
if ((info = dict_lookup (zi->wordDict, term_dict)))
add_isam_p (info);
break;
case 1: /* right truncation */
- strcpy (term_dict, term_sub);
+ strcat (term_dict, term_sub);
strcat (term_dict, ".*");
dict_lookup_grep (zi->wordDict, term_dict, 0, grep_handle);
break;
zi->errCode = 120;
return -1;
case 101: /* process # in term */
- for (j = 0, i = 0; term_sub[i] && i < 2; i++)
+ 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] == '#')
dict_lookup_grep (zi->wordDict, term_dict, 0, grep_handle);
break;
case 102: /* regular expression */
- strcpy (term_dict, term_sub);
+ strcat (term_dict, term_sub);
dict_lookup_grep (zi->wordDict, term_dict, 0, grep_handle);
break;
}
return 0;
}
+static void trans_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt,
+ char *termz)
+{
+ size_t i, sizez;
+ Z_Term *term = zapt->term;
+
+ sizez = term->u.general->len;
+ if (sizez > IT_MAX_WORD)
+ sizez = IT_MAX_WORD;
+ for (i = 0; i < sizez; i++)
+ termz[i] = index_char_cvt (term->u.general->buf[i]);
+ termz[i] = '\0';
+}
+
static RSET rpn_search_APT_relevance (ZServerInfo *zi,
Z_AttributesPlusTerm *zapt)
{
char term_sub[IT_MAX_WORD+1];
char *p0 = termz, *p1 = NULL;
Z_Term *term = zapt->term;
- size_t sizez, i;
parms.key_size = sizeof(struct it_key);
parms.max_rec = 100;
zi->errCode = 124;
return NULL;
}
- i = index_word_prefix (termz, 1, 1016);
- sizez = i + term->u.general->len;
- if (sizez > IT_MAX_WORD)
- sizez = IT_MAX_WORD;
- for ( ; i < sizez; i++)
- termz[i] = index_char_cvt (term->u.general->buf[i]);
- termz[i] = '\0';
-
+ trans_term (zi, zapt, termz);
isam_p_indx = 0; /* global, set by trunc_term - see below */
while (1)
{
char termz[IT_MAX_WORD+1];
Z_Term *term = zapt->term;
- size_t sizez, i;
if (term->which != Z_Term_general)
{
zi->errCode = 124;
return NULL;
}
- i = index_word_prefix (termz, 1, 1016);
- sizez = i + term->u.general->len;
- if (sizez > IT_MAX_WORD)
- sizez = IT_MAX_WORD;
- for ( ; i < sizez; i++)
- termz[i] = index_char_cvt (term->u.general->buf[i]);
- termz[i] = '\0';
-
+ trans_term (zi, zapt, termz);
isam_p_indx = 0; /* global, set by trunc_term - see below */
if (trunc_term (zi, zapt, termz, &isam_positions))
return NULL;
char termz[IT_MAX_WORD+1];
Z_Term *term = zapt->term;
- size_t sizez, i;
if (term->which != Z_Term_general)
{
zi->errCode = 124;
return NULL;
}
- i = index_word_prefix (termz, 1, 1016);
- sizez = i + term->u.general->len;
- if (sizez > IT_MAX_WORD)
- sizez = IT_MAX_WORD;
- for ( ; i < sizez; i++)
- termz[i] = index_char_cvt (term->u.general->buf[i]);
- termz[i] = '\0';
-
+ trans_term (zi, zapt, termz);
isam_p_indx = 0; /* global, set by trunc_term - see below */
if (trunc_term (zi, zapt, termz, &isam_positions))
return NULL;
return zi->errCode;
}
+static struct scan_entry *scan_list;
+static ODR scan_odr;
+static int scan_before, scan_after;
+static int scan_prefix;
+
+static int scan_handle (Dict_char *name, const char *info, int pos)
+{
+ int idx;
+
+ if (pos > 0)
+ idx = scan_after - pos + scan_before;
+ else
+ idx = - pos - 1;
+ scan_list[idx].term = odr_malloc (scan_odr, strlen(name + scan_prefix)+1);
+ strcpy (scan_list[idx].term, name + scan_prefix);
+ scan_list[idx].occurrences = 1;
+ logf (LOG_DEBUG, "pos=%3d idx=%3d name=%s", pos, idx, name);
+ return 0;
+}
+
+int rpn_scan (ZServerInfo *zi, ODR odr, Z_AttributesPlusTerm *zapt,
+ int *position, int *num_entries, struct scan_entry **list)
+{
+ int i, j, sizez;
+ int pos = *position;
+ int num = *num_entries;
+ int before;
+ int after;
+ char termz[IT_MAX_WORD+20];
+ AttrType use;
+ int use_value;
+ Z_Term *term = zapt->term;
+
+ logf (LOG_DEBUG, "scan, position = %d, num = %d", pos, num);
+ scan_before = before = pos-1;
+ scan_after = after = 1+num-pos;
+ scan_odr = odr;
+
+ logf (LOG_DEBUG, "scan, before = %d, after = %d", before, after);
+
+ scan_list = *list = odr_malloc (odr, (before+after)*sizeof(**list));
+ attr_init (&use, zapt, 1);
+ use_value = attr_find (&use);
+ logf (LOG_DEBUG, "use value %d", use_value);
+
+ if (use_value == -1)
+ use_value = 1016;
+ scan_prefix = i = index_word_prefix (termz, 1, use_value);
+ sizez = term->u.general->len;
+ if (sizez > IT_MAX_WORD)
+ sizez = IT_MAX_WORD;
+ for (j = 0; j<sizez; j++)
+ termz[j+i] = index_char_cvt (term->u.general->buf[j]);
+ termz[j+i] = '\0';
+
+ dict_scan (zi->wordDict, termz, &before, &after, scan_handle);
+ return 0;
+}
+