From e199777080c6fa0963d51b7df1763fd5286ca9a4 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 31 Oct 2007 16:56:13 +0000 Subject: [PATCH] Changed the index type to a string everywhere. The functions zebra_map_get and zebra_map_get_or_add changed their 3rd argument 'int reg_id' to 'const char *id'. The recExtractCtrl struct defined in idzebra/recctrl.h changed: the seqno array was removed. It is used by no filters and assumes that index type(AKA register type) is a char (int). --- include/idzebra/api.h | 7 ++--- include/idzebra/recctrl.h | 5 ++-- include/zebramap.h | 6 ++--- index/extract.c | 65 +++++---------------------------------------- index/index.h | 7 ++--- index/invstat.c | 4 +-- index/kinput.c | 4 +-- index/retrieve.c | 6 ++--- index/rpnscan.c | 6 ++--- index/rpnsearch.c | 22 +++++++-------- index/untrans.c | 11 ++++---- index/zebraapi.c | 6 ++--- index/zsets.c | 6 ++--- util/zebramap.c | 51 +++++++++++++++-------------------- 14 files changed, 73 insertions(+), 133 deletions(-) diff --git a/include/idzebra/api.h b/include/idzebra/api.h index 4a75217..e3e976b 100644 --- a/include/idzebra/api.h +++ b/include/idzebra/api.h @@ -1,4 +1,4 @@ -/* $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 @@ -328,14 +328,15 @@ ZEBRA_RES zebra_auth(ZebraHandle zh, const char *user, const char *pass); /** \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 diff --git a/include/idzebra/recctrl.h b/include/idzebra/recctrl.h index 207b32d..e4d3604 100644 --- a/include/idzebra/recctrl.h +++ b/include/idzebra/recctrl.h @@ -1,4 +1,4 @@ -/* $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 @@ -49,7 +49,7 @@ YAZ_BEGIN_CDECL /** 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; @@ -100,7 +100,6 @@ struct recExtractCtrl { 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); diff --git a/include/zebramap.h b/include/zebramap.h index 678ff94..0912f89 100644 --- a/include/zebramap.h +++ b/include/zebramap.h @@ -1,4 +1,4 @@ -/* $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 @@ -86,10 +86,10 @@ WRBUF zebra_replace(zebra_map_t zm, const char *ex_list, 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 diff --git a/index/extract.c b/index/extract.c index 66eaff1..c70e6a1 100644 --- a/index/extract.c +++ b/index/extract.c @@ -1,4 +1,4 @@ -/* $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 @@ -67,9 +67,6 @@ static void zebra_init_log_level(void) } } -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); @@ -100,15 +97,6 @@ static void logRecord(ZebraHandle zh) 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; } @@ -282,7 +270,7 @@ static void snippet_token_add(RecWord *p) { 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)) { @@ -1277,7 +1265,7 @@ void extract_rec_keys_log(ZebraHandle zh, int is_insert, 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; ireg->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, @@ -1510,7 +1457,7 @@ ZEBRA_RES zebra_rec_keys_to_snippets(ZebraHandle zh, 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); @@ -1541,7 +1488,7 @@ void print_rec_keys(ZebraHandle zh, zebra_rec_keys_t reckeys) 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); @@ -1821,7 +1768,7 @@ static void extract_token_add2(RecWord *p) 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) diff --git a/index/index.h b/index/index.h index a03ee21..514a700 100644 --- a/index/index.h +++ b/index/index.h @@ -1,4 +1,4 @@ -/* $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 @@ -376,12 +376,13 @@ Dict dict_open_res(BFiles bfs, const char *name, int cache, int rw, 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, diff --git a/index/invstat.c b/index/invstat.c index 3ec3a32..4ed7ef2 100644 --- a/index/invstat.c +++ b/index/invstat.c @@ -1,4 +1,4 @@ -/* $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 @@ -60,7 +60,7 @@ static void print_dict_item (ZebraHandle zh, const char *s, zint count, { 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); diff --git a/index/kinput.c b/index/kinput.c index cd86e32..9101fa7 100644 --- a/index/kinput.c +++ b/index/kinput.c @@ -1,4 +1,4 @@ -/* $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 @@ -389,7 +389,7 @@ void zebra_log_dict_entry(ZebraHandle zh, const char *s) 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); diff --git a/index/retrieve.c b/index/retrieve.c index cd87235..6a56d61 100644 --- a/index/retrieve.c +++ b/index/retrieve.c @@ -1,4 +1,4 @@ -/* $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 @@ -186,7 +186,7 @@ int zebra_special_sort_fetch(ZebraHandle zh, zint sysno, ODR odr, 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)) { @@ -326,7 +326,7 @@ int zebra_special_index_fetch(ZebraHandle zh, zint sysno, ODR odr, 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)) diff --git a/index/rpnscan.c b/index/rpnscan.c index 1327f5f..9349565 100644 --- a/index/rpnscan.c +++ b/index/rpnscan.c @@ -1,4 +1,4 @@ -/* $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 @@ -257,7 +257,7 @@ static int scan_save_set(ZebraHandle zh, ODR stream, NMEM nmem, } } 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); @@ -283,7 +283,7 @@ static ZEBRA_RES rpn_scan_ver2(ZebraHandle zh, ODR stream, NMEM nmem, { 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; diff --git a/index/rpnsearch.c b/index/rpnsearch.c index ca44a81..b399a49 100644 --- a/index/rpnsearch.c +++ b/index/rpnsearch.c @@ -1,4 +1,4 @@ -/* $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 @@ -79,7 +79,7 @@ struct grep_info { int isam_p_indx; int trunc_max; ZebraHandle zh; - int reg_type; + const char *index_type; ZebraSet termset; }; @@ -135,7 +135,7 @@ static int add_isam_p(const char *name, const char *info, 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); @@ -948,7 +948,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, 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); @@ -1123,7 +1123,7 @@ static void grep_info_delete(struct grep_info *grep_info) 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; @@ -1132,7 +1132,7 @@ static ZEBRA_RES grep_info_prepare(ZebraHandle zh, 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) { @@ -1217,7 +1217,7 @@ static ZEBRA_RES term_list_trunc(ZebraHandle zh, *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) { @@ -1275,7 +1275,7 @@ static ZEBRA_RES rpn_search_APT_position(ZebraHandle zh, 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); @@ -1634,7 +1634,7 @@ static ZEBRA_RES numeric_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, 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); @@ -1706,7 +1706,7 @@ static ZEBRA_RES rpn_search_APT_numeric(ZebraHandle zh, 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) { @@ -1904,7 +1904,7 @@ static RSET xpath_trunc(ZebraHandle zh, NMEM stream, 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) diff --git a/index/untrans.c b/index/untrans.c index d51c25c..0551e3c 100644 --- a/index/untrans.c +++ b/index/untrans.c @@ -1,4 +1,4 @@ -/* $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 @@ -28,10 +28,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "index.h" #include -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) { @@ -49,13 +49,14 @@ void zebra_term_untrans(ZebraHandle zh, int reg_type, 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) { diff --git a/index/zebraapi.c b/index/zebraapi.c index ed3786c..66e9f87 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $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 @@ -1551,12 +1551,12 @@ ZEBRA_RES zebra_create_database (ZebraHandle zh, const char *db) 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); diff --git a/index/zsets.c b/index/zsets.c index 04cc69e..1a4686b 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -1,4 +1,4 @@ -/* $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 @@ -580,9 +580,9 @@ void resultSetInsertSort(ZebraHandle zh, ZebraSet sset, 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); diff --git a/util/zebramap.c b/util/zebramap.c index b96e9f0..3fe7f06 100644 --- a/util/zebramap.c +++ b/util/zebramap.c @@ -1,4 +1,4 @@ -/* $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 @@ -37,7 +37,7 @@ #define ZEBRA_REPLACE_ANY 300 struct zebra_map { - unsigned reg_id; + const char *id; int completeness; int positioned; int alwaysmatches; @@ -45,9 +45,6 @@ struct zebra_map { int type; union { struct { - int dummy; - } index; - struct { int entry_size; } sort; } u; @@ -63,7 +60,6 @@ struct zebra_maps_s { 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; @@ -90,7 +86,7 @@ zebra_map_t zebra_add_map(zebra_maps_t zms, const char *index_type, 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; @@ -199,6 +195,14 @@ ZEBRA_RES zebra_maps_read_file(zebra_maps_t zms, const char *fname) { 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 { @@ -209,9 +213,6 @@ ZEBRA_RES zebra_maps_read_file(zebra_maps_t zms, const char *fname) } 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; @@ -221,7 +222,6 @@ zebra_maps_t zebra_maps_open(Res res, const char *base_path, const char *profile_path) { zebra_maps_t zms = (zebra_maps_t) xmalloc(sizeof(*zms)); - int i; zms->nmem = nmem_create(); zms->no_maps = 0; @@ -238,47 +238,38 @@ zebra_maps_t zebra_maps_open(Res res, const char *base_path, 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; } -- 1.7.10.4