-/* $Id: api.h,v 1.52 2007-08-21 13:27:04 adam Exp $
+/* $Id: api.h,v 1.53 2007-10-31 16:56:14 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
/** \brief Normalize zebra term for register (subject to change!)
\param zh session handle
- \param reg_id register ID, 'w', 'p',..
+ \param index_type "w", "p",..
\param input_str input string buffer
\param input_len input string length
\param output_str output string buffer
\param output_len output string length
*/
YAZ_EXPORT
-int zebra_string_norm(ZebraHandle zh, unsigned reg_id, const char *input_str,
+int zebra_string_norm(ZebraHandle zh, const char *index_type,
+ const char *input_str,
int input_len, char *output_str, int output_len);
/** \brief Creates a database
-/* $Id: recctrl.h,v 1.37 2007-10-29 16:57:51 adam Exp $
+/* $Id: recctrl.h,v 1.38 2007-10-31 16:56:14 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
/** Indexing token */
typedef struct {
- /** index type ('w', 'p', .. */
+ /** index type, e.g. "w", "p", .. */
const char *index_type;
/** index name, e.g. "title" */
const char *index_name;
void (*setStoreData)(struct recExtractCtrl *p, void *buf, size_t size);
int first_record;
int flagShowRecords;
- int seqno[256];
char match_criteria[256];
zint staticrank;
void (*schemaAdd)(struct recExtractCtrl *p, Odr_oid *oid);
-/* $Id: zebramap.h,v 1.25 2007-10-30 19:17:15 adam Exp $
+/* $Id: zebramap.h,v 1.26 2007-10-31 16:56:13 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
const char *input_str, int input_len);
YAZ_EXPORT
-zebra_map_t zebra_map_get(zebra_maps_t zms, unsigned reg_id);
+zebra_map_t zebra_map_get(zebra_maps_t zms, const char *id);
YAZ_EXPORT
-zebra_map_t zebra_map_get_or_add(zebra_maps_t zms, unsigned reg_id);
+zebra_map_t zebra_map_get_or_add(zebra_maps_t zms, const char *id);
YAZ_END_CDECL
-/* $Id: extract.c,v 1.266 2007-10-30 19:17:15 adam Exp $
+/* $Id: extract.c,v 1.267 2007-10-31 16:56:14 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
}
}
-static void extract_flush_record_keys(ZebraHandle zh, zint sysno,
- int cmd, zebra_rec_keys_t reckeys,
- zint staticrank);
static void extract_flush_sort_keys(ZebraHandle zh, zint sysno,
int cmd, zebra_rec_keys_t skp);
static void extract_schema_add(struct recExtractCtrl *p, Odr_oid *oid);
static void init_extractCtrl(ZebraHandle zh, struct recExtractCtrl *ctrl)
{
- int i;
- for (i = 0; i<256; i++)
- {
- zebra_map_t zm = zebra_map_get(zh->reg->zebra_maps, i);
- if (zebra_maps_is_positioned(zm))
- ctrl->seqno[i] = 1;
- else
- ctrl->seqno[i] = 0;
- }
ctrl->flagShowRecords = !zh->m_flag_rw;
}
{
struct snip_rec_info *h = p->extractCtrl->handle;
ZebraHandle zh = h->zh;
- zebra_map_t zm = zebra_map_get(zh->reg->zebra_maps, *p->index_type);
+ zebra_map_t zm = zebra_map_get(zh->reg->zebra_maps, p->index_type);
if (zm && zebra_maps_is_index(zm))
{
zebraExplain_lookup_ord(zh->reg->zei, ord, &index_type,
0/* db */, &string_index);
assert(index_type);
- zebra_term_untrans_iconv(zh, nmem, *index_type,
+ zebra_term_untrans_iconv(zh, nmem, index_type,
&dst_term, str);
*keystr = '\0';
for (i = 0; i<key.len; i++)
yaz_log(log_level_extract, "normal=%d optimized=%d", normal, optimized);
}
-void extract_flush_record_keys(ZebraHandle zh, zint sysno, int cmd,
- zebra_rec_keys_t reckeys,
- zint staticrank)
-{
- ZebraExplainInfo zei = zh->reg->zei;
-
- extract_rec_keys_adjust(zh, cmd, reckeys);
-
- if (log_level_details)
- {
- yaz_log(log_level_details, "Keys for record " ZINT_FORMAT " %s",
- sysno, cmd ? "insert" : "delete");
- extract_rec_keys_log(zh, cmd, reckeys, log_level_details);
- }
-
- if (!zh->reg->key_block)
- {
- int mem = 1024*1024 * atoi( res_get_def( zh->res, "memmax", "8"));
- const char *key_tmp_dir = res_get_def(zh->res, "keyTmpDir", ".");
- int use_threads = atoi(res_get_def(zh->res, "threads", "1"));
- zh->reg->key_block = key_block_create(mem, key_tmp_dir, use_threads);
- }
- zebraExplain_recordCountIncrement(zei, cmd ? 1 : -1);
-
-#if 0
- yaz_log(YLOG_LOG, "sysno=" ZINT_FORMAT " cmd=%d", sysno, cmd);
- print_rec_keys(zh, reckeys);
-#endif
- if (zebra_rec_keys_rewind(reckeys))
- {
- size_t slen;
- const char *str;
- struct it_key key_in;
- while(zebra_rec_keys_read(reckeys, &str, &slen, &key_in))
- {
- key_block_write(zh->reg->key_block, sysno,
- &key_in, cmd, str, slen,
- staticrank, zh->m_staticrank);
- }
- }
-}
ZEBRA_RES zebra_rec_keys_to_snippets(ZebraHandle zh,
zebra_rec_keys_t reckeys,
zebraExplain_lookup_ord(zh->reg->zei, ord, &index_type,
0/* db */, 0 /* string_index */);
assert(index_type);
- zebra_term_untrans_iconv(zh, nmem, *index_type,
+ zebra_term_untrans_iconv(zh, nmem, index_type,
&dst_term, str);
zebra_snippets_append(snippets, seqno, 0, ord, dst_term);
nmem_reset(nmem);
seqno = key.mem[key.len-1];
- zebra_term_untrans(zh, *index_type, dst_buf, str);
+ zebra_term_untrans(zh, index_type, dst_buf, str);
yaz_log(YLOG_LOG, "ord=%d seqno=" ZINT_FORMAT
" term=%s", ord, seqno, dst_buf);
static void extract_token_add(RecWord *p)
{
ZebraHandle zh = p->extractCtrl->handle;
- zebra_map_t zm = zebra_map_get_or_add(zh->reg->zebra_maps, *p->index_type);
+ zebra_map_t zm = zebra_map_get_or_add(zh->reg->zebra_maps, p->index_type);
WRBUF wrbuf;
if (log_level_details)
-/* $Id: index.h,v 1.203 2007-10-30 19:17:15 adam Exp $
+/* $Id: index.h,v 1.204 2007-10-31 16:56:14 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
void zebra_setError(ZebraHandle zh, int code, const char *addinfo);
void zebra_setError_zint(ZebraHandle zh, int code, zint i);
-void zebra_term_untrans_iconv(ZebraHandle zh, NMEM stream, int reg_type,
+void zebra_term_untrans_iconv(ZebraHandle zh, NMEM stream,
+ const char *index_type,
char **dst, const char *src);
ZEBRA_RES zebra_get_hit_vector(ZebraHandle zh, const char *setname, zint sysno);
-void zebra_term_untrans(ZebraHandle zh, int reg_type,
+void zebra_term_untrans(ZebraHandle zh, const char *index_type,
char *dst, const char *src);
ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh,
-/* $Id: invstat.c,v 1.55 2007-10-29 16:57:52 adam Exp $
+/* $Id: invstat.c,v 1.56 2007-10-31 16:56:14 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
{
zebraExplain_lookup_ord (zh->reg->zei, ord, &index_type, &db, 0);
- zebra_term_untrans(zh, *index_type, dst, s + len);
+ zebra_term_untrans(zh, index_type, dst, s + len);
}
printf("%02d:%10" ZINT_FORMAT0 " %s %d.%d - %d.%d\n", ord, count, dst,
firstsys, firstseq, lastsys, lastseq);
-/* $Id: kinput.c,v 1.85 2007-10-29 16:57:52 adam Exp $
+/* $Id: kinput.c,v 1.86 2007-10-31 16:56:14 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
zebraExplain_lookup_ord(zh->reg->zei,
ord, &index_type, &db, &string_index);
- zebra_term_untrans(zh, *index_type, dst, s + len);
+ zebra_term_untrans(zh, index_type, dst, s + len);
yaz_log(YLOG_LOG, "ord=%d index_type=%s index=%s term=%s",
ord, index_type, string_index, dst);
-/* $Id: retrieve.c,v 1.74 2007-10-29 16:57:53 adam Exp $
+/* $Id: retrieve.c,v 1.75 2007-10-31 16:56:14 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
zebraExplain_lookup_ord(zh->reg->zei, ord, &index_type, &db, &string_index);
- zebra_term_untrans(zh, *index_type, dst_buf, str);
+ zebra_term_untrans(zh, index_type, dst_buf, str);
if (!oid_oidcmp(input_format, yaz_oid_recsyn_xml))
{
if (retrieval_type == 0
|| !strcmp(retrieval_type_cstr, index_type))
{
- zebra_term_untrans(zh, *index_type, dst_buf, str);
+ zebra_term_untrans(zh, index_type, dst_buf, str);
if (strlen(dst_buf))
{
if (!oid_oidcmp(input_format, yaz_oid_recsyn_xml))
-/* $Id: rpnscan.c,v 1.16 2007-10-30 19:17:15 adam Exp $
+/* $Id: rpnscan.c,v 1.17 2007-10-31 16:56:14 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
}
}
if (!glist[pos].term)
- zebra_term_untrans_iconv(zh, stream->mem, *index_type,
+ zebra_term_untrans_iconv(zh, stream->mem, index_type,
&glist[pos].term, term);
glist[pos].occurrences = count;
zebra_snippets_destroy(rec_snippets);
{
struct scan2_info_entry *ar = nmem_malloc(nmem, sizeof(*ar) * ord_no);
struct rpn_char_map_info rcmi;
- zebra_map_t zm = zebra_map_get(zh->reg->zebra_maps, *index_type);
+ zebra_map_t zm = zebra_map_get(zh->reg->zebra_maps, index_type);
int i, dif;
int after_pos;
int pos = 0;
-/* $Id: rpnsearch.c,v 1.18 2007-10-30 19:17:15 adam Exp $
+/* $Id: rpnsearch.c,v 1.19 2007-10-31 16:56:14 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
int isam_p_indx;
int trunc_max;
ZebraHandle zh;
- int reg_type;
+ const char *index_type;
ZebraSet termset;
};
const char *index_name;
int len = key_SU_decode(&ord, (const unsigned char *) name);
- zebra_term_untrans (p->zh, p->reg_type, term_tmp, name+len);
+ zebra_term_untrans (p->zh, p->index_type, term_tmp, name+len);
yaz_log(log_level_rpn, "grep: %d %c %s", ord, name[len], term_tmp);
zebraExplain_lookup_ord(p->zh->reg->zei,
ord, 0 /* index_type */, &db, &index_name);
int relation_error;
char ord_buf[32];
int ord_len, i;
- zebra_map_t zm = zebra_map_get(zh->reg->zebra_maps, *index_type);
+ zebra_map_t zm = zebra_map_get(zh->reg->zebra_maps, index_type);
*ol = ord_list_create(stream);
static ZEBRA_RES grep_info_prepare(ZebraHandle zh,
Z_AttributesPlusTerm *zapt,
struct grep_info *grep_info,
- int reg_type)
+ const char *index_type)
{
#ifdef TERM_COUNT
grep_info->term_no = 0;
grep_info->isam_p_size = 0;
grep_info->isam_p_buf = NULL;
grep_info->zh = zh;
- grep_info->reg_type = reg_type;
+ grep_info->index_type = index_type;
grep_info->termset = 0;
if (zapt)
{
*num_result_sets = 0;
*term_dst = 0;
- if (grep_info_prepare(zh, zapt, &grep_info, *index_type) == ZEBRA_FAIL)
+ if (grep_info_prepare(zh, zapt, &grep_info, index_type) == ZEBRA_FAIL)
return ZEBRA_FAIL;
while(1)
{
int ord_len;
char *val;
ISAM_P isam_p;
- zebra_map_t zm = zebra_map_get(zh->reg->zebra_maps, *index_type);
+ zebra_map_t zm = zebra_map_get(zh->reg->zebra_maps, index_type);
attr_init_APT(&position, zapt, 3);
position_value = attr_find(&position, NULL);
int relation_error = 0;
int ord, ord_len, i;
char ord_buf[32];
- zebra_map_t zm = zebra_map_get(zh->reg->zebra_maps, *index_type);
+ zebra_map_t zm = zebra_map_get(zh->reg->zebra_maps, index_type);
*ol = ord_list_create(stream);
term_limits_APT(zh, zapt, &hits_limit_value, &term_ref_id_str, stream);
yaz_log(log_level_rpn, "APT_numeric t='%s'", termz);
- if (grep_info_prepare(zh, zapt, &grep_info, *index_type) == ZEBRA_FAIL)
+ if (grep_info_prepare(zh, zapt, &grep_info, index_type) == ZEBRA_FAIL)
return ZEBRA_FAIL;
while (1)
{
int ord = zebraExplain_lookup_attr_str(zh->reg->zei,
zinfo_index_category_index,
index_type, xpath_use);
- if (grep_info_prepare(zh, 0 /* zapt */, &grep_info, '0') == ZEBRA_FAIL)
+ if (grep_info_prepare(zh, 0 /* zapt */, &grep_info, "0") == ZEBRA_FAIL)
return rset_create_null(rset_nmem, kc, 0);
if (ord < 0)
-/* $Id: untrans.c,v 1.4 2007-10-30 19:17:15 adam Exp $
+/* $Id: untrans.c,v 1.5 2007-10-31 16:56:14 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
#include "index.h"
#include <charmap.h>
-void zebra_term_untrans(ZebraHandle zh, int reg_type,
+void zebra_term_untrans(ZebraHandle zh, const char *index_type,
char *dst, const char *src)
{
- zebra_map_t zm = zebra_map_get(zh->reg->zebra_maps, reg_type);
+ zebra_map_t zm = zebra_map_get(zh->reg->zebra_maps, index_type);
int len = 0;
while (*src)
{
dst[len] = '\0';
}
-void zebra_term_untrans_iconv(ZebraHandle zh, NMEM stream, int reg_type,
+void zebra_term_untrans_iconv(ZebraHandle zh, NMEM stream,
+ const char *index_type,
char **dst, const char *src)
{
char term_src[IT_MAX_WORD];
char term_dst[IT_MAX_WORD];
- zebra_term_untrans (zh, reg_type, term_src, src);
+ zebra_term_untrans (zh, index_type, term_src, src);
if (zh->iconv_from_utf8 != 0)
{
-/* $Id: zebraapi.c,v 1.261 2007-10-30 19:17:15 adam Exp $
+/* $Id: zebraapi.c,v 1.262 2007-10-31 16:56:14 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
return zebra_end_trans (zh);
}
-int zebra_string_norm(ZebraHandle zh, unsigned reg_id,
+int zebra_string_norm(ZebraHandle zh, const char *index_type,
const char *input_str, int input_len,
char *output_str, int output_len)
{
WRBUF wrbuf;
- zebra_map_t zm = zebra_map_get(zh->reg->zebra_maps, reg_id);
+ zebra_map_t zm = zebra_map_get(zh->reg->zebra_maps, index_type);
ASSERTZH;
assert(input_str);
assert(output_str);
-/* $Id: zsets.c,v 1.123 2007-10-29 16:57:53 adam Exp $
+/* $Id: zsets.c,v 1.124 2007-10-31 16:56:14 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
char other_entry_org[1024];
double diff;
const char *index_type = criteria[j].index_type;
- zebra_term_untrans(zh, *index_type, this_entry_org,
+ zebra_term_untrans(zh, index_type, this_entry_org,
this_entry_buf);
- zebra_term_untrans(zh, *index_type, other_entry_org,
+ zebra_term_untrans(zh, index_type, other_entry_org,
other_entry_buf);
diff = atof(this_entry_org) - atof(other_entry_org);
-/* $Id: zebramap.c,v 1.60 2007-10-30 19:17:15 adam Exp $
+/* $Id: zebramap.c,v 1.61 2007-10-31 16:56:15 adam Exp $
Copyright (C) 1995-2007
Index Data ApS
#define ZEBRA_REPLACE_ANY 300
struct zebra_map {
- unsigned reg_id;
+ const char *id;
int completeness;
int positioned;
int alwaysmatches;
int type;
union {
struct {
- int dummy;
- } index;
- struct {
int entry_size;
} sort;
} u;
NMEM nmem;
char temp_map_str[2];
const char *temp_map_ptr[2];
- struct zebra_map **lookup_array;
WRBUF wrbuf_1;
int no_maps;
zebra_map_t map_list;
zebra_map_t zm = (zebra_map_t) nmem_malloc(zms->nmem, sizeof(*zm));
zm->zebra_maps = zms;
- zm->reg_id = index_type[0];
+ zm->id = nmem_strdup(zms->nmem, index_type);
zm->maptab_name = 0;
zm->maptab = 0;
zm->type = map_type;
{
if (zm->type == ZEBRA_MAP_TYPE_SORT)
zm->u.sort.entry_size = atoi(argv[1]);
+ else
+ {
+ yaz_log(YLOG_WARN,
+ "%s:%d: entrysize only valid in sort section",
+ fname, lineno);
+ failures++;
+ }
+
}
else
{
}
yaz_fclose(f);
- for (zm = zms->map_list; zm; zm = zm->next)
- zms->lookup_array[zm->reg_id] = zm;
-
if (failures)
return ZEBRA_FAIL;
return ZEBRA_OK;
const char *profile_path)
{
zebra_maps_t zms = (zebra_maps_t) xmalloc(sizeof(*zms));
- int i;
zms->nmem = nmem_create();
zms->no_maps = 0;
zms->temp_map_ptr[0] = zms->temp_map_str;
zms->temp_map_ptr[1] = NULL;
- zms->lookup_array = (zebra_map_t *)
- nmem_malloc(zms->nmem, sizeof(*zms->lookup_array)*256);
zms->wrbuf_1 = wrbuf_alloc();
- for (i = 0; i<256; i++)
- zms->lookup_array[i] = 0;
return zms;
}
-zebra_map_t zebra_map_get(zebra_maps_t zms, unsigned reg_id)
+zebra_map_t zebra_map_get(zebra_maps_t zms, const char *id)
{
- assert(reg_id >= 0 && reg_id <= 255);
- return zms->lookup_array[reg_id];
+ zebra_map_t zm;
+ for (zm = zms->map_list; zm; zm = zm->next)
+ if (!strcmp(zm->id, id))
+ break;
+ return zm;
}
-zebra_map_t zebra_map_get_or_add(zebra_maps_t zms, unsigned reg_id)
+zebra_map_t zebra_map_get_or_add(zebra_maps_t zms, const char *id)
{
- struct zebra_map *zm = zebra_map_get(zms, reg_id);
+ struct zebra_map *zm = zebra_map_get(zms, id);
if (!zm)
{
- char name[2];
- name[0] = reg_id;
- name[1] = '\0';
-
- zm = zebra_add_map(zms, name, ZEBRA_MAP_TYPE_INDEX);
+ zm = zebra_add_map(zms, id, ZEBRA_MAP_TYPE_INDEX);
/* no reason to warn if no maps are installed at ALL
Note that zebra_add_maps increments no_maps ..
*/
if (zms->no_maps > 1)
- yaz_log(YLOG_WARN, "Unknown register type: %c", reg_id);
+ yaz_log(YLOG_WARN, "Unknown register type: %s", id);
else
zms->no_maps = 0;
zm->maptab_name = nmem_strdup(zms->nmem, "@");
zm->completeness = 0;
zm->positioned = 1;
- zm->next = zms->map_list;
- zms->map_list = zm->next;
-
- zms->lookup_array[zm->reg_id & 255] = zm;
}
return zm;
}