Preserve pz:metadata attributes
[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 struct record_metadata_attr {
41     char *name;
42     char *value;
43     struct record_metadata_attr *next;
44 };
45
46 struct record_metadata {
47     union data_types data;
48     // next item of this name
49     struct record_metadata *next; 
50     struct record_metadata_attr *attributes;
51 };
52
53 union data_types * data_types_assign(NMEM nmem, 
54                                      union data_types ** data1, 
55                                      union data_types data2);
56
57
58 struct record {
59     struct client *client;
60     // Array mirrors list of metadata fields in config
61     struct record_metadata **metadata; 
62     // Array mirrors list of sortkey fields in config
63     union data_types **sortkeys;
64     // Next in cluster of merged records       
65     struct record *next;  
66     // client result set position;
67     int position;
68 };
69
70
71 struct record * record_create(NMEM nmem, int num_metadata, int num_sortkeys,
72                               struct client *client, int position);
73
74 struct record_metadata * record_metadata_create(NMEM nmem);
75
76 struct record_metadata * record_metadata_insert(NMEM nmem, 
77                                                 struct record_metadata ** rmd,
78                                                 union data_types data);
79
80
81 struct record_metadata * record_add_metadata_field_id(NMEM nmem, 
82                                                       struct record * record,
83                                                       int field_id, 
84                                                       union data_types data);
85
86
87 struct record_metadata * record_add_metadata(NMEM nmem, 
88                                              struct record * record,
89                                              struct conf_service * service,
90                                              const char * name,
91                                              union data_types data);
92
93
94 union data_types * record_assign_sortkey_field_id(NMEM nmem, 
95                                                struct record * record,
96                                                int field_id, 
97                                                union data_types data);
98
99
100 union data_types * record_assign_sortkey(NMEM nmem, 
101                                       struct record * record,
102                                       struct conf_service * service,
103                                       const char * name,
104                                       union data_types data);
105
106
107
108
109 struct record_cluster
110 {
111     // Array mirrors list of metadata fields in config
112     struct record_metadata **metadata; 
113     union data_types **sortkeys;
114     char *merge_key;
115     int relevance;
116     int *term_frequency_vec;
117     // Set-specific ID for this record
118     char *recid;
119     struct record *records;
120 };
121
122
123
124
125 #endif // RECORD_H
126
127 /*
128  * Local variables:
129  * c-basic-offset: 4
130  * c-file-style: "Stroustrup"
131  * indent-tabs-mode: nil
132  * End:
133  * vim: shiftwidth=4 tabstop=8 expandtab
134  */
135