From ebcf2ad410ec9196eee698f021a1bfd6057bdc25 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 30 Mar 2006 09:52:15 +0000 Subject: [PATCH] Add extra argument to zebraExplain_lookup_ord so that we can get string based index back. Provide example of the printing of this in rankstatic.c. --- index/extract.c | 7 ++++--- index/invstat.c | 4 ++-- index/kinput.c | 4 ++-- index/rankstatic.c | 24 +++++++++++++++++++++++- index/zinfo.c | 20 ++++++++++++++++++-- index/zinfo.h | 4 ++-- index/zrpn.c | 4 ++-- 7 files changed, 53 insertions(+), 14 deletions(-) diff --git a/index/extract.c b/index/extract.c index 33f4f9e..f1506c5 100644 --- a/index/extract.c +++ b/index/extract.c @@ -1,4 +1,4 @@ -/* $Id: extract.c,v 1.205 2006-03-25 21:18:09 adam Exp $ +/* $Id: extract.c,v 1.206 2006-03-30 09:52:15 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -1553,7 +1553,8 @@ ZEBRA_RES zebra_snippets_rec_keys(ZebraHandle zh, ord = key.mem[0]; zebraExplain_lookup_ord(zh->reg->zei, ord, &index_type, - 0/* db */, 0/* set */, 0/* use */); + 0/* db */, 0/* set */, 0/* use */, + 0 /* string index */); assert(index_type); zebra_term_untrans_iconv(zh, nmem, index_type, &dst_term, str); @@ -1582,7 +1583,7 @@ void print_rec_keys(ZebraHandle zh, zebra_rec_keys_t reckeys) assert(key.len <= 4 && key.len > 2); zebraExplain_lookup_ord(zh->reg->zei, - key.mem[0], &index_type, &db, 0, 0); + key.mem[0], &index_type, &db, 0, 0, 0); seqno = (int) key.mem[key.len-1]; diff --git a/index/invstat.c b/index/invstat.c index 76b99a3..afa8b81 100644 --- a/index/invstat.c +++ b/index/invstat.c @@ -1,4 +1,4 @@ -/* $Id: invstat.c,v 1.47 2006-02-20 12:41:42 adam Exp $ +/* $Id: invstat.c,v 1.48 2006-03-30 09:52:15 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -58,7 +58,7 @@ static void print_dict_item (ZebraHandle zh, const char *s, zint count, *dst = '\0'; else { - zebraExplain_lookup_ord (zh->reg->zei, ord, &index_type, &db, 0, 0); + zebraExplain_lookup_ord (zh->reg->zei, ord, &index_type, &db, 0, 0, 0); zebra_term_untrans(zh, index_type, dst, s + len); } diff --git a/index/kinput.c b/index/kinput.c index e1dcc77..9d4beaa 100644 --- a/index/kinput.c +++ b/index/kinput.c @@ -1,4 +1,4 @@ -/* $Id: kinput.c,v 1.70 2006-02-20 18:40:23 adam Exp $ +/* $Id: kinput.c,v 1.71 2006-03-30 09:52:15 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -435,7 +435,7 @@ static void print_dict_item(ZebraHandle zh, const char *s) else { zebraExplain_lookup_ord (zh->reg->zei, - ord, &index_type, &db, 0, 0); + ord, &index_type, &db, 0, 0, 0); zebra_term_untrans(zh, index_type, dst, s + len); diff --git a/index/rankstatic.c b/index/rankstatic.c index 9abc7ec..999aa2b 100644 --- a/index/rankstatic.c +++ b/index/rankstatic.c @@ -1,4 +1,4 @@ -/* $Id: rankstatic.c,v 1.3 2005-08-19 11:04:23 adam Exp $ +/* $Id: rankstatic.c,v 1.4 2006-03-30 09:52:15 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -83,8 +83,30 @@ static void *begin (struct zebra_register *reg, si->no_rank_entries = 0; for (i = 0; i < numterms; i++) { + struct ord_list *ol = terms[i]->ol; + yaz_log(log_level, "i=%d flags=%s '%s'", i, terms[i]->flags, terms[i]->name ); + + for (; ol; ol = ol->next) + { + int index_type = 0; + const char *db = 0; + const char *string_index = 0; + int set = -1; + int use = -1; + + zebraExplain_lookup_ord(reg->zei, + ol->ord, &index_type, &db, &set, &use, + &string_index); + + if (string_index) + yaz_log(log_level, " ord=%d index_type=%c db=%s str-index=%s", + ol->ord, index_type, db, string_index); + else + yaz_log(log_level, " ord=%d index_type=%c db=%s set=%d use=%d", + ol->ord, index_type, db, set, use); + } if (!strncmp (terms[i]->flags, "rank,", 5)) (si->no_rank_entries)++; } diff --git a/index/zinfo.c b/index/zinfo.c index 7a7e097..a61dac1 100644 --- a/index/zinfo.c +++ b/index/zinfo.c @@ -1,4 +1,4 @@ -/* $Id: zinfo.c,v 1.56 2006-03-26 14:17:01 adam Exp $ +/* $Id: zinfo.c,v 1.57 2006-03-30 09:52:15 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -1463,9 +1463,20 @@ int zebraExplain_trav_ord(ZebraExplainInfo zei, void *handle, int zebraExplain_lookup_ord (ZebraExplainInfo zei, int ord, int *index_type, const char **db, - int *set, int *use) + int *set, int *use, + const char **string_index) { struct zebDatabaseInfoB *zdb; + + if (set) + *set = -1; + if (use) + *use = -1; + if (index_type) + *index_type = 0; + if (string_index) + *string_index = 0; + for (zdb = zei->databaseInfo; zdb; zdb = zdb->next) { struct zebSUInfoB *zsui; @@ -1485,6 +1496,11 @@ int zebraExplain_lookup_ord (ZebraExplainInfo zei, int ord, if (use) *use = zsui->info.u.su.use; } + + if (zsui->info.which == ZEB_SU_STR) + if (string_index) + *string_index = zsui->info.u.str; + if (index_type) *index_type = zsui->info.index_type; return 0; diff --git a/index/zinfo.h b/index/zinfo.h index fe20b92..981353d 100644 --- a/index/zinfo.h +++ b/index/zinfo.h @@ -1,4 +1,4 @@ -/* $Id: zinfo.h,v 1.28 2006-02-09 08:31:02 adam Exp $ +/* $Id: zinfo.h,v 1.29 2006-03-30 09:52:15 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -69,7 +69,7 @@ void zebraExplain_flush (ZebraExplainInfo zei, void *updateHandle); int zebraExplain_lookup_ord (ZebraExplainInfo zei, int ord, int *index_type, const char **db, - int *set, int *use); + int *set, int *use, const char **string_index); int zebraExplain_trav_ord(ZebraExplainInfo zei, void *handle, int (*f)(void *handle, int ord)); diff --git a/index/zrpn.c b/index/zrpn.c index 5bee0e7..ade12f2 100644 --- a/index/zrpn.c +++ b/index/zrpn.c @@ -1,4 +1,4 @@ -/* $Id: zrpn.c,v 1.209 2006-02-20 12:38:42 adam Exp $ +/* $Id: zrpn.c,v 1.210 2006-03-30 09:52:16 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -245,7 +245,7 @@ static void add_isam_p(const char *name, const char *info, zebra_term_untrans (p->zh, p->reg_type, term_tmp, name+len+1); 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, &set, &use); + ord, 0 /* index_type */, &db, &set, &use, 0); yaz_log(log_level_rpn, "grep: set=%d use=%d db=%s", set, use, db); resultSetAddTerm(p->zh, p->termset, name[len], db, -- 1.7.10.4