-/* $Id: d1_absyn.c,v 1.19 2005-01-15 19:38:18 adam Exp $
+/* $Id: d1_absyn.c,v 1.20 2005-06-23 06:45:46 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
nmem_malloc(data1_nmem_get(dh), sizeof(**tp));
(*tp)->next = 0;
+#if NATTR
+ (*tp)->index_name = nmem_strdup(data1_nmem_get(dh), element_name);
+ if (*attname == '!' && xpelement)
+ (*tp)->index_name = 0;
+#else
if (!xpelement) {
if (*attname == '!')
strcpy(attname, element_name);
}
- if (!((*tp)->att = data1_getattbyname(dh, res->attset,
- attname))) {
+ if (!((*tp)->att = data1_getattbyname(dh, res->attset, attname)))
+ {
if ((!xpelement) || (*attname != '!')) {
yaz_log(YLOG_WARN,
"%s:%d: Couldn't find att '%s' in attset",
(*tp)->att = 0;
}
}
-
+#endif
if (r == 2 && (source = strchr(structure, ':')))
*source++ = '\0'; /* cut off structure .. */
else
}
else if (!strcmp(cmd, "attset"))
{
+#if NATTR
+ yaz_log(YLOG_WARN, "%s:%d: attset obsolete", file, lineno);
+#else
char *name;
data1_attset *attset;
(*attset_childp)->child = attset;
(*attset_childp)->next = 0;
attset_childp = &(*attset_childp)->next;
+#endif
}
else if (!strcmp(cmd, "tagset"))
{
-/* $Id: data1.h,v 1.9 2005-04-23 16:30:58 adam Exp $
+/* $Id: data1.h,v 1.10 2005-06-23 06:45:46 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
typedef struct data1_termlist
{
+#if NATTR
+ char *index_name;
+#else
data1_att *att;
+#endif
char *structure;
char *source;
struct data1_termlist *next;
-/* $Id: recctrl.h,v 1.11 2005-06-07 11:36:38 adam Exp $
+/* $Id: recctrl.h,v 1.12 2005-06-23 06:45:46 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
YAZ_BEGIN_CDECL
+#if NATTR
+#define ZEBRA_XPATH_ELM_BEGIN "_XPATH_BEGIN"
+#define ZEBRA_XPATH_ELM_END "_XPATH_END"
+#define ZEBRA_XPATH_CDATA "_XPATH_CDATA"
+#define ZEBRA_XPATH_ATTR "_XPATH_ATTR"
+#endif
+
/* single word entity */
typedef struct {
+#if NATTR
+#else
int attrSet;
int attrUse;
- unsigned reg_type;
- char *attrStr;
+#endif
+ unsigned index_type;
+ char *index_name;
char *term_buf;
int term_len;
zint seqno;
-/* $Id: util.h,v 1.3 2005-04-29 23:09:57 adam Exp $
+/* $Id: util.h,v 1.4 2005-06-23 06:45:46 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
#define CAST_ZINT_TO_INT(x) (int)(x)
#define CAST_ZINT_TO_DOUBLE(x) (double)(x)
+/* NATTR=1 for string-attribute architecture, =0 for set+use . */
+#define NATTR 0
+#define REG_TYPE_PREFIX 0
+
#endif
-/* $Id: extract.c,v 1.186 2005-06-14 20:28:54 adam Exp $
+/* $Id: extract.c,v 1.187 2005-06-23 06:45:46 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
{
w->zebra_maps = p->zebra_maps;
w->seqno = 1;
+#if NATTR
+#else
w->attrSet = VAL_BIB1;
w->attrUse = 1016;
- w->attrStr = 0;
- w->reg_type = 'w';
+#endif
+ w->index_name = 0;
+ w->index_type = 'w';
w->extractCtrl = p;
w->record_id = 0;
w->section_id = 0;
/* we are going to read from a file, so prepare the extraction */
create_rec_keys_codec(&zh->reg->keys);
-
+#if NATTR
+ create_rec_keys_codec(&zh->reg->sortKeys);
+#else
zh->reg->sortKeys.buf_used = 0;
-
+#endif
recordOffset = fi->file_moffset;
extractCtrl.handle = zh;
extractCtrl.offset = fi->file_moffset;
{
/* record already exists */
struct recKeys delkeys;
+#if NATTR
+ struct recKeys sortKeys;
+#else
struct sortKeys sortKeys;
+#endif
rec = rec_get (zh->reg->records, *sysno);
assert (rec);
extractCtrl.fh = &fc;
create_rec_keys_codec(&zh->reg->keys);
-
+#if NATTR
+ create_rec_keys_codec(&zh->reg->sortKeys);
+#else
zh->reg->sortKeys.buf_used = 0;
-
+#endif
if (zebraExplain_curDatabase (zh->reg->zei, zh->basenames[0]))
{
if (zebraExplain_newDatabase (zh->reg->zei, zh->basenames[0],
{
/* record already exists */
struct recKeys delkeys;
+#if NATTR
+ struct recKeys sortKeys;
+#else
struct sortKeys sortKeys;
+#endif
if (!allow_update)
{
}
create_rec_keys_codec(&zh->reg->keys);
-
+#if NATTR
+ create_rec_keys_codec(&zh->reg->sortKeys);
+#else
zh->reg->sortKeys.buf_used = 0;
-
+#endif
extractCtrl.init = extract_init;
extractCtrl.tokenAdd = extract_token_add;
extractCtrl.schemaAdd = extract_schema_add;
if (rec->size[recInfo_delKeys])
{
struct recKeys delkeys;
+#if NATTR
+ struct recKeys sortkeys;
+#else
struct sortKeys sortkeys;
+#endif
delkeys.buf_used = rec->size[recInfo_delKeys];
delkeys.buf = rec->info[recInfo_delKeys];
}
void extract_add_it_key (ZebraHandle zh,
+ struct recKeys *keys,
int reg_type,
const char *str, int slen, struct it_key *key)
{
char *dst;
- struct recKeys *keys = &zh->reg->keys;
const char *src = (char*) key;
if (keys->buf_used+1024 > keys->buf_max)
iscz1_encode(keys->codec_handle, &dst, &src);
+#if REG_TYPE_PREFIX
*dst++ = reg_type;
+#endif
memcpy (dst, str, slen);
dst += slen;
*dst++ = '\0';
ZebraExplainInfo zei = zh->reg->zei;
int ch;
- if (p->attrStr)
+ if (p->index_name)
{
- ch = zebraExplain_lookup_attr_str(zei, p->attrStr);
+ ch = zebraExplain_lookup_attr_str(zei, p->index_type, p->index_name);
if (ch < 0)
- ch = zebraExplain_add_attr_str(zei, p->attrStr);
+ ch = zebraExplain_add_attr_str(zei, p->index_type, p->index_name);
}
else
{
- ch = zebraExplain_lookup_attr_su(zei, p->attrSet, p->attrUse);
+#if NATTR
+ return;
+#else
+ ch = zebraExplain_lookup_attr_su(zei, p->index_type,
+ p->attrSet, p->attrUse);
if (ch < 0)
- ch = zebraExplain_add_attr_su(zei, p->attrSet, p->attrUse);
+ ch = zebraExplain_add_attr_su(zei, p->index_type,
+ p->attrSet, p->attrUse);
+#endif
}
key.len = 4;
key.mem[0] = ch;
p->attrSet, p->attrUse, p->record_id, p->section_id, p->seqno);
#endif
- extract_add_it_key(p->extractCtrl->handle, p->reg_type, str,
+ extract_add_it_key(p->extractCtrl->handle,
+ &zh->reg->keys,
+ p->index_type, str,
length, &key);
}
-static void extract_add_sort_string (RecWord *p, const char *str,
- int length)
+#if NATTR
+static void extract_add_sort_string (RecWord *p, const char *str, int length)
+{
+ struct it_key key;
+
+ ZebraHandle zh = p->extractCtrl->handle;
+ ZebraExplainInfo zei = zh->reg->zei;
+ int ch;
+
+ if (p->index_name)
+ {
+ ch = zebraExplain_lookup_attr_str(zei, p->index_type, p->index_name);
+ if (ch < 0)
+ ch = zebraExplain_add_attr_str(zei, p->index_type, p->index_name);
+ }
+ else
+ {
+ return;
+ }
+ key.len = 4;
+ key.mem[0] = ch;
+ key.mem[1] = p->record_id;
+ key.mem[2] = p->section_id;
+ key.mem[3] = p->seqno;
+
+ extract_add_it_key(p->extractCtrl->handle,
+ &zh->reg->sortKeys,
+ p->index_type, str,
+ length, &key);
+}
+#else
+static void extract_add_sort_string (RecWord *p, const char *str, int length)
{
ZebraHandle zh = p->extractCtrl->handle;
struct sortKeys *sk = &zh->reg->sortKeys;
memcpy (sk->buf + off, str, length);
sk->buf_used = off + length;
}
+#endif
void extract_add_string (RecWord *p, const char *string, int length)
{
assert (length > 0);
- if (zebra_maps_is_sort (p->zebra_maps, p->reg_type))
+ if (zebra_maps_is_sort (p->zebra_maps, p->index_type))
extract_add_sort_string (p, string, length);
else
extract_add_index_string (p, string, length);
yaz_log(YLOG_DEBUG, "Incomplete field, w='%.*s'", p->term_len, p->term_buf);
if (remain > 0)
- map = zebra_maps_input(p->zebra_maps, p->reg_type, &b, remain, 0);
+ map = zebra_maps_input(p->zebra_maps, p->index_type, &b, remain, 0);
while (map)
{
{
remain = p->term_len - (b - p->term_buf);
if (remain > 0)
- map = zebra_maps_input(p->zebra_maps, p->reg_type, &b, remain, 0);
+ map = zebra_maps_input(p->zebra_maps, p->index_type, &b,
+ remain, 0);
else
map = 0;
}
buf[i++] = *(cp++);
remain = p->term_len - (b - p->term_buf);
if (remain > 0)
- map = zebra_maps_input(p->zebra_maps, p->reg_type, &b, remain, 0);
+ map = zebra_maps_input(p->zebra_maps, p->index_type, &b, remain, 0);
else
map = 0;
}
p->term_len, p->term_buf);
if (remain > 0)
- map = zebra_maps_input (p->zebra_maps, p->reg_type, &b, remain, 1);
+ map = zebra_maps_input (p->zebra_maps, p->index_type, &b, remain, 1);
while (remain > 0 && i < IT_MAX_WORD)
{
if (remain > 0)
{
int first = i ? 0 : 1; /* first position */
- map = zebra_maps_input(p->zebra_maps, p->reg_type, &b, remain, first);
+ map = zebra_maps_input(p->zebra_maps, p->index_type, &b, remain, first);
}
else
map = 0;
remain = p->term_len - (b - p->term_buf);
if (remain > 0)
{
- map = zebra_maps_input (p->zebra_maps, p->reg_type, &b,
+ map = zebra_maps_input (p->zebra_maps, p->index_type, &b,
remain, 0);
}
else
p->reg_type, p->attrSet, p->attrUse, p->seqno, p->length,
p->string);
#endif
- if ((wrbuf = zebra_replace(p->zebra_maps, p->reg_type, 0,
+ if ((wrbuf = zebra_replace(p->zebra_maps, p->index_type, 0,
p->term_buf, p->term_len)))
{
p->term_buf = wrbuf_buf(wrbuf);
p->term_len = wrbuf_len(wrbuf);
}
- if (zebra_maps_is_complete (p->zebra_maps, p->reg_type))
+ if (zebra_maps_is_complete (p->zebra_maps, p->index_type))
extract_add_complete_field (p);
else
extract_add_incomplete_field(p);
zebraExplain_addSchema (zh->reg->zei, oid);
}
+#if NATTR
+void extract_flushSortKeys (ZebraHandle zh, SYSNO sysno,
+ int cmd, struct recKeys *reckeys)
+{
+ SortIdx sortIdx = zh->reg->sortIdx;
+ void *decode_handle = iscz1_start();
+ int off = 0;
+ int ch = 0;
+
+ while (off < reckeys->buf_used)
+ {
+ const char *src = reckeys->buf + off;
+ struct it_key key;
+ char *dst = (char*) &key;
+
+ iscz1_decode(decode_handle, &dst, &src);
+ assert(key.len == 4);
+
+ ch = (int) key.mem[0]; /* ordinal for field/use/attribute */
+
+ sortIdx_type(sortIdx, ch);
+ if (cmd == 1)
+ sortIdx_add(sortIdx, src, strlen(src));
+ else
+ sortIdx_add(sortIdx, "", 1);
+
+ src += strlen(src);
+ src++;
+
+ off = src - reckeys->buf;
+ }
+ assert (off == reckeys->buf_used);
+ iscz1_stop(decode_handle);
+}
+#else
void extract_flushSortKeys (ZebraHandle zh, SYSNO sysno,
int cmd, struct sortKeys *sk)
{
off += slen;
}
}
+#endif
void encode_key_init (struct encode_info *i)
{
-/* $Id: index.h,v 1.144 2005-06-22 19:42:38 adam Exp $
+/* $Id: index.h,v 1.145 2005-06-23 06:45:46 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
void *codec_handle;
};
+#if NATTR
+
+#else
struct sortKeys {
int buf_used;
int buf_max;
char *buf;
};
+#endif
struct zebra_register {
char *name;
int active; /* 0=shutdown, 1=enabled and inactive, 2=activated */
struct recKeys keys;
-#if 1
- struct sortKeys sortKeys;
+#if NATTR
+ struct recKeys sortKeys;
#else
- struct sortKey *sortKeys;
+ struct sortKeys sortKeys;
#endif
char **key_buf;
size_t ptr_top;
void extract_flushRecordKeys (ZebraHandle zh, SYSNO sysno,
int cmd, struct recKeys *reckeys);
+#if NATTR
+void extract_flushSortKeys (ZebraHandle zh, SYSNO sysno,
+ int cmd, struct recKeys *skp);
+#else
void extract_flushSortKeys (ZebraHandle zh, SYSNO sysno,
int cmd, struct sortKeys *skp);
+#endif
void extract_schema_add (struct recExtractCtrl *p, Odr_oid *oid);
void extract_token_add (RecWord *p);
int explain_extract (void *handle, Record rec, data1_node *n);
-/* $Id: zebraapi.c,v 1.178 2005-06-14 20:28:54 adam Exp $
+/* $Id: zebraapi.c,v 1.179 2005-06-23 06:45:46 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
reg->sortKeys.buf = 0;
reg->sortKeys.buf_max = 0;
+#if NATTR
+ reg->sortKeys.codec_handle = iscz1_start();
+#endif
reg->records = 0;
reg->dict = 0;
xfree(reg->keys.buf);
if (reg->keys.codec_handle)
iscz1_stop(reg->keys.codec_handle);
+#if NATTR
+ if (reg->sortKeys.codec_handle)
+ iscz1_stop(reg->sortKeys.codec_handle);
+#endif
xfree(reg->key_buf);
xfree(reg->name);
xfree(reg);
-/* $Id: zinfo.c,v 1.45 2005-03-05 09:19:14 adam Exp $
+/* $Id: zinfo.c,v 1.46 2005-06-23 06:45:46 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
#define ZINFO_DEBUG 0
struct zebSUInfo {
+ int index_type;
#define ZEB_SU_SET_USE 1
#define ZEB_SU_STR 2
int which;
data1_node *node_use = NULL;
data1_node *node_str = NULL;
data1_node *node_ordinal = NULL;
+ data1_node *node_type = NULL;
data1_node *np2;
char oid_str[128];
int oid_str_len;
node_str = np2->child;
else if (!strcmp (np2->u.tag.tag, "ordinal"))
node_ordinal = np2->child;
+ else if (!strcmp (np2->u.tag.tag, "type"))
+ node_type = np2->child;
}
assert (node_ordinal);
*zsuip = (struct zebSUInfoB *)
nmem_malloc (zei->nmem, sizeof(**zsuip));
+
+ if (node_type && node_type->u.data.len > 0)
+ (*zsuip)->info.index_type = node_type->u.data.data[0];
+ else
+ {
+ yaz_log(YLOG_WARN, "Missing attribute 'type' in attribute info");
+ (*zsuip)->info.index_type = 'w';
+ }
+
if (node_set && node_use)
{
(*zsuip)->info.which = ZEB_SU_SET_USE;
}
else
{
- yaz_log(YLOG_WARN, "Missng set/use/str in attribute info");
+ yaz_log(YLOG_WARN, "Missing set/use/str in attribute info");
continue;
}
(*zsuip)->info.ordinal = atoi_n (node_ordinal->u.data.data,
struct oident oident;
int oid[OID_SIZE];
data1_node *node_attr;
+ char index_type_str[2];
+
node_attr = data1_mk_tag (zei->dh, zei->nmem, "attr", 0 /* attr */,
node_list);
+
+ index_type_str[0] = zsui->info.index_type;
+ index_type_str[1] = '\0';
+ data1_mk_tag_data_text (zei->dh, node_attr, "type",
+ index_type_str, zei->nmem);
if (zsui->info.which == ZEB_SU_SET_USE)
{
oident.proto = PROTO_Z3950;
rec_put (zei->records, &trec);
}
-int zebraExplain_lookup_attr_su(ZebraExplainInfo zei, int set, int use)
+int zebraExplain_lookup_attr_su(ZebraExplainInfo zei, int index_type,
+ int set, int use)
{
struct zebSUInfoB *zsui;
assert (zei->curDatabaseInfo);
for (zsui = zei->curDatabaseInfo->attributeDetails->SUInfo;
zsui; zsui=zsui->next)
- if (zsui->info.which == ZEB_SU_SET_USE &&
+ if (zsui->info.index_type == index_type &&
+ zsui->info.which == ZEB_SU_SET_USE &&
zsui->info.u.su.use == use && zsui->info.u.su.set == set)
return zsui->info.ordinal;
return -1;
}
-int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, const char *str)
+int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, int index_type,
+ const char *str)
{
struct zebSUInfoB *zsui;
assert (zei->curDatabaseInfo);
for (zsui = zei->curDatabaseInfo->attributeDetails->SUInfo;
zsui; zsui=zsui->next)
- if (zsui->info.which == ZEB_SU_STR &&
- !strcmp(zsui->info.u.str, str))
+ if (zsui->info.index_type == index_type &&
+ zsui->info.which == ZEB_SU_STR && !strcmp(zsui->info.u.str, str))
return zsui->info.ordinal;
return -1;
}
}
}
-int zebraExplain_add_attr_su(ZebraExplainInfo zei, int set, int use)
+int zebraExplain_add_attr_su(ZebraExplainInfo zei, int index_type,
+ int set, int use)
{
struct zebSUInfoB *zsui;
zei->curDatabaseInfo->attributeDetails->SUInfo = zsui;
zei->curDatabaseInfo->attributeDetails->dirty = 1;
zei->dirty = 1;
+ zsui->info.index_type = index_type;
zsui->info.which = ZEB_SU_SET_USE;
zsui->info.u.su.set = set;
zsui->info.u.su.use = use;
return zsui->info.ordinal;
}
-int zebraExplain_add_attr_str(ZebraExplainInfo zei, const char *str)
+int zebraExplain_add_attr_str(ZebraExplainInfo zei, int index_type,
+ const char *index_name)
{
struct zebSUInfoB *zsui;
zei->curDatabaseInfo->attributeDetails->SUInfo = zsui;
zei->curDatabaseInfo->attributeDetails->dirty = 1;
zei->dirty = 1;
+ zsui->info.index_type = index_type;
zsui->info.which = ZEB_SU_STR;
- zsui->info.u.str = nmem_strdup(zei->nmem, str);
+ zsui->info.u.str = nmem_strdup(zei->nmem, index_name);
zsui->info.ordinal = (zei->ordinalSU)++;
return zsui->info.ordinal;
}
-/* $Id: zinfo.h,v 1.23 2005-03-08 14:02:12 adam Exp $
+/* $Id: zinfo.h,v 1.24 2005-06-23 06:45:46 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int zebraExplain_curDatabase (ZebraExplainInfo zei, const char *database);
int zebraExplain_newDatabase (ZebraExplainInfo zei, const char *database,
int explain_database);
-int zebraExplain_lookup_attr_su(ZebraExplainInfo zei, int set, int use);
-int zebraExplain_add_attr_su(ZebraExplainInfo zei, int set, int use);
-int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, const char *str);
-int zebraExplain_add_attr_str(ZebraExplainInfo zei, const char *str);
+int zebraExplain_lookup_attr_su(ZebraExplainInfo zei, int index_type,
+ int set, int use);
+int zebraExplain_add_attr_su(ZebraExplainInfo zei, int index_type,
+ int set, int use);
+int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, int index_type,
+ const char *str);
+int zebraExplain_add_attr_str(ZebraExplainInfo zei, int index_type,
+ const char *str);
void zebraExplain_addSchema (ZebraExplainInfo zei, Odr_oid *oid);
void zebraExplain_recordCountIncrement (ZebraExplainInfo zei, int adjust_num);
void zebraExplain_recordBytesIncrement (ZebraExplainInfo zei, int adjust_num);
-/* $Id: zrpn.c,v 1.201 2005-06-22 19:42:38 adam Exp $
+/* $Id: zrpn.c,v 1.202 2005-06-23 06:45:46 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
return ZEBRA_OK;
}
-static char *nmem_strdup_i(NMEM nmem, int v)
-{
- char val_str[64];
- sprintf(val_str, "%d", v);
- return nmem_strdup(nmem, val_str);
-}
-
static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
const char **term_sub,
oid_value attributeSet, NMEM stream,
int space_split = complete_flag ? 0 : 1;
int bases_ok = 0; /* no of databases with OK attribute */
- int errCode = 0; /* err code (if any is not OK) */
- char *errString = 0; /* addinfo */
-
*ol = ord_list_create(stream);
}
else if (use_string &&
(ord = zebraExplain_lookup_attr_str(zh->reg->zei,
+ reg_type,
use_string)) >= 0)
{
/* we have a match for a raw string attribute */
if (r == -1)
{
/* set was found, but value wasn't defined */
- errCode = YAZ_BIB1_UNSUPP_USE_ATTRIBUTE;
if (use_string)
- errString = nmem_strdup(stream, use_string);
+ zebra_setError(zh,
+ YAZ_BIB1_UNSUPP_USE_ATTRIBUTE,
+ use_string);
else
- errString = nmem_strdup_i (stream, use_value);
+ zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE,
+ use_value);
}
else
{
oident.value = curAttributeSet;
oid_ent_to_oid (&oident, oid);
- errCode = YAZ_BIB1_UNSUPP_ATTRIBUTE_SET;
- errString = nmem_strdup(stream, oident.desc);
+ zebra_setError(zh,
+ YAZ_BIB1_UNSUPP_ATTRIBUTE_SET,
+ oident.desc);
+
}
continue;
}
int i, ord_len;
ord = zebraExplain_lookup_attr_su(zh->reg->zei,
+ reg_type,
attp.attset_ordinal,
local_attr->local);
if (ord < 0)
attr_ok = 1;
term_dict[prefix_len++] = ')';
+#if REG_TYPE_PREFIX
term_dict[prefix_len++] = 1;
term_dict[prefix_len++] = reg_type;
yaz_log(log_level_rpn, "reg_type = %d", term_dict[prefix_len-1]);
+#endif
term_dict[prefix_len] = '\0';
j = prefix_len;
switch (truncation_value)
}
}
if (!bases_ok)
- {
- zebra_setError(zh, errCode, errString);
return ZEBRA_FAIL;
- }
*term_sub = termp;
yaz_log(YLOG_DEBUG, "%d positions", grep_info->isam_p_indx);
return ZEBRA_OK;
struct rpn_char_map_info rcmi;
int bases_ok = 0; /* no of databases with OK attribute */
- int errCode = 0; /* err code (if any is not OK) */
- char *errString = 0; /* addinfo */
rpn_char_map_prepare (zh->reg, reg_type, &rcmi);
attr_init(&use, zapt, 1);
else
{
if ((r = att_getentbyatt (zh, &attp, curAttributeSet, use_value,
- use_string)))
+ use_string)))
{
yaz_log(YLOG_DEBUG, "att_getentbyatt fail. set=%d use=%d r=%d",
curAttributeSet, use_value, r);
if (r == -1)
{
- errCode = YAZ_BIB1_UNSUPP_USE_ATTRIBUTE;
if (use_string)
- errString = nmem_strdup(stream, use_string);
+ zebra_setError(zh,
+ YAZ_BIB1_UNSUPP_USE_ATTRIBUTE,
+ use_string);
else
- errString = nmem_strdup_i (stream, use_value);
+ zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_USE_ATTRIBUTE,
+ use_value);
}
else
- errCode = YAZ_BIB1_UNSUPP_ATTRIBUTE_SET;
+ zebra_setError(zh, YAZ_BIB1_UNSUPP_ATTRIBUTE_SET, 0);
continue;
}
}
int i, ord_len;
ord = zebraExplain_lookup_attr_su(zh->reg->zei,
+ reg_type,
attp.attset_ordinal,
local_attr->local);
if (ord < 0)
continue;
}
bases_ok++;
- term_dict[prefix_len++] = ')';
+ term_dict[prefix_len++] = ')';
+#if REG_TYPE_PREFIX
term_dict[prefix_len++] = 1;
term_dict[prefix_len++] = reg_type;
yaz_log(YLOG_DEBUG, "reg_type = %d", term_dict[prefix_len-1]);
+#endif
term_dict[prefix_len] = '\0';
if (!numeric_relation(zh, zapt, &termp, term_dict,
attributeSet, grep_info, &max_pos, reg_type,
}
}
if (!bases_ok)
- {
- zebra_setError(zh, errCode, errString);
return ZEBRA_FAIL;
- }
*term_sub = termp;
yaz_log(YLOG_DEBUG, "%d positions", grep_info->isam_p_indx);
return ZEBRA_OK;
char term_dict[2048];
char ord_buf[32];
int prefix_len = 0;
- int ord = zebraExplain_lookup_attr_su(zh->reg->zei, curAttributeSet, use);
+ int ord = zebraExplain_lookup_attr_su(zh->reg->zei, reg_type,
+ curAttributeSet, use);
int ord_len, i, r, max_pos;
int term_type = Z_Term_characterString;
const char *flags = "void";
term_dict[prefix_len++] = ord_buf[i];
}
term_dict[prefix_len++] = ')';
+#if REG_TYPE_PREFIX
term_dict[prefix_len++] = 1;
term_dict[prefix_len++] = reg_type;
-
+#endif
strcpy(term_dict+prefix_len, term);
grep_info.isam_p_indx = 0;
}
if (use_string &&
- (ord = zebraExplain_lookup_attr_str(zh->reg->zei,
+ (ord = zebraExplain_lookup_attr_str(zh->reg->zei, reg_id,
use_string)) >= 0)
{
/* we have a match for a raw string attribute */
for (local_attr = attp.local_attributes; local_attr && ord_no < 32;
local_attr = local_attr->next)
{
- ord = zebraExplain_lookup_attr_su(zh->reg->zei,
+ ord = zebraExplain_lookup_attr_su(zh->reg->zei, reg_id,
attp.attset_ordinal,
local_attr->local);
if (ord > 0)
scan_info->list[j].term = NULL;
prefix_len += key_SU_encode (ords[i], termz + prefix_len);
+#if REG_TYPE_PREFIX
termz[prefix_len++] = reg_id;
+#endif
termz[prefix_len] = 0;
strcpy(scan_info->prefix, termz);
-/* $Id: alvis.c,v 1.2 2005-04-28 08:20:40 adam Exp $
+/* $Id: alvis.c,v 1.3 2005-06-23 06:45:47 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
xfree(tinfo->sep);
tinfo->sep = 0;
(*p->init)(p, &recWord);
- recWord.reg_type = 'w';
do
{
int i = 0;
-/* $Id: recgrs.c,v 1.101 2005-04-29 23:09:30 adam Exp $
+/* $Id: recgrs.c,v 1.102 2005-06-23 06:45:47 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
char *structure, struct recExtractCtrl *p,
RecWord *wrd)
{
+#if NATTR
+ wrd->index_name = ZEBRA_XPATH_ELM_BEGIN;
+#else
wrd->attrSet = VAL_IDXPATH;
wrd->attrUse = 1;
- wrd->reg_type = '0';
+#endif
+ wrd->index_type = '0';
wrd->term_buf = tag_path;
wrd->term_len = strlen(tag_path);
(*p->tokenAdd)(wrd);
if (value) {
+#if NATTR
+ wrd->index_name = ZEBRA_XPATH_ATTR;
+#else
wrd->attrUse = 1015;
- wrd->reg_type = 'w';
+#endif
+ wrd->index_type = 'w';
wrd->term_buf = value;
wrd->term_len = strlen(value);
(*p->tokenAdd)(wrd);
}
-
+#if NATTR
+ wrd->index_name = ZEBRA_XPATH_ELM_END;
+#else
wrd->attrUse = 2;
- wrd->reg_type = '0';
+#endif
+ wrd->index_type = '0';
wrd->term_buf = tag_path;
wrd->term_len = strlen(tag_path);
(*p->tokenAdd)(wrd);
}
-static void index_xpath (struct source_parser *sp, data1_node *n,
- struct recExtractCtrl *p,
- int level, RecWord *wrd, int use)
+static void index_xpath(struct source_parser *sp, data1_node *n,
+ struct recExtractCtrl *p,
+ int level, RecWord *wrd,
+#if NATTR
+ char *xpath_index,
+ int xpath_is_start
+#else
+ int use
+#endif
+ )
{
int i;
char tag_path_full[1024];
int termlist_only = 1;
data1_termlist *tl;
int xpdone = 0;
+#if NATTR
+#else
+ int xpath_is_start = 0;
+ if (use == 1)
+ xpath_is_start = 1;
+#endif
+#if NATTR
+ yaz_log(YLOG_DEBUG, "index_xpath level=%d xpath_index=%s",
+ level, xpath_index);
+#else
yaz_log(YLOG_DEBUG, "index_xpath level=%d use=%d", level, use);
+#endif
if ((!n->root->u.root.absyn) ||
(n->root->u.root.absyn->enable_xpath_indexing)) {
termlist_only = 0;
{
/* need to copy recword because it may be changed */
RecWord wrd_tl;
- wrd->reg_type = *tl->structure;
- /* this is the ! case, so structure is for the xpath index */
+ wrd->index_type = *tl->structure;
memcpy (&wrd_tl, wrd, sizeof(*wrd));
if (tl->source)
sp_parse(sp, n, &wrd_tl, tl->source);
- if (!tl->att) {
+#if NATTR
+ if (!tl->index_name)
+#else
+ if (!tl->att)
+#endif
+ {
+ /* this is the ! case, so structure is for the xpath index */
+#if NATTR
+ wrd_tl.index_name = xpath_index;
+#else
wrd_tl.attrSet = VAL_IDXPATH;
wrd_tl.attrUse = use;
+#endif
if (p->flagShowRecords)
{
int i;
xpdone = 1;
} else {
/* this is just the old fashioned attribute based index */
+#if NATTR
+ wrd_tl.index_name = tl->index_name;
+#else
wrd_tl.attrSet = (int) (tl->att->parent->reference);
wrd_tl.attrUse = tl->att->locals->local;
+#endif
if (p->flagShowRecords)
{
int i;
printf("%*sIdx: [%s]", (level + 1) * 4, "",
tl->structure);
+#if NATTR
+ printf("%s %s", tl->index_name, tl->source);
+#else
printf("%s:%s [%d] %s",
tl->att->parent->name,
tl->att->name, tl->att->value,
tl->source);
+#endif
printf (" XData:\"");
for (i = 0; i<wrd_tl.term_len && i < 40; i++)
fputc (wrd_tl.term_buf[i], stdout);
or no ! in the termlist, and default indexing is enabled... */
if (!p->flagShowRecords && !xpdone && !termlist_only)
{
+#if NATTR
+ wrd->index_name = xpath_index;
+#else
wrd->attrSet = VAL_IDXPATH;
wrd->attrUse = use;
- wrd->reg_type = 'w';
+#endif
+ wrd->index_type = 'w';
(*p->tokenAdd)(wrd);
}
break;
}
- wrd->reg_type = '0';
+ wrd->index_type = '0';
wrd->term_buf = tag_path_full;
wrd->term_len = flen;
+#if NATTR
+ wrd->index_name = xpath_index;
+#else
wrd->attrSet = VAL_IDXPATH;
wrd->attrUse = use;
+#endif
if (p->flagShowRecords)
{
printf("%*s tag=", (level + 1) * 4, "");
tag_path_full[flen] = 0;
- /* Add tag start/end xpath index, only when there is a ! in the apropriate xelm
- directive, or default xpath indexing is enabled */
- if (!(do_xpindex = 1 - termlist_only)) {
- if ((tl = xpath_termlist_by_tagpath(tag_path_full, n))) {
- for (; tl; tl = tl->next) { if (!tl->att) {do_xpindex = 1;} }
+ /* Add tag start/end xpath index, only when there is a ! in
+ the apropriate xelm directive, or default xpath indexing
+ is enabled
+ */
+ if (!(do_xpindex = 1 - termlist_only))
+ {
+ if ((tl = xpath_termlist_by_tagpath(tag_path_full, n)))
+ {
+ for (; tl; tl = tl->next)
+ {
+#if NATTR
+ if (!tl->index_name)
+#else
+ if (!tl->att)
+#endif
+ do_xpindex = 1;
+ }
}
}
if (do_xpindex) {
(*p->tokenAdd)(wrd); /* index element pag (AKA tag path) */
}
- if (use == 1) /* only for the starting tag... */
+ if (xpath_is_start == 1) /* only for the starting tag... */
{
#define MAX_ATTR_COUNT 50
data1_termlist *tll[MAX_ATTR_COUNT];
if ((tl = tll[i]))
{
for (; tl; tl = tl->next)
- {
+ {
+#if NATTR
+ if (!tl->index_name)
+ do_xpindex = 1;
+#else
if (!tl->att)
do_xpindex = 1;
+#endif
}
}
if (do_xpindex) {
/* attribute (no value) */
- wrd->reg_type = '0';
+ wrd->index_type = '0';
+#if NATTR
+ wrd->index_name = ZEBRA_XPATH_ATTR;
+#else
wrd->attrUse = 3;
+#endif
wrd->term_buf = xp->name;
wrd->term_len = strlen(xp->name);
strcpy (comb, xp->name);
strcat (comb, "=");
strcat (comb, xp->value);
-
+
+#if NATTR
+ wrd->index_name = ZEBRA_XPATH_ATTR;
+#else
wrd->attrUse = 3;
- wrd->reg_type = '0';
+#endif
+ wrd->index_type = '0';
wrd->term_buf = comb;
wrd->term_len = strlen(comb);
wrd->seqno--;
/* If there is a termlist given (=xelm directive) */
for (; tl; tl = tl->next)
{
- if (!tl->att) {
+#if NATTR
+ if (!tl->index_name)
+#else
+ if (!tl->att)
+#endif
+ {
/* add xpath index for the attribute */
index_xpath_attr (attr_tag_path_full, xp->name,
xp->value, tl->structure,
xpdone = 1;
} else {
/* add attribute based index for the attribute */
- if (xp->value) {
+ if (xp->value)
+ {
+#if NATTR
+ wrd->index_name = tl->index_name;
+#else
wrd->attrSet = (int)
(tl->att->parent->reference);
wrd->attrUse = tl->att->locals->local;
- wrd->reg_type = *tl->structure;
+#endif
+ wrd->index_type = *tl->structure;
wrd->term_buf = xp->value;
wrd->term_len = strlen(xp->value);
(*p->tokenAdd)(wrd);
int i;
printf("%*sIdx: [%s]", (level + 1) * 4, "",
tlist->structure);
+#if NATTR
+ printf("%s %s", tlist->index_name, tlist->source);
+#else
printf("%s:%s [%d] %s",
tlist->att->parent->name,
tlist->att->name, tlist->att->value,
tlist->source);
+#endif
printf (" XData:\"");
for (i = 0; i<wrd->term_len && i < 40; i++)
fputc (wrd->term_buf[i], stdout);
}
else
{
- wrd->reg_type = *tlist->structure;
+ wrd->index_type = *tlist->structure;
+#if NATTR
+ wrd->index_name = tlist->index_name;
+#else
wrd->attrSet = (int) (tlist->att->parent->reference);
wrd->attrUse = tlist->att->locals->local;
+#endif
(*p->tokenAdd)(wrd);
}
}
{
index_termlist(sp, n, n, p, level, wrd);
/* index start tag */
+#if NATTR
+ if (n->root->u.root.absyn)
+ index_xpath(sp, n, p, level, wrd, ZEBRA_XPATH_ELM_BEGIN,
+ 1 /* is start */);
+#else
if (n->root->u.root.absyn)
index_xpath(sp, n, p, level, wrd, 1);
+#endif
}
if (n->child)
if (par)
index_termlist(sp, par, n, p, level, wrd);
+#if NATTR
+ index_xpath(sp, n, p, level, wrd, ZEBRA_XPATH_CDATA,
+ 0 /* is start */);
+#else
index_xpath(sp, n, p, level, wrd, 1016);
+#endif
}
if (n->which == DATA1N_tag)
{
/* index end tag */
+#if NATTR
+ index_xpath(sp, n, p, level, wrd, ZEBRA_XPATH_ELM_END,
+ 0 /* is start */);
+#else
index_xpath(sp, n, p, level, wrd, 2);
+#endif
}
if (p->flagShowRecords && n->which == DATA1N_root)
-/* $Id: rectext.c,v 1.28 2005-06-14 20:27:33 adam Exp $
+/* $Id: rectext.c,v 1.29 2005-06-23 06:45:47 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
static void filter_config(void *clientData, Res res, const char *args)
{
- struct filter_info *tinfo = (struct marc_info*) clientData;
+ struct filter_info *tinfo = (struct filter_info*) clientData;
xfree(tinfo->sep);
tinfo->sep = 0;
if (args && *args)
(long) (*fi->p->tellf)(fi->p->fh));
#endif
(*p->init)(p, &recWord);
- recWord.reg_type = 'w';
do
{
int i = 0;
-/* $Id: safari.c,v 1.7 2005-03-31 12:42:07 adam Exp $
+/* $Id: safari.c,v 1.8 2005-06-23 06:45:47 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
return RECCTRL_EXTRACT_ERROR_GENERIC;
sscanf(line, "%255s", p->match_criteria);
- recWord.reg_type = 'w';
+ recWord.index_type = 'w';
while (fi_gets(fi, line, sizeof(line)-1))
{
int nor = 0;
}
for (cp = line + nor; *cp == ' '; cp++)
;
- recWord.attrStr = field;
+ recWord.index_name = field;
recWord.term_buf = cp;
recWord.term_len = strlen(cp);
(*p->tokenAdd)(&recWord);
-/* $Id: xslt.c,v 1.10 2005-06-15 15:30:05 adam Exp $
+/* $Id: xslt.c,v 1.11 2005-06-23 06:45:47 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
if (!strcmp(ptr->name, "index"))
{
char *name_str = 0;
+ const char *type_str = 0;
const char *xpath_str = 0;
struct _xmlAttr *attr;
for (attr = ptr->properties; attr; attr = attr->next)
if (!strcmp(attr->name, "xpath")
&& attr->children && attr->children->type == XML_TEXT_NODE)
xpath_str = attr->children->content;
+ if (!strcmp(attr->name, "type")
+ && attr->children && attr->children->type == XML_TEXT_NODE)
+ type_str = attr->children->content;
}
if (name_str)
{
- recWord->attrStr = name_str;
+ int prev_type = recWord->index_type; /* save default type */
+
+ if (type_str && *type_str)
+ recWord->index_type = *type_str; /* type was given */
+ recWord->index_name = name_str;
index_cdata(tinfo, ctrl, ptr->children, recWord);
+
+ recWord->index_type = prev_type; /* restore it again */
}
}
}
set_param_str(params, "schema", zebra_xslt_ns, tinfo->odr);
(*p->init)(p, &recWord);
- recWord.reg_type = 'w';
if (schema && schema->stylesheet_xsp)
{
-/* $Id: t5.c,v 1.12 2005-04-15 10:47:49 adam Exp $
+/* $Id: t5.c,v 1.13 2005-06-23 06:45:47 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
/* provoke unsupported relation */
do_query_x(__LINE__, zh, "@attr 1=1016 @attr 2=6 x", 0, 117);
- do_query_x(__LINE__, zh, "@attr 1=1016 @attr 2=6 @attr 4=109 x", 0, 117);
+ do_query_x(__LINE__, zh, "@attr 1=1016 @attr 2=6 @attr 4=109 x", 0, 114);
return close_down(zh, zs, 0);
}