record parameter checksum
[pazpar2-moved-to-github.git] / src / record.h
1 /* This file is part of Pazpar2.
2    Copyright (C) 2006-2012 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     // checksum
68     unsigned checksum;
69 };
70
71
72 struct record * record_create(NMEM nmem, int num_metadata, int num_sortkeys,
73                               struct client *client, int position);
74
75 struct record_metadata * record_metadata_create(NMEM nmem);
76
77 int record_compare(struct record *r1, struct record *r2, struct conf_service *service);
78
79 struct record_cluster
80 {
81     // Array mirrors list of metadata fields in config
82     struct record_metadata **metadata; 
83     union data_types **sortkeys;
84     char *merge_key;
85     int relevance_score;
86     int *term_frequency_vec;
87     int *term_frequency_vec_tmp;
88     float *term_frequency_vecf;
89     // Set-specific ID for this record
90     char *recid;
91     struct record *records;
92 };
93
94 #endif // RECORD_H
95
96 /*
97  * Local variables:
98  * c-basic-offset: 4
99  * c-file-style: "Stroustrup"
100  * indent-tabs-mode: nil
101  * End:
102  * vim: shiftwidth=4 tabstop=8 expandtab
103  */
104