X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fclient.c;h=25b75d3dfc21317bea4fab6201354218c791c662;hb=6424430743ec2d233dfc8118313cfa4299432e2c;hp=9781abc0e16bb52aa21bf1950e32d114c424e729;hpb=d83ed24b0cf7522f931e689eefb6f7f6d74b8b28;p=pazpar2-moved-to-github.git diff --git a/src/client.c b/src/client.c index 9781abc..25b75d3 100644 --- a/src/client.c +++ b/src/client.c @@ -547,10 +547,10 @@ void client_search_response(struct client *cl) } else { - yaz_log(YLOG_DEBUG, "client_search_response: hits " ODR_INT_PRINTF, cl->hits); client_report_facets(cl, resultset); cl->record_offset = cl->startrecs; cl->hits = ZOOM_resultset_size(resultset); + yaz_log(YLOG_DEBUG, "client_search_response: hits " ODR_INT_PRINTF, cl->hits); if (cl->suggestions) client_suggestions_destroy(cl); cl->suggestions = client_suggestions_create(ZOOM_resultset_option_get(resultset, "suggestions")); @@ -589,8 +589,7 @@ static void client_record_ingest(struct client *cl) else if (ZOOM_record_error(rec, &msg, &addinfo, 0)) { yaz_log(YLOG_WARN, "Record error %s (%s): %s (rec #%d)", - msg, addinfo, client_get_id(cl), - cl->record_offset); + msg, addinfo, client_get_id(cl), cl->record_offset); } else { @@ -696,7 +695,7 @@ static void client_set_facets_request(struct client *cl, ZOOM_connection link) wrbuf_puts(w, ","); } } - yaz_log(YLOG_LOG, "using facets str: %s", wrbuf_cstr(w)); + yaz_log(YLOG_DEBUG, "using facets str: %s", wrbuf_cstr(w)); ZOOM_connection_option_set(link, "facets", wrbuf_len(w) ? wrbuf_cstr(w) : 0); wrbuf_destroy(w); @@ -763,11 +762,12 @@ void client_start_search(struct client *cl) int present_chunk = 20; // Default chunk size if (opt_present_chunk && strcmp(opt_present_chunk,"")) { present_chunk = atoi(opt_present_chunk); + yaz_log(YLOG_DEBUG, "Present chunk set to %d", present_chunk); } - assert(link); cl->diagnostic = 0; + cl->filtered = 0; if (extra_args && *extra_args) ZOOM_connection_option_set(link, "extraArgs", extra_args); @@ -804,11 +804,13 @@ void client_start_search(struct client *cl) /* A present_chunk less than 1 will disable chunking. */ if (present_chunk > 0 && cl->maxrecs > present_chunk) { sprintf(present_chunk_str, "%d", present_chunk); - ZOOM_connection_option_set(link, "presentChunk", opt_present_chunk); + ZOOM_connection_option_set(link, "presentChunk", present_chunk_str); + yaz_log(YLOG_DEBUG, "Present chunk set to %s", present_chunk_str); } - else + else { ZOOM_connection_option_set(link, "presentChunk", maxrecs_str); - + yaz_log(YLOG_DEBUG, "Present chunk set to %s (maxrecs)", maxrecs_str); + } sprintf(startrecs_str, "%d", cl->startrecs); ZOOM_connection_option_set(link, "start", startrecs_str); @@ -1090,7 +1092,7 @@ static int apply_limit(struct session_database *sdb, for (i = 0; (name = facet_limits_get(facet_limits, i, &value)); i++) { struct setting *s = 0; - + nmem_reset(nmem_tmp); for (s = sdb->settings[PZ_LIMITMAP]; s; s = s->next) { const char *p = strchr(s->name + 3, ':'); @@ -1146,7 +1148,6 @@ static int apply_limit(struct session_database *sdb, break; } } - nmem_reset(nmem_tmp); if (!s) { yaz_log(YLOG_WARN, "Target %s: limit %s used, but no limitmap defined", @@ -1326,6 +1327,16 @@ Odr_int client_get_hits(struct client *cl) return cl->hits; } +Odr_int client_get_approximation(struct client *cl) +{ + if (cl->record_offset > 0) { + Odr_int approx = ((10 * cl->hits * (cl->record_offset - cl->filtered)) / cl->record_offset + 5) /10; + yaz_log(YLOG_DEBUG, "%s: Approx: %lld * %d / %d = %lld ", client_get_id(cl), cl->hits, cl->record_offset - cl->filtered, cl->record_offset, approx); + return approx; + } + return cl->hits; +} + int client_get_num_records(struct client *cl) { return cl->record_offset;