more records constructor work, no yet finished
[pazpar2-moved-to-github.git] / src / record.h
1 /* $Id: record.h,v 1.3 2007-04-23 08:48:50 marc Exp $
2    Copyright (c) 2006-2007, Index Data.
3
4 This file is part of Pazpar2.
5
6 Pazpar2 is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
9 version.
10
11 Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Pazpar2; see the file LICENSE.  If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA.
20  */
21
22 #ifndef RECORD_H
23 #define RECORD_H
24
25
26 struct record;
27 struct client;
28 struct conf_service;
29
30 union data_types {
31     char *text;
32     struct {
33         int min;
34         int max;
35     } number;
36 };
37
38 struct record_metadata {
39     union data_types data;
40     // next item of this name
41     struct record_metadata *next; 
42 };
43
44 struct record {
45     struct client *client;
46     // Array mirrors list of metadata fields in config
47     struct record_metadata **metadata; 
48     // Array mirrors list of sortkey fields in config
49     union data_types **sortkeys;
50     // Next in cluster of merged records       
51     struct record *next;  
52 };
53
54
55 struct record * record_create(NMEM nmem, int num_metadata, int num_sortkeys);
56
57 struct record_metadata * record_metadata_insert(NMEM nmem, 
58                                                 struct record_metadata ** rmd,
59                                                 union data_types data);
60
61
62 struct record_metadata * record_add_metadata_field_id(NMEM nmem, 
63                                                       struct record * record,
64                                                       int field_id, 
65                                                       union data_types data);
66
67
68 struct record_metadata * record_add_metadata(NMEM nmem, 
69                                              struct record * record,
70                                              struct conf_service * service,
71                                              const char * name,
72                                              union data_types data);
73
74
75 struct record_cluster
76 {
77     // Array mirrors list of metadata fields in config
78     struct record_metadata **metadata; 
79     union data_types **sortkeys;
80     char *merge_key;
81     int relevance;
82     int *term_frequency_vec;
83     // Set-specific ID for this record
84     int recid; 
85     struct record *records;
86 };
87
88
89 #endif // RECORD_H
90
91 /*
92  * Local variables:
93  * c-basic-offset: 4
94  * indent-tabs-mode: nil
95  * End:
96  * vim: shiftwidth=4 tabstop=8 expandtab
97  */