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