X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Freclists.c;h=e96ee929cfcf687a445095ecfa850bf2eec3acdf;hb=64dccf5757a22cedd3c21ca834e3e02f39dd0504;hp=817c1339f988ff26b54be4b4ddc756b976cce81d;hpb=d8c3965cc2bb222a012481819c47db36a8a5905b;p=pazpar2-moved-to-github.git diff --git a/src/reclists.c b/src/reclists.c index 817c133..e96ee92 100644 --- a/src/reclists.c +++ b/src/reclists.c @@ -1,5 +1,5 @@ /* This file is part of Pazpar2. - Copyright (C) 2006-2013 Index Data + Copyright (C) Index Data Pazpar2 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -123,7 +123,11 @@ struct reclist_sortparms *reclist_parse_sortparms(NMEM nmem, const char *parms, { type = Metadata_type_position; } - else + else if (!strcmp(parm, "retrieval")) + { + type = Metadata_type_retrieval; + } + else if (service) { for (i = 0; i < service->num_sortkeys; i++) { @@ -142,6 +146,12 @@ struct reclist_sortparms *reclist_parse_sortparms(NMEM nmem, const char *parms, } offset = i; } + else + { + yaz_log(YLOG_FATAL, "Sortkey not defined in service: %s", + parm); + return 0; + } } new = *rp = nmem_malloc(nmem, sizeof(struct reclist_sortparms)); new->next = 0; @@ -234,6 +244,9 @@ static int reclist_cmp(const void *p1, const void *p2) else res = 0; break; + case Metadata_type_retrieval: + res = r1->retrieval_position - r2->retrieval_position; + break; } if (res && !s->increasing) res *= -1; @@ -330,16 +343,19 @@ struct record_cluster *reclist_read_record(struct reclist *l) void reclist_enter(struct reclist *l) { yaz_mutex_enter(l->mutex); - if (l) - l->sorted_ptr = l->sorted_list; + l->sorted_ptr = l->sorted_list; } void reclist_leave(struct reclist *l) { yaz_mutex_leave(l->mutex); - if (l) - l->sorted_ptr = l->sorted_list; + l->sorted_ptr = l->sorted_list; +} + +void reclist_rewind(struct reclist *l) +{ + l->sorted_ptr = l->sorted_list; } @@ -438,6 +454,7 @@ static struct record_cluster *new_cluster( cluster = nmem_malloc(l->nmem, sizeof(*cluster)); record->next = 0; + cluster->retrieval_position = l->num_records; cluster->records = record; cluster->merge_keys = 0; append_merge_keys(&cluster->merge_keys, merge_keys, l->nmem);