X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Freclists.c;h=245d06187192dd1f46473169dc2046f6ab09ab99;hb=a3f57f20fb1ade51cc5a99aafcc16af1a1f5b0c8;hp=103eefd38e8bf00dd965517f565b32993ebf1941;hpb=9db0457fa07df43928fc8fbade13593eb6c9b534;p=pazpar2-moved-to-github.git diff --git a/src/reclists.c b/src/reclists.c index 103eefd..245d061 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,6 +123,10 @@ struct reclist_sortparms *reclist_parse_sortparms(NMEM nmem, const char *parms, { type = Metadata_type_position; } + else if (!strcmp(parm, "retrieval")) + { + type = Metadata_type_retrieval; + } else { for (i = 0; i < service->num_sortkeys; i++) @@ -234,6 +238,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,22 +337,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) { - if (l) - l->sorted_ptr = l->sorted_list; + l->sorted_ptr = l->sorted_list; } @@ -444,6 +448,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);