* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zinfo.c,v $
- * Revision 1.1 1996-05-13 14:23:07 adam
+ * Revision 1.2 1996-05-14 06:16:41 adam
+ * Compact use/set bytes used in search service.
+ *
+ * Revision 1.1 1996/05/13 14:23:07 adam
* Work on compaction of set/use bytes in dictionary.
*
*/
char *databaseName;
int sysno;
int readFlag;
+ int dirty;
struct zebDatabaseInfo *next;
};
if (writeFlag)
{
- Record grec;
char p0[4096], *p = p0;
memcpy (p, &zti->dictNum, sizeof(zti->dictNum));
p += sizeof(zti->dictNum);
for (zdi = zti->databaseInfo; zdi; zdi=zdi->next)
{
- if (zdi->readFlag || !zdi->sysno)
+ if (zdi->dirty)
{
char q0[4096], *q = q0;
struct zebSUInfoB *zsui;
memcpy (p, &zdi->sysno, sizeof(zdi->sysno));
p += sizeof(zdi->sysno);
}
- *p = '\0';
- grec = rec_get (zti->records, 1);
- xfree (grec->info[0]);
- grec->size[0] = p-p0;
- grec->info[0] = xmalloc (grec->size[0]);
- memcpy (grec->info[0], p0, grec->size[0]);
- rec_put (zti->records, &grec);
+ *p++ = '\0';
+ if (zti->dirty)
+ {
+ Record grec = rec_get (zti->records, 1);
+
+ assert (grec);
+ xfree (grec->info[0]);
+ grec->size[0] = p-p0;
+ grec->info[0] = xmalloc (grec->size[0]);
+ memcpy (grec->info[0], p0, grec->size[0]);
+ rec_put (zti->records, &grec);
+ }
}
for (zdi = zti->databaseInfo; zdi; zdi = zdi1)
{
memcpy (&(*zdi)->sysno, p, sizeof((*zdi)->sysno));
p += sizeof((*zdi)->sysno);
(*zdi)->readFlag = 1;
+ (*zdi)->dirty = 0;
zdi = &(*zdi)->next;
}
assert (p - rec->info[0] == rec->size[0]-1);
rec->info[0] = xmalloc (1+sizeof(zti->dictNum));
memcpy (rec->info[0], &zti->dictNum, sizeof(zti->dictNum));
rec->info[0][sizeof(zti->dictNum)] = '\0';
+ rec->size[0] = sizeof(zti->dictNum)+1;
rec_put (records, &rec);
}
}
zdi->readFlag = 0;
zdi->databaseName = xstrdup (database);
zdi->SUInfo = NULL;
+ zdi->dirty = 1;
+ zti->dirty = 1;
zti->curDatabaseInfo = zdi;
return 0;
}
zsui = xmalloc (sizeof(*zsui));
zsui->next = zti->curDatabaseInfo->SUInfo;
zti->curDatabaseInfo->SUInfo = zsui;
+ zti->curDatabaseInfo->dirty = 1;
+ zti->dirty = 1;
zsui->info.set = set;
zsui->info.use = use;
zsui->info.ordinal = (zti->dictNum)++;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zrpn.c,v $
- * Revision 1.43 1996-05-09 09:54:43 adam
+ * Revision 1.44 1996-05-14 06:16:44 adam
+ * Compact use/set bytes used in search service.
+ *
+ * Revision 1.43 1996/05/09 09:54:43 adam
* Server supports maps from one logical attributes to a list of physical
* attributes.
* The extraction process doesn't make space consuming 'any' keys.
for (base_no = 0; base_no < num_bases; base_no++)
{
+#if 1
+ attent *attp;
+ data1_local_attribute *local_attr;
+ int max_pos, prefix_len = 0;
+
+ attp = att_getentbyatt (curAttributeSet, use_value);
+ if (!attp)
+ {
+ zi->errCode = 114;
+ return -1;
+ }
+ if (zebTargetInfo_curDatabase (zi->zti, basenames[base_no]))
+ {
+ zi->errCode = 109; /* Database unavailable */
+ zi->errString = basenames[base_no];
+ }
+ for (local_attr = attp->local_attributes; local_attr;
+ local_attr = local_attr->next)
+ {
+ int ord;
+
+ ord = zebTargetInfo_lookupSU (zi->zti, attp->attset_ordinal,
+ local_attr->local);
+ if (ord < 0)
+ continue;
+ if (prefix_len)
+ term_dict[prefix_len++] = '|';
+ else
+ term_dict[prefix_len++] = '(';
+ if ((ord >= 'A' && ord <= 'Z') || (ord >= 'a' && ord <= 'z'))
+ term_dict[prefix_len++] = ord;
+ else
+ {
+ term_dict[prefix_len++] = '\\';
+ term_dict[prefix_len++] = ord;
+ }
+ }
+ if (!prefix_len)
+ {
+ zi->errCode = 114;
+ return -1;
+ }
+ term_dict[prefix_len++] = ')';
+ term_dict[prefix_len] = '\0';
+ if (!relational_term (zi, zapt, term_sub, term_dict,
+ attributeSet, grep_info, &max_pos))
+ {
+ const char *cp;
+
+ j = prefix_len;
+ switch (truncation_value)
+ {
+ case -1: /* not specified */
+ case 100: /* do not truncate */
+ 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, 0, grep_handle);
+ if (r)
+ logf (LOG_WARN, "dict_lookup_grep err, trunc=none:%d", r);
+ break;
+ case 1: /* right truncation */
+ 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, 0, grep_handle);
+ break;
+ case 2: /* left truncation */
+ case 3: /* left&right truncation */
+ zi->errCode = 120;
+ return -1;
+ case 101: /* process # in term */
+ term_dict[j++] = '(';
+ for (i=0; term_sub[i]; i++)
+ if (term_sub[i] == '#' && i > 2)
+ {
+ term_dict[j++] = '.';
+ term_dict[j++] = '*';
+ }
+ else
+ 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, 0, grep_handle);
+ if (r)
+ logf (LOG_WARN, "dict_lookup_grep err, trunc=#: %d",
+ r);
+ break;
+ case 102: /* regular expression */
+ sprintf (term_dict + j, "(%s)", term_sub);
+ r = dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info,
+ &max_pos, 0, grep_handle);
+ if (r)
+ logf (LOG_WARN, "dict_lookup_grep err, trunc=regular: %d",
+ r);
+ break;
+ case 103: /* regular expression with error correction */
+ cp = term_sub;
+ r = 0;
+ if (*cp == '*' && cp[1] && cp[2])
+ {
+ r = atoi (cp+1);
+ cp += 2;
+ }
+ sprintf (term_dict + j, "(%s)", cp);
+ r = dict_lookup_grep (zi->wordDict, term_dict, r, grep_info,
+ &max_pos, j, grep_handle);
+ if (r)
+ logf (LOG_WARN, "dict_lookup_grep err, trunc=eregular: %d",
+ r);
+ break;
+ }
+ }
+#else
int max_pos;
#if 1
attent *attp;
return -1;
}
#endif
+#endif
}
logf (LOG_DEBUG, "%d positions", grep_info->isam_p_indx);
return 0;
}
static void trans_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt,
- char *termz)
+ int regType, 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;
+ if (sizez > IT_MAX_WORD-1)
+ sizez = IT_MAX_WORD-1;
+ termz[0] = regType;
for (i = 0; i < sizez; i++)
- termz[i] = index_char_cvt (term->u.general->buf[i]);
- termz[i] = '\0';
+ termz[i+1] = index_char_cvt (term->u.general->buf[i]);
+ termz[i+1] = '\0';
}
static RSET rpn_search_APT_relevance (ZServerInfo *zi,
zi->errCode = 124;
return NULL;
}
- trans_term (zi, zapt, termz);
+ trans_term (zi, zapt, 'w', termz);
+
grep_info.isam_p_indx = 0;
grep_info.isam_p_size = 0;
grep_info.isam_p_buf = NULL;
return result;
}
+static RSET rpn_search_APT_cphrase (ZServerInfo *zi,
+ Z_AttributesPlusTerm *zapt,
+ oid_value attributeSet,
+ int num_bases, char **basenames)
+{
+ rset_isam_parms parms;
+ char termz[IT_MAX_WORD+1];
+ struct grep_info grep_info;
+ RSET result;
+
+ if (zapt->term->which != Z_Term_general)
+ {
+ zi->errCode = 124;
+ return NULL;
+ }
+ trans_term (zi, zapt, 'p', termz);
+
+ grep_info.isam_p_indx = 0;
+ grep_info.isam_p_size = 0;
+ grep_info.isam_p_buf = NULL;
+
+ if (field_term (zi, zapt, termz, attributeSet, &grep_info,
+ num_bases, basenames))
+ return NULL;
+ if (grep_info.isam_p_indx < 1)
+ result = rset_create (rset_kind_null, NULL);
+ else if (grep_info.isam_p_indx == 1)
+ {
+ parms.is = zi->wordIsam;
+ parms.pos = *grep_info.isam_p_buf;
+ result = rset_create (rset_kind_isam, &parms);
+ }
+ else
+ result = rset_trunc (zi->wordIsam, grep_info.isam_p_buf,
+ grep_info.isam_p_indx);
+ xfree (grep_info.isam_p_buf);
+ return result;
+}
static RSET rpn_search_APT_word (ZServerInfo *zi,
Z_AttributesPlusTerm *zapt,
oid_value attributeSet,
zi->errCode = 124;
return NULL;
}
- trans_term (zi, zapt, termz);
+ trans_term (zi, zapt, 'w', termz);
grep_info.isam_p_indx = 0;
grep_info.isam_p_size = 0;
zi->errCode = 124;
return NULL;
}
- trans_term (zi, zapt, termz);
+ trans_term (zi, zapt, 'w', termz);
grep_info.isam_p_size = 0;
grep_info.isam_p_buf = NULL;
result = rset_create (rset_kind_temp, &parms);
rsfd = rset_open (result, RSETF_WRITE|RSETF_SORT_SYSNO);
- trans_term (zi, zapt, termz);
- key.sysno = atoi (termz);
+ trans_term (zi, zapt, 'w', termz);
+
+ key.sysno = atoi (termz+1);
if (key.sysno <= 0)
key.sysno = 1;
rset_write (result, rsfd, &key);
{
AttrType relation;
AttrType structure;
- int relation_value, structure_value;
+ AttrType completeness;
+ int relation_value, structure_value, completeness_value;
attr_init (&relation, zapt, 2);
attr_init (&structure, zapt, 4);
+ attr_init (&completeness, zapt, 6);
relation_value = attr_find (&relation, NULL);
structure_value = attr_find (&structure, NULL);
+ completeness_value = attr_find (&completeness, NULL);
switch (structure_value)
{
case -1:
if (relation_value == 102) /* relevance relation */
return rpn_search_APT_relevance (zi, zapt, attributeSet,
num_bases, basenames);
+ if (completeness_value == 2 || completeness_value == 3)
+ return rpn_search_APT_cphrase (zi, zapt, attributeSet,
+ num_bases, basenames);
return rpn_search_APT_phrase (zi, zapt, attributeSet,
num_bases, basenames);
case 1: /* phrase */
if (relation_value == 102) /* relevance relation */
return rpn_search_APT_relevance (zi, zapt, attributeSet,
num_bases, basenames);
+ if (completeness_value == 2 || completeness_value == 3)
+ return rpn_search_APT_cphrase (zi, zapt, attributeSet,
+ num_bases, basenames);
return rpn_search_APT_phrase (zi, zapt, attributeSet,
num_bases, basenames);
break;