-/* $Id: recctrl.h,v 1.7 2005-01-16 23:13:06 adam Exp $
+/* $Id: recctrl.h,v 1.8 2005-03-05 09:19:14 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
int attrSet;
int attrUse;
unsigned reg_type;
- char *string;
- int length;
+ char *attrStr;
+ char *term_buf;
+ int term_len;
zint seqno;
zint record_id;
zint section_id;
-/* $Id: extract.c,v 1.171 2005-01-15 19:38:25 adam Exp $
+/* $Id: extract.c,v 1.172 2005-03-05 09:19:14 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
w->seqno = 1;
w->attrSet = VAL_BIB1;
w->attrUse = 1016;
+ w->attrStr = 0;
w->reg_type = 'w';
w->extractCtrl = p;
w->record_id = 0;
const char *src = reckeys->buf + off;
struct it_key key;
char *dst = (char*) &key;
- int attrSet, attrUse;
iscz1_decode(decode_handle, &dst, &src);
assert(key.len == 4);
- attrSet = (int) key.mem[0] >> 16;
- attrUse = (int) key.mem[0] & 65535;
-
if (zh->reg->key_buf_used + 1024 >
(zh->reg->ptr_top -zh->reg->ptr_i)*sizeof(char*))
extract_flushWriteKeys (zh,0);
(zh->reg->key_buf)[zh->reg->ptr_top - zh->reg->ptr_i] =
(char*)zh->reg->key_buf + zh->reg->key_buf_used;
- ch = zebraExplain_lookupSU (zei, attrSet, attrUse);
- if (ch < 0)
- ch = zebraExplain_addSU (zei, attrSet, attrUse);
+ ch = key.mem[0]; /* ordinal for field/use/attribute */
- assert (ch > 0);
zh->reg->key_buf_used +=
key_SU_encode (ch,((char*)zh->reg->key_buf) +
zh->reg->key_buf_used);
((char*)(zh->reg->key_buf))[(zh->reg->key_buf_used)++] = cmd;
key.len = 3;
- if (key.mem[1]) /* filter specify record ID */
+ if (key.mem[1]) /* filter specified record ID */
key.mem[0] = key.mem[1];
else
key.mem[0] = sysno;
if (keys->buf_used+1024 > keys->buf_max)
{
- char *b;
-
- b = (char *) xmalloc (keys->buf_max += 128000);
+ char *b = (char *) xmalloc (keys->buf_max += 128000);
if (keys->buf_used > 0)
memcpy (b, keys->buf, keys->buf_used);
xfree (keys->buf);
void extract_add_index_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->attrStr)
+ {
+ ch = zebraExplain_lookup_attr_str(zei, p->attrStr);
+ if (ch < 0)
+ ch = zebraExplain_add_attr_str(zei, p->attrStr);
+ }
+ else
+ {
+ ch = zebraExplain_lookup_attr_su(zei, p->attrSet, p->attrUse);
+ if (ch < 0)
+ ch = zebraExplain_add_attr_su(zei, p->attrSet, p->attrUse);
+ }
key.len = 4;
- key.mem[0] = p->attrSet * 65536 + p->attrUse;
+ key.mem[0] = ch;
key.mem[1] = p->record_id;
key.mem[2] = p->section_id;
key.mem[3] = p->seqno;
static void extract_add_incomplete_field (RecWord *p)
{
- const char *b = p->string;
- int remain = p->length;
+ const char *b = p->term_buf;
+ int remain = p->term_len;
const char **map = 0;
- yaz_log(YLOG_DEBUG, "Incomplete field, w='%.*s'", p->length, p->string);
+ 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);
/* Skip spaces */
while (map && *map && **map == *CHR_SPACE)
{
- remain = p->length - (b - p->string);
+ remain = p->term_len - (b - p->term_buf);
if (remain > 0)
map = zebra_maps_input(p->zebra_maps, p->reg_type, &b, remain, 0);
else
while (i < IT_MAX_WORD && *cp)
buf[i++] = *(cp++);
- remain = p->length - (b - p->string);
+ remain = p->term_len - (b - p->term_buf);
if (remain > 0)
map = zebra_maps_input(p->zebra_maps, p->reg_type, &b, remain, 0);
else
static void extract_add_complete_field (RecWord *p)
{
- const char *b = p->string;
+ const char *b = p->term_buf;
char buf[IT_MAX_WORD+1];
const char **map = 0;
- int i = 0, remain = p->length;
- int first; /* first position */
+ int i = 0, remain = p->term_len;
- yaz_log(YLOG_DEBUG, "Complete field, w='%.*s'", p->length, p->string);
+ yaz_log(YLOG_DEBUG, "Complete field, w='%.*s'",
+ p->term_len, p->term_buf);
if (remain > 0)
map = zebra_maps_input (p->zebra_maps, p->reg_type, &b, remain, 1);
{
while (map && *map && **map == *CHR_SPACE)
{
- remain = p->length - (b - p->string);
+ remain = p->term_len - (b - p->term_buf);
if (remain > 0)
{
- first = i ? 0 : 1;
+ int first = i ? 0 : 1; /* first position */
map = zebra_maps_input(p->zebra_maps, p->reg_type, &b, remain, first);
}
else
while (i < IT_MAX_WORD && *cp)
buf[i++] = *(cp++);
}
- remain = p->length - (b - p->string);
+ remain = p->term_len - (b - p->term_buf);
if (remain > 0)
{
map = zebra_maps_input (p->zebra_maps, p->reg_type, &b,
p->string);
#endif
if ((wrbuf = zebra_replace(p->zebra_maps, p->reg_type, 0,
- p->string, p->length)))
+ p->term_buf, p->term_len)))
{
- p->string = wrbuf_buf(wrbuf);
- p->length = wrbuf_len(wrbuf);
+ p->term_buf = wrbuf_buf(wrbuf);
+ p->term_len = wrbuf_len(wrbuf);
}
if (zebra_maps_is_complete (p->zebra_maps, p->reg_type))
extract_add_complete_field (p);
-/* $Id: zinfo.c,v 1.44 2005-01-16 23:33:31 adam Exp $
+/* $Id: zinfo.c,v 1.45 2005-03-05 09:19:14 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
#define ZINFO_DEBUG 0
struct zebSUInfo {
- int set;
- int use;
+#define ZEB_SU_SET_USE 1
+#define ZEB_SU_STR 2
+ int which;
+ union {
+ char *str;
+ struct {
+ int set;
+ int use;
+ } su;
+ } u;
int ordinal;
};
{
data1_node *node_set = NULL;
data1_node *node_use = NULL;
+ data1_node *node_str = NULL;
data1_node *node_ordinal = NULL;
data1_node *np2;
char oid_str[128];
node_set = np2->child;
else if (!strcmp (np2->u.tag.tag, "use"))
node_use = np2->child;
+ else if (!strcmp (np2->u.tag.tag, "str"))
+ node_str = np2->child;
else if (!strcmp (np2->u.tag.tag, "ordinal"))
node_ordinal = np2->child;
}
- assert (node_set && node_use && node_ordinal);
-
- oid_str_len = node_set->u.data.len;
- if (oid_str_len >= (int) sizeof(oid_str))
- oid_str_len = sizeof(oid_str)-1;
- memcpy (oid_str, node_set->u.data.data, oid_str_len);
- oid_str[oid_str_len] = '\0';
+ assert (node_ordinal);
*zsuip = (struct zebSUInfoB *)
nmem_malloc (zei->nmem, sizeof(**zsuip));
- (*zsuip)->info.set = oid_getvalbyname (oid_str);
+ if (node_set && node_use)
+ {
+ (*zsuip)->info.which = ZEB_SU_SET_USE;
+
+ oid_str_len = node_set->u.data.len;
+ if (oid_str_len >= (int) sizeof(oid_str))
+ oid_str_len = sizeof(oid_str)-1;
+ memcpy (oid_str, node_set->u.data.data, oid_str_len);
+ oid_str[oid_str_len] = '\0';
- (*zsuip)->info.use = atoi_n (node_use->u.data.data,
- node_use->u.data.len);
+ (*zsuip)->info.u.su.set = oid_getvalbyname (oid_str);
+
+ (*zsuip)->info.u.su.use = atoi_n (node_use->u.data.data,
+ node_use->u.data.len);
+ yaz_log (YLOG_DEBUG, "set=%d use=%d ordinal=%d",
+ (*zsuip)->info.u.su.set, (*zsuip)->info.u.su.use,
+ (*zsuip)->info.ordinal);
+ }
+ else if (node_str)
+ {
+ (*zsuip)->info.which = ZEB_SU_STR;
+
+ (*zsuip)->info.u.str = nmem_strdupn(zei->nmem,
+ node_str->u.data.data,
+ node_str->u.data.len);
+ }
+ else
+ {
+ yaz_log(YLOG_WARN, "Missng set/use/str in attribute info");
+ continue;
+ }
(*zsuip)->info.ordinal = atoi_n (node_ordinal->u.data.data,
node_ordinal->u.data.len);
- yaz_log (YLOG_DEBUG, "set=%d use=%d ordinal=%d",
- (*zsuip)->info.set, (*zsuip)->info.use, (*zsuip)->info.ordinal);
zsuip = &(*zsuip)->next;
}
*zsuip = NULL;
writeAttributeValueDetails (zei, zad, node_atvs, c->child);
for (zsui = zad->SUInfo; zsui; zsui = zsui->next)
{
- data1_node *node_attvalue, *node_value;
- if (set_ordinal != zsui->info.set)
- continue;
- node_attvalue = data1_mk_tag (zei->dh, zei->nmem, "attributeValue",
- 0 /* attr */, node_atvs);
- node_value = data1_mk_tag (zei->dh, zei->nmem, "value",
- 0 /* attr */, node_attvalue);
- data1_mk_tag_data_int (zei->dh, node_value, "numeric",
- zsui->info.use, zei->nmem);
+ if (zsui->info.which == ZEB_SU_SET_USE &&
+ set_ordinal == zsui->info.u.su.set)
+ {
+ data1_node *node_attvalue, *node_value;
+ node_attvalue = data1_mk_tag (zei->dh, zei->nmem, "attributeValue",
+ 0 /* attr */, node_atvs);
+ node_value = data1_mk_tag (zei->dh, zei->nmem, "value",
+ 0 /* attr */, node_attvalue);
+ data1_mk_tag_data_int (zei->dh, node_value, "numeric",
+ zsui->info.u.su.use, zei->nmem);
+ }
}
}
int set_ordinal = -1;
for (zsui = zad->SUInfo; zsui; zsui = zsui->next)
{
- if ((set_ordinal < 0 || set_ordinal > zsui->info.set)
- && zsui->info.set > set_min)
- set_ordinal = zsui->info.set;
+ if (zsui->info.which == ZEB_SU_SET_USE &&
+ (set_ordinal < 0 || set_ordinal > zsui->info.u.su.set)
+ && zsui->info.u.su.set > set_min)
+ set_ordinal = zsui->info.u.su.set;
}
if (set_ordinal < 0)
break;
node_attr = data1_mk_tag (zei->dh, zei->nmem, "attr", 0 /* attr */,
node_list);
-
- oident.proto = PROTO_Z3950;
- oident.oclass = CLASS_ATTSET;
- oident.value = (enum oid_value) zsui->info.set;
- oid_ent_to_oid (&oident, oid);
-
- data1_mk_tag_data_text (zei->dh, node_attr, "set",
- oident.desc, zei->nmem);
- data1_mk_tag_data_int (zei->dh, node_attr, "use",
- zsui->info.use, zei->nmem);
+ if (zsui->info.which == ZEB_SU_SET_USE)
+ {
+ oident.proto = PROTO_Z3950;
+ oident.oclass = CLASS_ATTSET;
+ oident.value = (enum oid_value) zsui->info.u.su.set;
+ oid_ent_to_oid (&oident, oid);
+
+ data1_mk_tag_data_text (zei->dh, node_attr, "set",
+ oident.desc, zei->nmem);
+ data1_mk_tag_data_int (zei->dh, node_attr, "use",
+ zsui->info.u.su.use, zei->nmem);
+ }
+ else if (zsui->info.which == ZEB_SU_STR)
+ {
+ data1_mk_tag_data_text (zei->dh, node_attr, "str",
+ zsui->info.u.str, zei->nmem);
+ }
data1_mk_tag_data_int (zei->dh, node_attr, "ordinal",
zsui->info.ordinal, zei->nmem);
}
rec_put (zei->records, &trec);
}
-int zebraExplain_lookupSU (ZebraExplainInfo zei, int set, int use)
+int zebraExplain_lookup_attr_su(ZebraExplainInfo zei, int set, int use)
{
struct zebSUInfoB *zsui;
assert (zei->curDatabaseInfo);
for (zsui = zei->curDatabaseInfo->attributeDetails->SUInfo;
zsui; zsui=zsui->next)
- if (zsui->info.use == use && zsui->info.set == set)
+ if (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)
+{
+ 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))
return zsui->info.ordinal;
return -1;
}
{
struct zebSUInfoB *zsui = zdb->attributeDetails->SUInfo;
for ( ;zsui; zsui = zsui->next)
- if (zsui->info.ordinal == ord)
+ if (zsui->info.which == ZEB_SU_SET_USE &&
+ zsui->info.ordinal == ord)
{
*db = zdb->databaseName;
- *set = zsui->info.set;
- *use = zsui->info.use;
+ *set = zsui->info.u.su.set;
+ *use = zsui->info.u.su.use;
return 0;
}
}
}
}
-int zebraExplain_addSU (ZebraExplainInfo zei, int set, int use)
+int zebraExplain_add_attr_su(ZebraExplainInfo zei, int set, int use)
{
struct zebSUInfoB *zsui;
assert (zei->curDatabaseInfo);
- for (zsui = zei->curDatabaseInfo->attributeDetails->SUInfo;
- zsui; zsui=zsui->next)
- if (zsui->info.use == use && zsui->info.set == set)
- return -1;
zebraExplain_addAttributeSet (zei, set);
zsui = (struct zebSUInfoB *) nmem_malloc (zei->nmem, sizeof(*zsui));
zsui->next = zei->curDatabaseInfo->attributeDetails->SUInfo;
zei->curDatabaseInfo->attributeDetails->SUInfo = zsui;
zei->curDatabaseInfo->attributeDetails->dirty = 1;
zei->dirty = 1;
- zsui->info.set = set;
- zsui->info.use = use;
+ zsui->info.which = ZEB_SU_SET_USE;
+ zsui->info.u.su.set = set;
+ zsui->info.u.su.use = use;
+ zsui->info.ordinal = (zei->ordinalSU)++;
+ return zsui->info.ordinal;
+}
+
+int zebraExplain_add_attr_str(ZebraExplainInfo zei, const char *str)
+{
+ struct zebSUInfoB *zsui;
+
+ assert (zei->curDatabaseInfo);
+ zsui = (struct zebSUInfoB *) nmem_malloc (zei->nmem, sizeof(*zsui));
+ zsui->next = zei->curDatabaseInfo->attributeDetails->SUInfo;
+ zei->curDatabaseInfo->attributeDetails->SUInfo = zsui;
+ zei->curDatabaseInfo->attributeDetails->dirty = 1;
+ zei->dirty = 1;
+ zsui->info.which = ZEB_SU_STR;
+ zsui->info.u.str = nmem_strdup(zei->nmem, str);
zsui->info.ordinal = (zei->ordinalSU)++;
return zsui->info.ordinal;
}
-/* $Id: zinfo.h,v 1.21 2005-01-15 21:45:43 adam Exp $
+/* $Id: zinfo.h,v 1.22 2005-03-05 09:19:15 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_lookupSU (ZebraExplainInfo zei, int set, int use);
-int zebraExplain_addSU (ZebraExplainInfo zei, int set, int use);
+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);
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.169 2005-02-25 10:08:44 adam Exp $
+/* $Id: zrpn.c,v 1.170 2005-03-05 09:19:15 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
}
static void add_isam_p(const char *name, const char *info,
- struct grep_info *p)
+ struct grep_info *p)
{
if (!log_level_set)
{
use_value = 1016;
for (base_no = 0; base_no < num_bases; base_no++)
{
+ int ord = -1;
int attr_ok = 0;
int regex_range = 0;
int init_pos = 0;
}
if (xpath_use > 0 && use_value == -2)
{
- use_value = xpath_use;
+ /* xpath mode and we have a string attribute */
attp.local_attributes = &id_xpath_attr;
attp.attset_ordinal = VAL_IDXPATH;
id_xpath_attr.next = 0;
+
+ use_value = xpath_use; /* xpath_use as use-attribute now */
id_xpath_attr.local = use_value;
}
- else if (curAttributeSet == VAL_IDXPATH)
+ else if (curAttributeSet == VAL_IDXPATH && use_value >= 0)
{
+ /* X-Path attribute, use numeric value directly */
attp.local_attributes = &id_xpath_attr;
attp.attset_ordinal = VAL_IDXPATH;
id_xpath_attr.next = 0;
id_xpath_attr.local = use_value;
}
- else
+ else if (use_string &&
+ (ord = zebraExplain_lookup_attr_str(zh->reg->zei,
+ use_string)) >= 0)
+ {
+ /* we have a match for a raw string attribute */
+ char ord_buf[32];
+ int i, ord_len;
+
+ if (prefix_len)
+ term_dict[prefix_len++] = '|';
+ else
+ term_dict[prefix_len++] = '(';
+
+ ord_len = key_SU_encode (ord, ord_buf);
+ for (i = 0; i<ord_len; i++)
+ {
+ term_dict[prefix_len++] = 1;
+ term_dict[prefix_len++] = ord_buf[i];
+ }
+ attp.local_attributes = 0; /* no more attributes */
+ }
+ else
{
+ /* lookup in the .att files . Allow string as well */
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);
continue;
}
}
- for (local_attr = attp.local_attributes; local_attr;
- local_attr = local_attr->next)
- {
- int ord;
- char ord_buf[32];
- int i, ord_len;
-
- ord = zebraExplain_lookupSU (zh->reg->zei, attp.attset_ordinal,
- local_attr->local);
- if (ord < 0)
- continue;
- if (prefix_len)
- term_dict[prefix_len++] = '|';
- else
- term_dict[prefix_len++] = '(';
-
- ord_len = key_SU_encode (ord, ord_buf);
- for (i = 0; i<ord_len; i++)
- {
- term_dict[prefix_len++] = 1;
- term_dict[prefix_len++] = ord_buf[i];
- }
- }
+ for (local_attr = attp.local_attributes; local_attr;
+ local_attr = local_attr->next)
+ {
+ char ord_buf[32];
+ int i, ord_len;
+
+ ord = zebraExplain_lookup_attr_su(zh->reg->zei,
+ attp.attset_ordinal,
+ local_attr->local);
+ if (ord < 0)
+ continue;
+ if (prefix_len)
+ term_dict[prefix_len++] = '|';
+ else
+ term_dict[prefix_len++] = '(';
+
+ ord_len = key_SU_encode (ord, ord_buf);
+ for (i = 0; i<ord_len; i++)
+ {
+ term_dict[prefix_len++] = 1;
+ term_dict[prefix_len++] = ord_buf[i];
+ }
+ }
if (!prefix_len)
{
#if 1
char ord_buf[32];
int i, ord_len;
- ord = zebraExplain_lookupSU (zh->reg->zei, attp.attset_ordinal,
- local_attr->local);
+ ord = zebraExplain_lookup_attr_su(zh->reg->zei,
+ attp.attset_ordinal,
+ local_attr->local);
if (ord < 0)
continue;
if (prefix_len)
char term_dict[2048];
char ord_buf[32];
int prefix_len = 0;
- int ord = zebraExplain_lookupSU (zh->reg->zei, curAttributeSet, use);
+ int ord = zebraExplain_lookup_attr_su(zh->reg->zei, curAttributeSet, use);
int ord_len, i, r, max_pos;
int term_type = Z_Term_characterString;
const char *flags = "void";
{
int ord;
- ord = zebraExplain_lookupSU (zh->reg->zei, attp.attset_ordinal,
- local_attr->local);
+ ord = zebraExplain_lookup_attr_su(zh->reg->zei,
+ attp.attset_ordinal,
+ local_attr->local);
if (ord > 0)
ords[ord_no++] = ord;
}
-/* $Id: isamb.c,v 1.71 2005-01-16 23:14:57 adam Exp $
+/* $Id: isamb.c,v 1.72 2005-03-05 09:19:15 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
}
}
-static int get_block (ISAMB b, ISAMC_P pos, char *userbuf, int wr)
+static int cache_block (ISAMB b, ISAMC_P pos, char *userbuf, int wr)
{
int cat = (int) (pos&CAT_MASK);
int off = (int) (((pos/CAT_MAX) &
*ce_last = 0; /* remove the last entry from list */
if (ce_this->dirty)
{
- yaz_log(b->log_io, "bf_write: get_block");
+ yaz_log(b->log_io, "bf_write: cache_block");
bf_write(b->file[cat].bf, ce_this->pos, 0, 0, ce_this->buf);
}
xfree(ce_this->buf);
b->file[cat].cache_entries = ce_this;
ce_this->buf = xmalloc(ISAMB_CACHE_ENTRY_SIZE);
ce_this->pos = norm;
- yaz_log(b->log_io, "bf_read: get_block");
+ yaz_log(b->log_io, "bf_read: cache_block");
if (!bf_read(b->file[cat].bf, norm, 0, 0, ce_this->buf))
memset (ce_this->buf, 0, ISAMB_CACHE_ENTRY_SIZE);
if (wr)
p->buf = xmalloc(b->file[cat].head.block_size);
p->cbuf = 0;
- if (!get_block (b, pos, p->buf, 0))
+ if (!cache_block (b, pos, p->buf, 0))
{
yaz_log(b->log_io, "bf_read: open_block");
if (!bf_read(b->file[cat].bf, pos/CAT_MAX, 0, 0, p->buf))
{
p->pos = b->file[cat].head.free_list;
assert((p->pos & CAT_MASK) == cat);
- if (!get_block (b, p->pos, p->buf, 0))
+ if (!cache_block (b, p->pos, p->buf, 0))
{
yaz_log(b->log_io, "bf_read: new_block");
if (!bf_read(b->file[cat].bf, p->pos/CAT_MAX, 0, 0, p->buf))
p->pos, p->cat, p->pos/CAT_MAX);
memcpy (p->buf, &b->file[p->cat].head.free_list, sizeof(zint));
b->file[p->cat].head.free_list = p->pos;
- if (!get_block (b, p->pos, p->buf, 1))
+ if (!cache_block (b, p->pos, p->buf, 1))
{
yaz_log(b->log_io, "bf_write: close_block (deleted)");
bf_write(b->file[p->cat].bf, p->pos/CAT_MAX, 0, 0, p->buf);
p->buf[2] = size >> 8;
encode_ptr(&dst, p->no_items);
check_block(b, p);
- if (!get_block (b, p->pos, p->buf, 1))
+ if (!cache_block (b, p->pos, p->buf, 1))
{
yaz_log(b->log_io, "bf_write: close_block");
bf_write(b->file[p->cat].bf, p->pos/CAT_MAX, 0, 0, p->buf);
-/* $Id: recgrs.c,v 1.99 2005-01-17 22:32:16 adam Exp $
+/* $Id: recgrs.c,v 1.100 2005-03-05 09:19:15 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
/* 2nd arg: start */
if (!sp_expr(sp, n, &tmp_w))
return 0;
- start = atoi_n(tmp_w.string, tmp_w.length);
+ start = atoi_n(tmp_w.term_buf, tmp_w.term_len);
if (sp->lookahead == ',')
{
/* 3rd arg: length */
if (!sp_expr(sp, n, &tmp_w))
return 0;
- len = atoi_n(tmp_w.string, tmp_w.length);
+ len = atoi_n(tmp_w.term_buf, tmp_w.term_len);
}
else
- len = wrd->length;
+ len = wrd->term_len;
/* ) */
if (sp->lookahead != ')')
return 0;
sp_lex(sp);
- if (wrd->string && wrd->length)
+ if (wrd->term_buf && wrd->term_len)
{
- wrd->string += start;
- wrd->length -= start;
- if (wrd->length > len)
- wrd->length = len;
+ wrd->term_buf += start;
+ wrd->term_len -= start;
+ if (wrd->term_len > len)
+ wrd->term_len = len;
}
return 1;
}
if (!sp_expr(sp, n, &search_w))
return 0;
- for (i = 0; i<wrd->length; i++)
+ for (i = 0; i<wrd->term_len; i++)
{
int j;
- for (j = 0; j<search_w.length && i+j < wrd->length; j++)
- if (wrd->string[i+j] != search_w.string[j])
+ for (j = 0; j<search_w.term_len && i+j < wrd->term_len; j++)
+ if (wrd->term_buf[i+j] != search_w.term_buf[j])
break;
- if (j == search_w.length) /* match ? */
+ if (j == search_w.term_len) /* match ? */
{
if (min_pos == -1 || i < min_pos)
min_pos = i;
if (min_pos == -1)
min_pos = 0; /* the default if not found */
sprintf(num_str, "%d", min_pos);
- wrd->string = nmem_strdup(sp->nmem, num_str);
- wrd->length = strlen(wrd->string);
+ wrd->term_buf = nmem_strdup(sp->nmem, num_str);
+ wrd->term_len = strlen(wrd->term_buf);
return 1;
}
{
if (n->which == DATA1N_data)
{
- wrd->string = n->u.data.data;
- wrd->length = n->u.data.len;
+ wrd->term_buf = n->u.data.data;
+ wrd->term_len = n->u.data.len;
}
sp_lex(sp);
}
{
if (n->which == DATA1N_tag)
{
- wrd->string = n->u.tag.tag;
- wrd->length = strlen(n->u.tag.tag);
+ wrd->term_buf = n->u.tag.tag;
+ wrd->term_len = strlen(n->u.tag.tag);
}
sp_lex(sp);
}
if (!sp_expr(sp, n, &tmp_w))
return 0;
- wrd->string = "";
- wrd->length = 0;
+ wrd->term_buf = "";
+ wrd->term_len = 0;
if (n->which == DATA1N_tag)
{
data1_xattr *p = n->u.tag.attributes;
- while (p && strlen(p->name) != tmp_w.length &&
- memcmp (p->name, tmp_w.string, tmp_w.length))
+ while (p && strlen(p->name) != tmp_w.term_len &&
+ memcmp (p->name, tmp_w.term_buf, tmp_w.term_len))
p = p->next;
if (p)
{
- wrd->string = p->value;
- wrd->length = strlen(p->value);
+ wrd->term_buf = p->value;
+ wrd->term_len = strlen(p->value);
}
}
if (sp->lookahead != ')')
}
else if (sp->len > 0 && isdigit(*(unsigned char *)sp->tok))
{
- wrd->string = nmem_malloc(sp->nmem, sp->len);
- memcpy(wrd->string, sp->tok, sp->len);
- wrd->length = sp->len;
+ wrd->term_buf = nmem_malloc(sp->nmem, sp->len);
+ memcpy(wrd->term_buf, sp->tok, sp->len);
+ wrd->term_len = sp->len;
sp_lex(sp);
}
else if (sp->len > 2 && sp->tok[0] == '\'' && sp->tok[sp->len-1] == '\'')
{
- wrd->length = sp->len - 2;
- wrd->string = nmem_malloc(sp->nmem, wrd->length);
- memcpy(wrd->string, sp->tok+1, wrd->length);
+ wrd->term_len = sp->len - 2;
+ wrd->term_buf = nmem_malloc(sp->nmem, wrd->term_len);
+ memcpy(wrd->term_buf, sp->tok+1, wrd->term_len);
sp_lex(sp);
}
else
{
- wrd->string = "";
- wrd->length = 0;
+ wrd->term_buf = "";
+ wrd->term_len = 0;
sp_lex(sp);
}
return 1;
wrd->attrSet = VAL_IDXPATH;
wrd->attrUse = 1;
wrd->reg_type = '0';
- wrd->string = tag_path;
- wrd->length = strlen(tag_path);
+ wrd->term_buf = tag_path;
+ wrd->term_len = strlen(tag_path);
(*p->tokenAdd)(wrd);
if (value) {
wrd->attrUse = 1015;
wrd->reg_type = 'w';
- wrd->string = value;
- wrd->length = strlen(value);
+ wrd->term_buf = value;
+ wrd->term_len = strlen(value);
(*p->tokenAdd)(wrd);
}
wrd->attrUse = 2;
wrd->reg_type = '0';
- wrd->string = tag_path;
- wrd->length = strlen(tag_path);
+ wrd->term_buf = tag_path;
+ wrd->term_len = strlen(tag_path);
(*p->tokenAdd)(wrd);
}
switch (n->which)
{
case DATA1N_data:
- wrd->string = n->u.data.data;
- wrd->length = n->u.data.len;
+ wrd->term_buf = n->u.data.data;
+ wrd->term_len = n->u.data.len;
xpdone = 0;
flen = 0;
int i;
printf("%*sXPath index", (level + 1) * 4, "");
printf (" XData:\"");
- for (i = 0; i<wrd_tl.length && i < 40; i++)
- fputc (wrd_tl.string[i], stdout);
+ for (i = 0; i<wrd_tl.term_len && i < 40; i++)
+ fputc (wrd_tl.term_buf[i], stdout);
fputc ('"', stdout);
- if (wrd_tl.length > 40)
+ if (wrd_tl.term_len > 40)
printf (" ...");
fputc ('\n', stdout);
}
tl->att->name, tl->att->value,
tl->source);
printf (" XData:\"");
- for (i = 0; i<wrd_tl.length && i < 40; i++)
- fputc (wrd_tl.string[i], stdout);
+ for (i = 0; i<wrd_tl.term_len && i < 40; i++)
+ fputc (wrd_tl.term_buf[i], stdout);
fputc ('"', stdout);
- if (wrd_tl.length > 40)
+ if (wrd_tl.term_len > 40)
printf (" ...");
fputc ('\n', stdout);
}
wrd->reg_type = '0';
- wrd->string = tag_path_full;
- wrd->length = flen;
+ wrd->term_buf = tag_path_full;
+ wrd->term_len = flen;
wrd->attrSet = VAL_IDXPATH;
wrd->attrUse = use;
if (p->flagShowRecords)
{
printf("%*s tag=", (level + 1) * 4, "");
- for (i = 0; i<wrd->length && i < 40; i++)
- fputc (wrd->string[i], stdout);
+ for (i = 0; i<wrd->term_len && i < 40; i++)
+ fputc (wrd->term_buf[i], stdout);
if (i == 40)
printf (" ..");
printf("\n");
/* attribute (no value) */
wrd->reg_type = '0';
wrd->attrUse = 3;
- wrd->string = xp->name;
- wrd->length = strlen(xp->name);
+ wrd->term_buf = xp->name;
+ wrd->term_len = strlen(xp->name);
wrd->seqno--;
(*p->tokenAdd)(wrd);
wrd->attrUse = 3;
wrd->reg_type = '0';
- wrd->string = comb;
- wrd->length = strlen(comb);
+ wrd->term_buf = comb;
+ wrd->term_len = strlen(comb);
wrd->seqno--;
(*p->tokenAdd)(wrd);
(tl->att->parent->reference);
wrd->attrUse = tl->att->locals->local;
wrd->reg_type = *tl->structure;
- wrd->string = xp->value;
- wrd->length = strlen(xp->value);
+ wrd->term_buf = xp->value;
+ wrd->term_len = strlen(xp->value);
(*p->tokenAdd)(wrd);
}
}
for (; tlist; tlist = tlist->next)
{
/* consider source */
- wrd->string = 0;
+ wrd->term_buf = 0;
assert(tlist->source);
sp_parse(sp, n, wrd, tlist->source);
- if (wrd->string && wrd->length)
+ if (wrd->term_buf && wrd->term_len)
{
if (p->flagShowRecords)
{
tlist->att->name, tlist->att->value,
tlist->source);
printf (" XData:\"");
- for (i = 0; i<wrd->length && i < 40; i++)
- fputc (wrd->string[i], stdout);
+ for (i = 0; i<wrd->term_len && i < 40; i++)
+ fputc (wrd->term_buf[i], stdout);
fputc ('"', stdout);
- if (wrd->length > 40)
+ if (wrd->term_len > 40)
printf (" ...");
fputc ('\n', stdout);
}
-/* $Id: rectext.c,v 1.23 2005-01-15 19:38:32 adam Exp $
+/* $Id: rectext.c,v 1.24 2005-03-05 09:19:16 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
}
if (i)
{
- recWord.string = w;
- recWord.length = i;
+ recWord.term_buf = w;
+ recWord.term_len = i;
(*p->tokenAdd)(&recWord);
}
} while (r > 0);
-/* $Id: safari.c,v 1.3 2005-01-15 19:38:32 adam Exp $
+/* $Id: safari.c,v 1.4 2005-03-05 09:19:16 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
}
for (cp = line + nor; *cp == ' '; cp++)
;
- recWord.string = cp;
- recWord.length = strlen(cp);
+ recWord.attrStr = field;
+ recWord.term_buf = cp;
+ recWord.term_len = strlen(cp);
(*p->tokenAdd)(&recWord);
}
fi_close(fi);
-/* $Id: safari1.c,v 1.3 2005-01-15 19:38:35 adam Exp $
+/* $Id: safari1.c,v 1.4 2005-03-05 09:19:16 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
ZebraHandle zh = zebra_open(zs);
init_data(zh, myrec);
- do_query(__LINE__, zh, "@attr 1=1016 the", 1);
- do_query(__LINE__, zh, "@attr 1=1016 {the art}", 1);
- do_query(__LINE__, zh, "@attr 1=1016 {den gamle}", 1);
- do_query(__LINE__, zh, "@attr 1=1016 {the of}", 0);
+ do_query(__LINE__, zh, "@attr 1=any the", 1);
+ do_query(__LINE__, zh, "@attr 1=any {the art}", 1);
+ do_query(__LINE__, zh, "@attr 1=any {den gamle}", 1);
+ do_query(__LINE__, zh, "@attr 1=any {the of}", 0);
ids[0] = 24338;
- meta_query(__LINE__, zh, "@attr 1=1016 the", 1, ids);
+ meta_query(__LINE__, zh, "@attr 1=any the", 1, ids);
return close_down(zh, zs, 0);
}