memcached: use facets in key for result set
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 30 Jan 2014 12:44:01 +0000 (13:44 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 30 Jan 2014 12:44:01 +0000 (13:44 +0100)
src/zoom-c.c
src/zoom-memcached.c
src/zoom-p.h
src/zoom-sru.c
src/zoom-z3950.c

index d302c32..383b344 100644 (file)
@@ -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);
     {
index 570345a..f35e7e6 100644 (file)
@@ -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
 }
 
index d09c54f..9de5509 100644 (file)
@@ -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 */
index 142051f..533c1df 100644 (file)
@@ -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)
index 824488e..a65b54f 100644 (file)
@@ -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);
         }