X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fsession.c;h=d8567ee18235c495cfdee2fff2feedcfd9c526ec;hb=73740a3422bf7d8e87e555f4b6e744afe399100c;hp=148f462961e107992e7510b392441ce69e9a1a4d;hpb=0198d9a410e2664e29f8fa526cf9bcf8f5bea89a;p=pazpar2-moved-to-github.git diff --git a/src/session.c b/src/session.c index 148f462..d8567ee 100644 --- a/src/session.c +++ b/src/session.c @@ -653,7 +653,7 @@ static void session_sort_unlocked(struct session *se, struct reclist_sortparms * int type = sp->type; int clients_research = 0; - yaz_log(YLOG_LOG, "session_sort field=%s increasing=%d type=%d", field, increasing, type); + yaz_log(YLOG_DEBUG, "session_sort field=%s increasing=%d type=%d", field, increasing, type); /* see if we already have sorted for this criteria */ for (sr = se->sorted_results; sr; sr = sr->next) { @@ -734,7 +734,6 @@ enum pazpar2_error_code session_search(struct session *se, int no_failed_query = 0; int no_failed_limit = 0; struct client_list *l, *l0; - int same_sort_order = 0; session_log(se, YLOG_DEBUG, "Search"); @@ -749,10 +748,6 @@ enum pazpar2_error_code session_search(struct session *se, session_enter(se, "session_search"); se->settings_modified = 0; - if (se->sorted_results) { - if (!reclist_sortparms_cmp(se->sorted_results, sp)) - same_sort_order = 1; - } session_clear_set(se, sp); relevance_destroy(&se->relevance); @@ -1269,7 +1264,9 @@ int session_fetch_more(struct session *se) struct record_cluster **show_range_start(struct session *se, struct reclist_sortparms *sp, int start, int *num, int *total, - Odr_int *sumhits, Odr_int *approx_hits) + Odr_int *sumhits, Odr_int *approx_hits, + void (*show_records_ready)(void *data), + struct http_channel *chan) { struct record_cluster **recs = 0; struct reclist_sortparms *spp; @@ -1301,13 +1298,24 @@ struct record_cluster **show_range_start(struct session *se, reclist_enter(se->reclist); *total = reclist_get_num_records(se->reclist); + for (l = se->clients_active; l; l = l->next) + client_update_show_stat(l->client, 0); + for (i = 0; i < start; i++) - if (!reclist_read_record(se->reclist)) + { + struct record_cluster *r = reclist_read_record(se->reclist); + if (!r) { *num = 0; break; } - + else + { + struct record *rec = r->records; + for (;rec; rec = rec->next) + client_update_show_stat(rec->client, 1); + } + } if (*num > 0) recs = nmem_malloc(se->nmem, *num * sizeof(struct record_cluster *)); @@ -1319,7 +1327,13 @@ struct record_cluster **show_range_start(struct session *se, *num = i; break; } - recs[i] = r; + else + { + struct record *rec = r->records; + for (;rec; rec = rec->next) + client_update_show_stat(rec->client, 1); + recs[i] = r; + } } reclist_leave(se->reclist); #if USE_TIMING @@ -1329,6 +1343,25 @@ struct record_cluster **show_range_start(struct session *se, yaz_timing_get_sys(t)); yaz_timing_destroy(&t); #endif + + if (!session_fetch_more(se)) + session_log(se, YLOG_LOG, "can not fetch more"); + else + { + show_range_stop(se, recs); + session_log(se, YLOG_LOG, "fetching more in progress"); + if (session_set_watch(se, SESSION_WATCH_SHOW, + show_records_ready, chan, chan)) + { + session_log(se, YLOG_WARN, "Ignoring show block"); + session_enter(se, "show_range_start"); + } + else + { + session_log(se, YLOG_LOG, "session watch OK"); + return 0; + } + } return recs; } @@ -1377,10 +1410,11 @@ static struct record_metadata *record_metadata_init( { if (attr->children && attr->children->content) { - if (strcmp((const char *) attr->name, "type")) - { /* skip the "type" attribute.. Its value is already part of - the element in output (md-%s) and so repeating it here - is redundant */ + if (strcmp((const char *) attr->name, "type") + && strcmp((const char *) attr->name, "empty")) + { /* skip the "type" + "empty" attribute.. + The "Type" is already part of the element in output + (md-%s) and so repeating it here is redundant */ *attrp = nmem_malloc(nmem, sizeof(**attrp)); (*attrp)->name = nmem_strdup(nmem, (const char *) attr->name); @@ -1832,10 +1866,17 @@ static int ingest_to_cluster(struct client *cl, type = xmlGetProp(n, (xmlChar *) "type"); value = xmlNodeListGetString(xdoc, n->children, 1); - - if (!type || !value || !*value) + if (!type) continue; - + if (!value || !*value) + { + xmlChar *empty = xmlGetProp(n, (xmlChar *) "empty"); + if (!empty) + continue; + if (value) + xmlFree(value); + value = empty; + } md_field_id = conf_service_metadata_field_id(service, (const char *) type); if (md_field_id < 0) @@ -1880,7 +1921,7 @@ static int ingest_to_cluster(struct client *cl, cluster = reclist_insert(se->reclist, service, record, mergekey_norm, &se->total_merged); if (!cluster) - return -1; + return 0; // complete match with existing record { const char *use_term_factor_str =