Updated footer comment
[pazpar2-moved-to-github.git] / src / record.h
1 /* This file is part of Pazpar2.
2    Copyright (C) 2006-2009 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 RECORD_H
21 #define RECORD_H
22
23
24 struct record;
25 struct client;
26 struct conf_service;
27
28 union data_types {
29     struct {
30         const char *disp;
31         const char *sort;
32     } text;
33     struct {
34         int min;
35         int max;
36     } number;
37 };
38
39
40
41 struct record_metadata {
42     union data_types data;
43     // next item of this name
44     struct record_metadata *next; 
45 };
46
47 union data_types * data_types_assign(NMEM nmem, 
48                                      union data_types ** data1, 
49                                      union data_types data2);
50
51
52 struct record {
53     struct client *client;
54     // Array mirrors list of metadata fields in config
55     struct record_metadata **metadata; 
56     // Array mirrors list of sortkey fields in config
57     union data_types **sortkeys;
58     // Next in cluster of merged records       
59     struct record *next;  
60     // client result set position;
61     int position;
62 };
63
64
65 struct record * record_create(NMEM nmem, int num_metadata, int num_sortkeys,
66                               struct client *client, int position);
67
68 struct record_metadata * record_metadata_create(NMEM nmem);
69
70 struct record_metadata * record_metadata_insert(NMEM nmem, 
71                                                 struct record_metadata ** rmd,
72                                                 union data_types data);
73
74
75 struct record_metadata * record_add_metadata_field_id(NMEM nmem, 
76                                                       struct record * record,
77                                                       int field_id, 
78                                                       union data_types data);
79
80
81 struct record_metadata * record_add_metadata(NMEM nmem, 
82                                              struct record * record,
83                                              struct conf_service * service,
84                                              const char * name,
85                                              union data_types data);
86
87
88 union data_types * record_assign_sortkey_field_id(NMEM nmem, 
89                                                struct record * record,
90                                                int field_id, 
91                                                union data_types data);
92
93
94 union data_types * record_assign_sortkey(NMEM nmem, 
95                                       struct record * record,
96                                       struct conf_service * service,
97                                       const char * name,
98                                       union data_types data);
99
100
101
102
103 struct record_cluster
104 {
105     // Array mirrors list of metadata fields in config
106     struct record_metadata **metadata; 
107     union data_types **sortkeys;
108     char *merge_key;
109     int relevance;
110     int *term_frequency_vec;
111     // Set-specific ID for this record
112     char *recid;
113     struct record *records;
114 };
115
116
117
118
119 #endif // RECORD_H
120
121 /*
122  * Local variables:
123  * c-basic-offset: 4
124  * c-file-style: "Stroustrup"
125  * indent-tabs-mode: nil
126  * End:
127  * vim: shiftwidth=4 tabstop=8 expandtab
128  */
129