X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fclient.c;h=9e52b0a9cb637f964eed6de3c9476b08fcf82a4a;hb=a308a61764c5a8da2d386827d8574c45618d63de;hp=26dd6efa93c0ec7c320a8698159508f8a64f517c;hpb=a1076b95713b6417eaf4083631ba34a7532bd6dd;p=pazpar2-moved-to-github.git diff --git a/src/client.c b/src/client.c index 26dd6ef..9e52b0a 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 { @@ -758,13 +757,13 @@ void client_start_search(struct client *cl) const char *opt_preferred = session_setting_oneval(sdb, PZ_PREFERRED); const char *extra_args = session_setting_oneval(sdb, PZ_EXTRA_ARGS); const char *opt_present_chunk = session_setting_oneval(sdb, PZ_PRESENT_CHUNK); - /* Default present chunk */ - int present_chunk = 20; + ZOOM_query q; + char maxrecs_str[24], startrecs_str[24], present_chunk_str[24]; + 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); } - char maxrecs_str[24], startrecs_str[24], present_chunk_str[24]; - ZOOM_query q; assert(link); @@ -805,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); @@ -1327,6 +1328,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_LOG, "%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;