From cd02e9c5558d2f0db2ab83fcad810a6522fd2319 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss - Indexdata Date: Thu, 2 Oct 2008 13:58:08 +0200 Subject: [PATCH] Fixed addinfo passing. Index type 's' is sort for absent index rules. --- include/zebramap.h | 3 +++ index/index.h | 2 +- index/retrieve.c | 21 +++++---------------- index/zebraapi.c | 6 +++++- util/zebramap.c | 6 ++++++ 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/include/zebramap.h b/include/zebramap.h index eb4e4fd..2a943b6 100644 --- a/include/zebramap.h +++ b/include/zebramap.h @@ -35,6 +35,9 @@ YAZ_EXPORT ZEBRA_RES zebra_maps_read_file(zebra_maps_t zms, const char *fname); YAZ_EXPORT +void zebra_maps_define_default_sort(zebra_maps_t zms); + +YAZ_EXPORT void zebra_maps_close(zebra_maps_t zm); YAZ_EXPORT diff --git a/index/index.h b/index/index.h index da9c042..3ab3d02 100644 --- a/index/index.h +++ b/index/index.h @@ -312,7 +312,7 @@ int zebra_record_fetch(ZebraHandle zh, const char *setname, const Odr_oid *input_format, Z_RecordComposition *comp, const Odr_oid **output_format, char **rec_bufp, int *rec_lenp, char **basenamep, - char **addinfo); + WRBUF addinfo_w); void extract_get_fname_tmp(ZebraHandle zh, char *fname, int no); diff --git a/index/retrieve.c b/index/retrieve.c index 39bbca1..4ff8586 100644 --- a/index/retrieve.c +++ b/index/retrieve.c @@ -1182,7 +1182,7 @@ int zebra_record_fetch(ZebraHandle zh, const char *setname, const Odr_oid *input_format, Z_RecordComposition *comp, const Odr_oid **output_format, char **rec_bufp, int *rec_lenp, char **basenamep, - char **addinfo) + WRBUF addinfo_w) { Record rec; char *fname, *file_type, *basename; @@ -1202,7 +1202,6 @@ int zebra_record_fetch(ZebraHandle zh, const char *setname, sysno = sysnos[0]; *basenamep = 0; - *addinfo = 0; elemsetname = yaz_get_esn(comp); fetch_info.zh = zh; @@ -1215,7 +1214,6 @@ int zebra_record_fetch(ZebraHandle zh, const char *setname, if (elemsetname && 0 == strncmp(elemsetname, "zebra::", 7)) { WRBUF result = wrbuf_alloc(); - WRBUF addinfo_w = wrbuf_alloc(); int r = zebra_special_fetch(&fetch_info, elemsetname + 7, input_format, output_format, result, addinfo_w); @@ -1224,13 +1222,7 @@ int zebra_record_fetch(ZebraHandle zh, const char *setname, *rec_bufp = odr_strdup(odr, wrbuf_cstr(result)); *rec_lenp = wrbuf_len(result); } - else - { - if (wrbuf_len(addinfo_w)) - *addinfo = odr_strdup(odr, wrbuf_cstr(addinfo_w)); - } wrbuf_destroy(result); - wrbuf_destroy(addinfo_w); return r; } @@ -1284,12 +1276,8 @@ int zebra_record_fetch(ZebraHandle zh, const char *setname, if (!(rt = recType_byName(zh->reg->recTypes, zh->res, file_type, &clientData))) { - char addinfo_str[100]; - - sprintf(addinfo_str, "Could not handle record type %.40s", - file_type); - - *addinfo = odr_strdup(odr, addinfo_str); + wrbuf_printf(addinfo_w, "Could not handle record type %.40s", + file_type); return_code = YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS; } else @@ -1300,7 +1288,8 @@ int zebra_record_fetch(ZebraHandle zh, const char *setname, *output_format = retrieveCtrl.output_format; *rec_bufp = (char *) retrieveCtrl.rec_buf; *rec_lenp = retrieveCtrl.rec_len; - *addinfo = retrieveCtrl.addinfo; + if (retrieveCtrl.addinfo) + wrbuf_puts(addinfo_w, retrieveCtrl.addinfo); } stream.destroy(&stream); diff --git a/index/zebraapi.c b/index/zebraapi.c index f656af4..202f7bb 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -423,6 +423,10 @@ struct zebra_register *zebra_register_open(ZebraService zs, const char *name, if (zebra_maps_read_file(reg->zebra_maps, index_fname) != ZEBRA_OK) ret = ZEBRA_FAIL; } + else + { + zebra_maps_define_default_sort(reg->zebra_maps); + } } if (!(reg->records = rec_open(reg->bfs, rw, record_compression))) @@ -1132,7 +1136,7 @@ ZEBRA_RES zebra_records_retrieve(ZebraHandle zh, ODR stream, recs[i].len = 0; recs[i].buf = 0; recs[i].base = 0; - recs[i].sysno = poset[i].term; + recs[i].sysno = poset[i].sysno; if (poset[i].term) { recs[i].format = yaz_oid_recsyn_sutrs; diff --git a/util/zebramap.c b/util/zebramap.c index c6f3da9..ba301ab 100644 --- a/util/zebramap.c +++ b/util/zebramap.c @@ -342,6 +342,12 @@ zebra_maps_t zebra_maps_open(Res res, const char *base_path, return zms; } +void zebra_maps_define_default_sort(zebra_maps_t zms) +{ + zebra_map_t zm = zebra_add_map(zms, "s", ZEBRA_MAP_TYPE_SORT); + zm->u.sort.entry_size = 80; +} + zebra_map_t zebra_map_get(zebra_maps_t zms, const char *id) { zebra_map_t zm; -- 1.7.10.4