Changed the index type to a string everywhere.
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 31 Oct 2007 16:56:13 +0000 (16:56 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 31 Oct 2007 16:56:13 +0000 (16:56 +0000)
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).

14 files changed:
include/idzebra/api.h
include/idzebra/recctrl.h
include/zebramap.h
index/extract.c
index/index.h
index/invstat.c
index/kinput.c
index/retrieve.c
index/rpnscan.c
index/rpnsearch.c
index/untrans.c
index/zebraapi.c
index/zsets.c
util/zebramap.c

index 4a75217..e3e976b 100644 (file)
@@ -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
 
    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
 
 /** \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
     \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
                      int input_len, char *output_str, int output_len);
 
 /** \brief Creates a database
index 207b32d..e4d3604 100644 (file)
@@ -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
 
    Copyright (C) 1995-2007
    Index Data ApS
 
@@ -49,7 +49,7 @@ YAZ_BEGIN_CDECL
 
 /** Indexing token */
 typedef struct {
 
 /** 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;
     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;
     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);
     char      match_criteria[256];
     zint      staticrank;
     void      (*schemaAdd)(struct recExtractCtrl *p, Odr_oid *oid);
index 678ff94..0912f89 100644 (file)
@@ -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
 
    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
                    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
 
 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
 
 
 YAZ_END_CDECL
 
index 66eaff1..c70e6a1 100644 (file)
@@ -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
 
    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);
 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)
 {
 
 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;
 }
 
     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;
 {
     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))
     {
 
     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);
             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++)
                                      &dst_term, str);
             *keystr = '\0';
             for (i = 0; i<key.len; i++)
@@ -1444,47 +1432,6 @@ void extract_flush_record_keys2(ZebraHandle zh, zint sysno,
     yaz_log(log_level_extract, "normal=%d optimized=%d", normal, optimized);
 }
 
     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,
 
 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);
            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);
                                     &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];
            
            
            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); 
            
            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;
 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)
     WRBUF wrbuf;
 
     if (log_level_details)
index a03ee21..514a700 100644 (file)
@@ -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
 
    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_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);
 
                              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,
                        char *dst, const char *src);
 
 ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh,
index 3ec3a32..4ed7ef2 100644 (file)
@@ -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
 
    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);
 
     {
         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);
     }
     printf("%02d:%10" ZINT_FORMAT0 " %s %d.%d - %d.%d\n", ord, count, dst,
           firstsys, firstseq, lastsys, lastseq);
index cd86e32..9101fa7 100644 (file)
@@ -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
 
    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);
 
         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);
 
         yaz_log(YLOG_LOG, "ord=%d index_type=%s index=%s term=%s",
                 ord, index_type, string_index, dst);
index cd87235..6a56d61 100644 (file)
@@ -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
 
    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);
         
 
         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 (!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))
                 {
                 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))
                     if (strlen(dst_buf))
                     {
                         if (!oid_oidcmp(input_format, yaz_oid_recsyn_xml))
index 1327f5f..9349565 100644 (file)
@@ -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
 
    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)
                 }
             }
             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);
                                          &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;
 {
     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;
     int i, dif;
     int after_pos;
     int pos = 0;
index ca44a81..b399a49 100644 (file)
@@ -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
 
    Copyright (C) 1995-2007
    Index Data ApS
 
@@ -79,7 +79,7 @@ struct grep_info {
     int isam_p_indx;
     int trunc_max;
     ZebraHandle zh;
     int isam_p_indx;
     int trunc_max;
     ZebraHandle zh;
-    int reg_type;
+    const char *index_type;
     ZebraSet termset;
 };        
 
     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);
         
         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);
         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;
     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);
 
     
     *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,
 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;
 {
 #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->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)
     {
     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;
 
     *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)
     { 
         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;
     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);
     
     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];
     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);
 
     
     *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);
     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)
     { 
         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);
     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)
         return rset_create_null(rset_nmem, kc, 0);
     
     if (ord < 0)
index d51c25c..0551e3c 100644 (file)
@@ -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
 
    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 <charmap.h>
 
 #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)
 {
                        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)
     {
     int len = 0;
     while (*src)
     {
@@ -49,13 +49,14 @@ void zebra_term_untrans(ZebraHandle zh, int reg_type,
     dst[len] = '\0';
 }
 
     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];
     
                              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)
     {
 
     if (zh->iconv_from_utf8 != 0)
     {
index ed3786c..66e9f87 100644 (file)
@@ -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
 
    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);
 }
 
     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;
                      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);
     ASSERTZH;
     assert(input_str);
     assert(output_str);
index 04cc69e..1a4686b 100644 (file)
@@ -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
 
    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;
                 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);
                                    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);
                 
                                    other_entry_buf);
                 diff = atof(this_entry_org) - atof(other_entry_org);
                 
index b96e9f0..3fe7f06 100644 (file)
@@ -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
 
    Copyright (C) 1995-2007
    Index Data ApS
 
@@ -37,7 +37,7 @@
 #define ZEBRA_REPLACE_ANY  300
 
 struct zebra_map {
 #define ZEBRA_REPLACE_ANY  300
 
 struct zebra_map {
-    unsigned reg_id;
+    const char *id;
     int completeness;
     int positioned;
     int alwaysmatches;
     int completeness;
     int positioned;
     int alwaysmatches;
@@ -45,9 +45,6 @@ struct zebra_map {
     int type;
     union {
         struct {
     int type;
     union {
         struct {
-            int dummy;
-        } index;
-        struct {
             int entry_size;
         } sort;
     } u;
             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];
     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;
     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;
     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;
     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]);
         {
             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
         {
         }
         else
         {
@@ -209,9 +213,6 @@ ZEBRA_RES zebra_maps_read_file(zebra_maps_t zms, const char *fname)
     }
     yaz_fclose(f);
 
     }
     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;
     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));
                          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->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->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();
 
     zms->wrbuf_1 = wrbuf_alloc();
 
-    for (i = 0; i<256; i++)
-       zms->lookup_array[i] = 0;
     return zms;
 }
 
     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)
     {
     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)
        
        /* 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;
         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;
 }
     }
     return zm;
 }