4ccef8f6125da6530739b86e7bbd956684a7e282
[pazpar2-moved-to-github.git] / src / reclists.h
1 /* This file is part of Pazpar2.
2    Copyright (C) 2006-2008 Index Data
3
4 Pazpar2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
18 */
19
20 #ifndef RECLISTS_H
21 #define RECLISTS_H
22
23 #include "config.h"
24 #include "record.h"
25
26 struct reclist
27 {
28     struct reclist_bucket **hashtable;
29     int hashtable_size;
30     int hashmask;
31
32     struct record_cluster **flatlist;
33     int flatlist_size;
34     int num_records;
35     int pointer;
36
37     NMEM nmem;
38 };
39
40 // This is a recipe for sorting. First node in list has highest priority
41 struct reclist_sortparms
42 {
43     int offset;
44     enum conf_sortkey_type type;
45     int increasing;
46     struct reclist_sortparms *next;
47 };
48
49 struct reclist_sortparms * 
50 reclist_sortparms_insert_field_id(NMEM nmem,
51                                   struct reclist_sortparms **sortparms,
52                                   int field_id ,
53                                   enum conf_sortkey_type type,
54                                   int increasing);
55
56
57 struct reclist_sortparms * 
58 reclist_sortparms_insert(NMEM nmem, 
59                          struct reclist_sortparms **sortparms,
60                          struct conf_service * service,
61                          const char * name,
62                          int increasing);
63
64
65 struct reclist *reclist_create(NMEM, int numrecs);
66 struct record_cluster *reclist_insert( struct reclist *tl,
67                                        struct conf_service *service,
68                                        struct record  *record,
69                                        char *merge_key, int *total);
70 void reclist_sort(struct reclist *l, struct reclist_sortparms *parms);
71 struct record_cluster *reclist_read_record(struct reclist *l);
72 void reclist_rewind(struct reclist *l);
73 struct reclist_sortparms *reclist_parse_sortparms(NMEM nmem, const char *parms);
74
75 #endif
76
77 /*
78  * Local variables:
79  * c-basic-offset: 4
80  * indent-tabs-mode: nil
81  * End:
82  * vim: shiftwidth=4 tabstop=8 expandtab
83  */