From e7b239d4c86d0bd72517054aed2887ba246de50f Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 10 Oct 2011 16:18:24 +0200 Subject: [PATCH] Refactor how total hits are calculated This is to ensure it doesn't get increased when we extend a search. --- src/client.c | 8 +------- src/session.c | 13 +++++++++---- src/session.h | 1 - 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/client.c b/src/client.c index bf3e04c..05f6541 100644 --- a/src/client.c +++ b/src/client.c @@ -505,7 +505,6 @@ void client_check_preferred_watch(struct client *cl) void client_search_response(struct client *cl) { struct connection *co = cl->connection; - struct session *se = cl->session; ZOOM_connection link = connection_get_link(co); ZOOM_resultset resultset = cl->resultset; @@ -525,11 +524,6 @@ void client_search_response(struct client *cl) client_report_facets(cl, resultset); cl->record_offset = cl->startrecs; cl->hits = ZOOM_resultset_size(resultset); - if (se) { - se->total_hits += cl->hits; - yaz_log(YLOG_DEBUG, "client_search_response: total hits " - ODR_INT_PRINTF, se->total_hits); - } } } @@ -685,7 +679,6 @@ void client_start_search(struct client *cl, const char *sort_strategy, assert(link); - cl->hits = -1; cl->record_offset = 0; cl->diagnostic = 0; @@ -1037,6 +1030,7 @@ int client_parse_query(struct client *cl, const char *query, if (!ccl_map) return -1; + cl->hits = -1; w_ccl = wrbuf_alloc(); wrbuf_puts(w_ccl, query); diff --git a/src/session.c b/src/session.c index 684cd8e..d18d6aa 100644 --- a/src/session.c +++ b/src/session.c @@ -669,7 +669,7 @@ enum pazpar2_error_code search(struct session *se, se->reclist = 0; relevance_destroy(&se->relevance); nmem_reset(se->nmem); - se->total_records = se->total_hits = se->total_merged = 0; + se->total_records = se->total_merged = 0; se->num_termlists = 0; live_channels = select_targets(se, filter); if (!live_channels) @@ -867,7 +867,6 @@ struct session *new_session(NMEM nmem, struct conf_service *service, session_log(session, YLOG_DEBUG, "New"); session->service = service; session->relevance = 0; - session->total_hits = 0; session->total_records = 0; session->number_of_warnings_unknown_elements = 0; session->number_of_warnings_unknown_metadata = 0; @@ -1128,6 +1127,8 @@ struct record_cluster **show_range_start(struct session *se, } else { + struct client_list *l; + for (spp = sp; spp; spp = spp->next) if (spp->type == Metadata_sortkey_relevance) { @@ -1138,7 +1139,10 @@ struct record_cluster **show_range_start(struct session *se, reclist_enter(se->reclist); *total = reclist_get_num_records(se->reclist); - *sumhits = se->total_hits; + + *sumhits = 0; + for (l = se->clients; l; l = l->next) + *sumhits += client_get_hits(l->client); for (i = 0; i < start; i++) if (!reclist_read_record(se->reclist)) @@ -1181,11 +1185,13 @@ void statistics(struct session *se, struct statistics *stat) int count = 0; memset(stat, 0, sizeof(*stat)); + stat->num_hits = 0; for (l = se->clients; l; l = l->next) { struct client *cl = l->client; if (!client_get_connection(cl)) stat->num_no_connection++; + stat->num_hits += client_get_hits(cl); switch (client_get_state(cl)) { case Client_Connecting: stat->num_connecting++; break; @@ -1197,7 +1203,6 @@ void statistics(struct session *se, struct statistics *stat) } count++; } - stat->num_hits = se->total_hits; stat->num_records = se->total_records; stat->num_clients = count; diff --git a/src/session.h b/src/session.h index a815446..d958eaf 100644 --- a/src/session.h +++ b/src/session.h @@ -107,7 +107,6 @@ struct session { struct relevance *relevance; struct reclist *reclist; struct session_watchentry watchlist[SESSION_WATCH_MAX + 1]; - Odr_int total_hits; int total_records; int total_merged; int number_of_warnings_unknown_elements; -- 1.7.10.4