From a91467db0bbbaefbaf64410b657a9439104997e0 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 30 Jan 2014 13:44:01 +0100 Subject: [PATCH] memcached: use facets in key for result set --- src/zoom-c.c | 5 ++++- src/zoom-memcached.c | 2 ++ src/zoom-p.h | 1 + src/zoom-sru.c | 7 +++---- src/zoom-z3950.c | 10 ++++++---- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/zoom-c.c b/src/zoom-c.c index d302c32..383b344 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -686,6 +686,7 @@ ZOOM_resultset ZOOM_resultset_create(void) r->connection = 0; r->databaseNames = 0; r->num_databaseNames = 0; + r->req_facets = 0; r->res_facets = 0; r->num_res_facets = 0; r->facets_names = 0; @@ -723,7 +724,7 @@ ZOOM_API(ZOOM_resultset) const char *cp; ZOOM_task task; int start, count; - const char *syntax, *elementSetName, *schema; + const char *syntax, *elementSetName, *schema, *facets; yaz_log(c->log_api, "%p ZOOM_connection_search set %p query %p", c, r, q); r->r_sort_spec = ZOOM_query_get_sortspec(q); r->query = q; @@ -731,6 +732,8 @@ ZOOM_API(ZOOM_resultset) r->options = ZOOM_options_create_with_parent(c->options); + r->req_facets = odr_strdup_null(r->odr, + ZOOM_options_get(r->options, "facets")); start = ZOOM_options_get_int(r->options, "start", 0); count = ZOOM_options_get_int(r->options, "count", 0); { diff --git a/src/zoom-memcached.c b/src/zoom-memcached.c index 570345a..f35e7e6 100644 --- a/src/zoom-memcached.c +++ b/src/zoom-memcached.c @@ -87,6 +87,8 @@ void ZOOM_memcached_resultset(ZOOM_resultset r, ZOOM_query q) wrbuf_destroy(w); } wrbuf_puts(r->mc_key, ";"); + if (r->req_facets) + wrbuf_puts(r->mc_key, r->req_facets); #endif } diff --git a/src/zoom-p.h b/src/zoom-p.h index d09c54f..9de5509 100644 --- a/src/zoom-p.h +++ b/src/zoom-p.h @@ -139,6 +139,7 @@ struct ZOOM_resultset_p { struct WRBUF_shptr *record_wrbuf; #endif ZOOM_resultset next; + char *req_facets; ZOOM_facet_field *res_facets; int num_res_facets; char **facets_names; /* redundant. For ZOOM_resultset_facets_names only */ diff --git a/src/zoom-sru.c b/src/zoom-sru.c index 142051f..533c1df 100644 --- a/src/zoom-sru.c +++ b/src/zoom-sru.c @@ -145,7 +145,6 @@ zoom_ret ZOOM_connection_srw_send_scan(ZOOM_connection c) #if YAZ_HAVE_XML2 zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c) { - const char *facets = 0; int i; int *start, *count; ZOOM_resultset resultset = 0; @@ -170,9 +169,9 @@ zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c) ZOOM_options_set(resultset->options, "setname", resultset->setname); start = &c->tasks->u.search.start; count = &c->tasks->u.search.count; - facets = ZOOM_options_get(resultset->options, "facets"); - if (facets) - facet_list = yaz_pqf_parse_facet_list(c->odr_out, facets); + if (resultset->req_facets) + facet_list = yaz_pqf_parse_facet_list(c->odr_out, + resultset->req_facets); schema = c->tasks->u.search.schema; if (resultset->live_set) diff --git a/src/zoom-z3950.c b/src/zoom-z3950.c index 824488e..a65b54f 100644 --- a/src/zoom-z3950.c +++ b/src/zoom-z3950.c @@ -668,10 +668,12 @@ static zoom_ret Z3950_send_search(ZOOM_connection c) if (!mediumSetElementSetName) mediumSetElementSetName = elementSetName; - facets = ZOOM_options_get(r->options, "facets"); - if (facets) { - Z_FacetList *facet_list = yaz_pqf_parse_facet_list(c->odr_out, facets); - if (facet_list) { + if (r->req_facets) + { + Z_FacetList *facet_list = + yaz_pqf_parse_facet_list(c->odr_out, r->req_facets); + if (facet_list) + { Z_OtherInformation **oi = &search_req->additionalSearchInfo; yaz_oi_set_facetlist(oi, c->odr_out, facet_list); } -- 1.7.10.4