From: Adam Dickmeiss Date: Fri, 19 May 2006 23:20:24 +0000 (+0000) Subject: Furhter code reductions because of string attributes X-Git-Tag: before.bug.529~110 X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=commitdiff_plain;h=1369748dd7899789c97d94801048bf942e0cc6e6 Furhter code reductions because of string attributes --- diff --git a/index/extract.c b/index/extract.c index 75bc9e0..0432e60 100644 --- a/index/extract.c +++ b/index/extract.c @@ -1,4 +1,4 @@ -/* $Id: extract.c,v 1.215 2006-05-19 13:49:34 adam Exp $ +/* $Id: extract.c,v 1.216 2006-05-19 23:20:24 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -1561,8 +1561,7 @@ 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 /* string_index */); + 0/* db */, 0 /* string_index */); assert(index_type); zebra_term_untrans_iconv(zh, nmem, index_type, &dst_term, str); @@ -1591,7 +1590,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, 0); + key.mem[0], &index_type, &db, 0); seqno = (int) key.mem[key.len-1]; diff --git a/index/index.h b/index/index.h index d06d36d..f205d25 100644 --- a/index/index.h +++ b/index/index.h @@ -1,4 +1,4 @@ -/* $Id: index.h,v 1.162 2006-05-19 13:49:34 adam Exp $ +/* $Id: index.h,v 1.163 2006-05-19 23:20:24 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -334,9 +334,9 @@ RSET rset_trunc(ZebraHandle zh, ISAM_P *isam_p, int no, struct ord_list *ol, int reg_type, zint hits_limit, const char *term_ref_id); -void resultSetAddTerm (ZebraHandle zh, ZebraSet s, int reg_type, - const char *db, int set, - int use, const char *term); +void resultSetAddTerm(ZebraHandle zh, ZebraSet s, int reg_type, + const char *db, const char *index_name, + const char *term); ZebraSet resultSetAdd (ZebraHandle zh, const char *name, int ov); ZebraSet resultSetGet (ZebraHandle zh, const char *name); ZEBRA_RES resultSetAddRPN (ZebraHandle zh, NMEM m, Z_RPNQuery *rpn, diff --git a/index/invstat.c b/index/invstat.c index 40fc02a..8a1cf1a 100644 --- a/index/invstat.c +++ b/index/invstat.c @@ -1,4 +1,4 @@ -/* $Id: invstat.c,v 1.50 2006-05-10 08:13:21 adam Exp $ +/* $Id: invstat.c,v 1.51 2006-05-19 23:20:24 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, 0); + zebraExplain_lookup_ord (zh->reg->zei, ord, &index_type, &db, 0); zebra_term_untrans(zh, index_type, dst, s + len); } diff --git a/index/ranksimilarity.c b/index/ranksimilarity.c index cf553d1..81add45 100644 --- a/index/ranksimilarity.c +++ b/index/ranksimilarity.c @@ -1,4 +1,4 @@ -/* $Id: ranksimilarity.c,v 1.8 2006-05-11 10:26:13 marc Exp $ +/* $Id: ranksimilarity.c,v 1.9 2006-05-19 23:20:24 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -228,13 +228,11 @@ static void *begin (struct zebra_register *reg, 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, + ol->ord, &index_type, &db, &string_index); - + no_docs_fieldindex += zebraExplain_ord_get_doc_occurrences(reg->zei, ol->ord); no_terms_fieldindex @@ -246,8 +244,8 @@ static void *begin (struct zebra_register *reg, ol->ord, index_type, db, string_index); else yaz_log(log_level, - "begin() index: ord=%d type=%c db=%s set=%d use=%d", - ol->ord, index_type, db, set, use); + "begin() index: ord=%d type=%c db=%s", + ol->ord, index_type, db); } si->entries[i].no_docs_fieldindex = no_docs_fieldindex; diff --git a/index/rankstatic.c b/index/rankstatic.c index 5ba63ef..cc86ca1 100644 --- a/index/rankstatic.c +++ b/index/rankstatic.c @@ -1,4 +1,4 @@ -/* $Id: rankstatic.c,v 1.6 2006-05-10 08:13:22 adam Exp $ +/* $Id: rankstatic.c,v 1.7 2006-05-19 23:20:24 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -98,8 +98,7 @@ static void *begin (struct zebra_register *reg, int use = -1; zebraExplain_lookup_ord(reg->zei, - ol->ord, &index_type, &db, &set, &use, - &string_index); + ol->ord, &index_type, &db, &string_index); if (string_index) yaz_log(log_level, " ord=%d index_type=%c db=%s str-index=%s", diff --git a/index/retrieve.c b/index/retrieve.c index 16ae27a..6492745 100644 --- a/index/retrieve.c +++ b/index/retrieve.c @@ -1,4 +1,4 @@ -/* $Id: retrieve.c,v 1.40 2006-05-10 08:13:22 adam Exp $ +/* $Id: retrieve.c,v 1.41 2006-05-19 23:20:24 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -153,9 +153,8 @@ int zebra_record_fetch (ZebraHandle zh, SYSNO sysno, int score, const char *string_index = 0; char dst_buf[IT_MAX_WORD]; - zebraExplain_lookup_ord (zh->reg->zei, ord, - &index_type, &db, - &set, &use, &string_index); + zebraExplain_lookup_ord(zh->reg->zei, ord, &index_type, &db, + &string_index); if (string_index) wrbuf_printf(wrbuf, "%s", string_index); diff --git a/index/zinfo.c b/index/zinfo.c index 3d2aee8..5146554 100644 --- a/index/zinfo.c +++ b/index/zinfo.c @@ -1,4 +1,4 @@ -/* $Id: zinfo.c,v 1.64 2006-05-19 13:49:34 adam Exp $ +/* $Id: zinfo.c,v 1.65 2006-05-19 23:20:24 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -38,10 +38,6 @@ struct zebSUInfo { int which; union { char *str; - struct { - int set; - int use; - } su; } u; int ordinal; zint doc_occurrences; @@ -591,16 +587,12 @@ static void zebraExplain_readAttributeDetails(ZebraExplainInfo zei, "attrlist"); for (np = node_list->child; np; np = np->next) { - data1_node *node_set = NULL; - data1_node *node_use = NULL; data1_node *node_str = NULL; data1_node *node_ordinal = NULL; data1_node *node_type = NULL; data1_node *node_doc_occurrences = NULL; data1_node *node_term_occurrences = NULL; data1_node *np2; - char oid_str[128]; - int oid_str_len; if (np->which != DATA1N_tag || strcmp(np->u.tag.tag, "attr")) continue; @@ -609,11 +601,7 @@ static void zebraExplain_readAttributeDetails(ZebraExplainInfo zei, if (np2->which != DATA1N_tag || !np2->child || np2->child->which != DATA1N_data) continue; - if (!strcmp(np2->u.tag.tag, "set")) - node_set = np2->child; - else if (!strcmp(np2->u.tag.tag, "use")) - node_use = np2->child; - else if (!strcmp(np2->u.tag.tag, "str")) + if (!strcmp(np2->u.tag.tag, "str")) node_str = np2->child; else if (!strcmp(np2->u.tag.tag, "ordinal")) node_ordinal = np2->child; @@ -654,25 +642,7 @@ static void zebraExplain_readAttributeDetails(ZebraExplainInfo zei, (*zsuip)->info.term_occurrences = atoi_zn(np->u.data.data, np->u.data.len); } - 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.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) + if (node_str) { (*zsuip)->info.which = ZEB_SU_STR; @@ -965,32 +935,6 @@ int zebraExplain_newDatabase (ZebraExplainInfo zei, const char *database, return 0; } -static void writeAttributeValueDetails (ZebraExplainInfo zei, - zebAttributeDetails zad, - data1_node *node_atvs, data1_attset *attset) - -{ - struct zebSUInfoB *zsui; - int set_ordinal = attset->reference; - data1_attset_child *c; - - for (c = attset->children; c; c = c->next) - writeAttributeValueDetails (zei, zad, node_atvs, c->child); - for (zsui = zad->SUInfo; zsui; zsui = zsui->next) - { - 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); - } - } -} static void zebraExplain_writeCategoryList (ZebraExplainInfo zei, struct zebraCategoryListInfo *zcl, @@ -1064,9 +1008,8 @@ static void zebraExplain_writeAttributeDetails (ZebraExplainInfo zei, char *sgml_buf; int sgml_len; Record drec; - data1_node *node_adinfo, *node_list, *node_zebra, *node_attributesBySet; + data1_node *node_adinfo, *node_list, *node_zebra; struct zebSUInfoB *zsui; - int set_min; if (!zad->dirty) return; @@ -1092,65 +1035,6 @@ static void zebraExplain_writeAttributeDetails (ZebraExplainInfo zei, record count, etc. is affected */ if (key_flush) (*zei->updateFunc)(zei->updateHandle, drec, zad->data1_tree); - - node_attributesBySet = data1_mk_tag_uni (zei->dh, zei->nmem, - "attributesBySet", node_adinfo); - set_min = -1; - while (1) - { - data1_node *node_asd; - data1_attset *attset; - int set_ordinal = -1; - for (zsui = zad->SUInfo; zsui; zsui = zsui->next) - { - 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; - set_min = set_ordinal; - node_asd = data1_mk_tag (zei->dh, zei->nmem, - "attributeSetDetails", - 0 /* attr */, node_attributesBySet); - - attset = data1_attset_search_id (zei->dh, set_ordinal); - if (!attset) - { - zebraExplain_loadAttsets (zei->dh, zei->res); - attset = data1_attset_search_id (zei->dh, set_ordinal); - } - if (attset) - { - int oid[OID_SIZE]; - oident oe; - - oe.proto = PROTO_Z3950; - oe.oclass = CLASS_ATTSET; - oe.value = (enum oid_value) set_ordinal; - - if (oid_ent_to_oid (&oe, oid)) - { - data1_node *node_abt, *node_atd, *node_atvs; - data1_mk_tag_data_oid (zei->dh, node_asd, "oid", - oid, zei->nmem); - - node_abt = data1_mk_tag (zei->dh, zei->nmem, - "attributesByType", - 0 /*attr */, node_asd); - node_atd = data1_mk_tag (zei->dh, zei->nmem, - "attributeTypeDetails", - 0 /* attr */, node_abt); - data1_mk_tag_data_int (zei->dh, node_atd, - "type", 1, zei->nmem); - node_atvs = data1_mk_tag (zei->dh, zei->nmem, - "attributeValues", - 0 /* attr */, node_atd); - writeAttributeValueDetails (zei, zad, node_atvs, attset); - } - } - } /* zebra info (private) */ node_zebra = data1_mk_tag_uni (zei->dh, zei->nmem, "zebraInfo", node_adinfo); @@ -1158,11 +1042,8 @@ static void zebraExplain_writeAttributeDetails (ZebraExplainInfo zei, "attrlist", node_zebra); for (zsui = zad->SUInfo; zsui; zsui = zsui->next) { - struct oident oident; - int oid[OID_SIZE]; data1_node *node_attr; char index_type_str[2]; - node_attr = data1_mk_tag (zei->dh, zei->nmem, "attr", 0 /* attr */, node_list); @@ -1171,19 +1052,7 @@ static void zebraExplain_writeAttributeDetails (ZebraExplainInfo zei, index_type_str[1] = '\0'; data1_mk_tag_data_text (zei->dh, node_attr, "type", index_type_str, 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) + if (zsui->info.which == ZEB_SU_STR) { data1_mk_tag_data_text (zei->dh, node_attr, "str", zsui->info.u.str, zei->nmem); @@ -1434,53 +1303,6 @@ static void zebraExplain_writeTarget (ZebraExplainInfo zei, int key_flush) rec_put (zei->records, &trec); } -int zebraExplain_lookup_attr_su_any_index(ZebraExplainInfo zei, - int set, int use) -{ - struct zebSUInfoB *zsui; - int ord; - - assert (zei->curDatabaseInfo); - - ord = zebraExplain_lookup_attr_su(zei, 'w', set, use); - if (ord != -1) - return ord; - for (zsui = zei->curDatabaseInfo->attributeDetails->SUInfo; - zsui; zsui=zsui->next) - 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_su(ZebraExplainInfo zei, int index_type, - int set, int use) -{ - struct zebSUInfoB **zsui; - -#if 0 - yaz_log(YLOG_LOG, "lookup_attr_su index_type=%d set=%d use=%d", - index_type, set, use); -#endif - assert (zei->curDatabaseInfo); - for (zsui = &zei->curDatabaseInfo->attributeDetails->SUInfo; - *zsui; zsui = &(*zsui)->next) - if ((*zsui)->info.index_type == index_type && - (*zsui)->info.which == ZEB_SU_SET_USE && - (*zsui)->info.u.su.use == use && (*zsui)->info.u.su.set == set) - { - struct zebSUInfoB *zsui_this = *zsui; - - /* take it out of the list and move to front */ - *zsui = (*zsui)->next; - zsui_this->next = zei->curDatabaseInfo->attributeDetails->SUInfo; - zei->curDatabaseInfo->attributeDetails->SUInfo = zsui_this; - - return zsui_this->info.ordinal; - } - return -1; -} - int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, int index_type, const char *str) { @@ -1601,15 +1423,10 @@ zint zebraExplain_ord_get_term_occurrences(ZebraExplainInfo zei, int ord) int zebraExplain_lookup_ord(ZebraExplainInfo zei, int ord, int *index_type, const char **db, - int *set, int *use, const char **string_index) { struct zebSUInfoB *zsui; - if (set) - *set = -1; - if (use) - *use = -1; if (index_type) *index_type = 0; if (string_index) @@ -1618,18 +1435,9 @@ int zebraExplain_lookup_ord(ZebraExplainInfo zei, int ord, zsui = zebraExplain_get_sui_info(zei, ord, 0, db); if (zsui) { - if (zsui->info.which == ZEB_SU_SET_USE) - { - if (set) - *set = zsui->info.u.su.set; - 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; @@ -1695,19 +1503,6 @@ struct zebSUInfoB *zebraExplain_add_sui_info(ZebraExplainInfo zei, return zsui; } -int zebraExplain_add_attr_su(ZebraExplainInfo zei, int index_type, - int set, int use) -{ - struct zebSUInfoB *zsui = zebraExplain_add_sui_info(zei, index_type); - - yaz_log(YLOG_WARN, "add_attr_su"); - zebraExplain_addAttributeSet (zei, set); - zsui->info.which = ZEB_SU_SET_USE; - zsui->info.u.su.set = set; - zsui->info.u.su.use = use; - return zsui->info.ordinal; -} - int zebraExplain_add_attr_str(ZebraExplainInfo zei, int index_type, const char *index_name) { diff --git a/index/zinfo.h b/index/zinfo.h index 8bead04..7597292 100644 --- a/index/zinfo.h +++ b/index/zinfo.h @@ -1,4 +1,4 @@ -/* $Id: zinfo.h,v 1.32 2006-05-11 10:15:33 adam Exp $ +/* $Id: zinfo.h,v 1.33 2006-05-19 23:20:24 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -50,10 +50,6 @@ void zebraExplain_close (ZebraExplainInfo zei); int zebraExplain_curDatabase (ZebraExplainInfo zei, const char *database); int zebraExplain_newDatabase (ZebraExplainInfo zei, const char *database, int explain_database); -int zebraExplain_lookup_attr_su(ZebraExplainInfo zei, int index_type, - int set, int use); -int zebraExplain_lookup_attr_su_any_index(ZebraExplainInfo zei, - int set, int use); int zebraExplain_add_attr_su(ZebraExplainInfo zei, int index_type, int set, int use); int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, int index_type, @@ -69,7 +65,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, const char **string_index); + const char **string_index); int zebraExplain_ord_adjust_occurrences(ZebraExplainInfo zei, int ord, int term_delta, int doc_delta); diff --git a/index/zrpn.c b/index/zrpn.c index f5da395..5a6932f 100644 --- a/index/zrpn.c +++ b/index/zrpn.c @@ -1,4 +1,4 @@ -/* $Id: zrpn.c,v 1.214 2006-05-19 13:49:34 adam Exp $ +/* $Id: zrpn.c,v 1.215 2006-05-19 23:20:24 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -151,19 +151,19 @@ static void add_isam_p(const char *name, const char *info, if (p->termset) { const char *db; - int set, use; char term_tmp[IT_MAX_WORD]; int ord = 0; + 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+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, 0); - yaz_log(log_level_rpn, "grep: set=%d use=%d db=%s", set, use, db); + zebraExplain_lookup_ord(p->zh->reg->zei, + ord, 0 /* index_type */, &db, &index_name); + yaz_log(log_level_rpn, "grep: db=%s index=%s", db, index_name); resultSetAddTerm(p->zh, p->termset, name[len], db, - set, use, term_tmp); + index_name, term_tmp); } #endif (p->isam_p_indx)++; @@ -2548,9 +2548,6 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, int after; int base_no; char termz[IT_MAX_WORD+20]; - AttrType use; - int use_value; - const char *use_string = 0; struct scan_info *scan_info_array; ZebraScanEntry *glist; int ords[32], ord_no = 0; @@ -2603,9 +2600,6 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, yaz_log(YLOG_DEBUG, "position = %d, num = %d set=%d", pos, num, attributeset); - attr_init_APT(&use, zapt, 1); - use_value = attr_find_ex(&use, &attributeset, &use_string); - if (zebra_maps_attr(zh->reg->zebra_maps, zapt, &index_type, &search_type, rank_type, &complete_flag, &sort_flag)) { @@ -2613,10 +2607,6 @@ ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, zebra_setError(zh, YAZ_BIB1_UNSUPP_ATTRIBUTE_TYPE, 0); return ZEBRA_FAIL; } - yaz_log(YLOG_DEBUG, "use_value = %d", use_value); - - if (use_value == -1) - use_value = 1016; for (base_no = 0; base_no < num_bases && ord_no < 32; base_no++) { int ord; diff --git a/index/zsets.c b/index/zsets.c index e915543..5dd1eef 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -1,4 +1,4 @@ -/* $Id: zsets.c,v 1.103 2006-05-19 13:49:35 adam Exp $ +/* $Id: zsets.c,v 1.104 2006-05-19 23:20:24 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -40,8 +40,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA struct zebra_set_term_entry { int reg_type; char *db; - int set; - int use; + char *index_name; char *term; }; @@ -181,9 +180,9 @@ ZEBRA_RES resultSetAddRPN (ZebraHandle zh, NMEM m, Z_RPNQuery *rpn, return res; } -void resultSetAddTerm (ZebraHandle zh, ZebraSet s, int reg_type, - const char *db, int set, - int use, const char *term) +void resultSetAddTerm(ZebraHandle zh, ZebraSet s, int reg_type, + const char *db, const char *index_name, + const char *term) { assert(zh); /* compiler shut up */ if (!s->nmem) @@ -202,9 +201,8 @@ void resultSetAddTerm (ZebraHandle zh, ZebraSet s, int reg_type, { s->term_entries[s->hits].reg_type = reg_type; s->term_entries[s->hits].db = nmem_strdup (s->nmem, db); - s->term_entries[s->hits].set = set; - s->term_entries[s->hits].use = use; - s->term_entries[s->hits].term = nmem_strdup (s->nmem, term); + s->term_entries[s->hits].index_name = nmem_strdup(s->nmem, index_name); + s->term_entries[s->hits].term = nmem_strdup(s->nmem, term); } (s->hits)++; }