Better logging for scan service.
[idzebra-moved-to-github.git] / index / zserver.h
1 /*
2  * Copyright (C) 1994-1998, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: zserver.h,v $
7  * Revision 1.28  1998-01-29 13:40:11  adam
8  * Better logging for scan service.
9  *
10  * Revision 1.27  1997/10/27 14:33:06  adam
11  * Moved towards generic character mapping depending on "structure"
12  * field in abstract syntax file. Fixed a few memory leaks. Fixed
13  * bug with negative integers when doing searches with relational
14  * operators.
15  *
16  * Revision 1.26  1997/09/29 12:41:35  adam
17  * Fixed bug regarding USE_TIMES var.
18  *
19  * Revision 1.25  1997/09/29 09:08:36  adam
20  * Revised locking system to be thread safe for the server.
21  *
22  * Revision 1.24  1997/09/17 12:19:19  adam
23  * Zebra version corresponds to YAZ version 1.4.
24  * Changed Zebra server so that it doesn't depend on global common_resource.
25  *
26  * Revision 1.23  1996/12/23 15:30:46  adam
27  * Work on truncation.
28  * Bug fix: result sets weren't deleted after server shut down.
29  *
30  * Revision 1.22  1996/11/04 14:07:49  adam
31  * Moved truncation code to trunc.c.
32  *
33  * Revision 1.21  1996/10/29 14:09:58  adam
34  * Use of cisam system - enabled if setting isamc is 1.
35  *
36  * Revision 1.20  1996/06/04 10:19:02  adam
37  * Minor changes - removed include of ctype.h.
38  *
39  * Revision 1.19  1996/05/14  11:34:01  adam
40  * Scan support in multiple registers/databases.
41  *
42  * Revision 1.18  1996/05/14  06:16:50  adam
43  * Compact use/set bytes used in search service.
44  *
45  * Revision 1.17  1995/12/08 16:22:57  adam
46  * Work on update while servers are running. Three lock files introduced.
47  * The servers reload their registers when necessary, but they don't
48  * reestablish result sets yet.
49  *
50  * Revision 1.16  1995/12/07  17:38:48  adam
51  * Work locking mechanisms for concurrent updates/commit.
52  *
53  * Revision 1.15  1995/11/21  15:29:13  adam
54  * Config file 'base' read by default by both indexer and server.
55  *
56  * Revision 1.14  1995/11/16  17:00:57  adam
57  * Better logging of rpn query.
58  *
59  * Revision 1.13  1995/11/16  15:34:56  adam
60  * Uses new record management system in both indexer and server.
61  *
62  * Revision 1.12  1995/10/27  14:00:12  adam
63  * Implemented detection of database availability.
64  *
65  * Revision 1.11  1995/10/17  18:02:12  adam
66  * New feature: databases. Implemented as prefix to words in dictionary.
67  *
68  * Revision 1.10  1995/10/09  16:18:38  adam
69  * Function dict_lookup_grep got extra client data parameter.
70  *
71  * Revision 1.9  1995/10/06  14:38:01  adam
72  * New result set method: r_score.
73  * Local no (sysno) and score is transferred to retrieveCtrl.
74  *
75  * Revision 1.8  1995/10/06  13:52:06  adam
76  * Bug fixes. Handler may abort further scanning.
77  *
78  * Revision 1.7  1995/10/06  10:43:57  adam
79  * Scan added. 'occurrences' in scan entries not set yet.
80  *
81  * Revision 1.6  1995/09/28  09:19:48  adam
82  * xfree/xmalloc used everywhere.
83  * Extract/retrieve method seems to work for text records.
84  *
85  * Revision 1.5  1995/09/27  16:17:32  adam
86  * More work on retrieve.
87  *
88  * Revision 1.4  1995/09/14  11:53:28  adam
89  * First work on regular expressions/truncations.
90  *
91  * Revision 1.3  1995/09/08  08:53:23  adam
92  * Record buffer maintained in server_info.
93  *
94  * Revision 1.2  1995/09/06  16:11:19  adam
95  * Option: only one word key per file.
96  *
97  * Revision 1.1  1995/09/05  15:28:40  adam
98  * More work on search engine.
99  *
100  */
101
102
103 #ifndef USE_TIMES
104 #ifdef __linux__
105 #define USE_TIMES 1
106 #else
107 #define USE_TIMES 0
108 #endif
109 #endif
110
111 #if USE_TIMES
112 #include <sys/times.h>
113 #endif
114
115 #include <backend.h>
116 #include <rset.h>
117
118 #include "index.h"
119 #include "zinfo.h"
120
121 typedef struct {
122     int sysno;
123     int score;
124 } ZServerSetSysno;
125
126 typedef struct ZServerSet_ {
127     char *name;
128     RSET rset;
129     int size;
130     struct ZServerSet_ *next;
131 } ZServerSet;
132    
133 typedef struct {
134     int registerState; /* 0 (no commit pages), 1 (use commit pages) */
135     time_t registerChange;
136     ZServerSet *sets;
137     Dict dict;
138     ISAM isam;
139     ISAMC isamc;
140     Records records;
141     int errCode;
142     char *errString;
143     ODR odr;
144     ZebTargetInfo *zti;
145     data1_handle dh;
146     data1_attset *registered_sets;
147     BFiles bfs;
148     Res res;
149
150     ZebraLockHandle server_lock_cmt;
151     ZebraLockHandle server_lock_org;
152     char *server_path_prefix;
153 #if USE_TIMES
154     struct tms tms1;
155     struct tms tms2;    
156 #endif
157     ZebraMaps zebra_maps;
158 } ZServerInfo;
159
160 int rpn_search (ZServerInfo *zi, 
161                 Z_RPNQuery *rpn, int num_bases, char **basenames, 
162                 const char *setname, int *hits);
163
164 int rpn_scan (ZServerInfo *zi, Z_AttributesPlusTerm *zapt,
165               oid_value attributeset,
166               int num_bases, char **basenames,
167               int *position, int *num_entries, struct scan_entry **list,
168               int *status);
169
170 RSET rset_trunc (ZServerInfo *zi, ISAM_P *isam_p, int no);
171
172 ZServerSet *resultSetAdd (ZServerInfo *zi, const char *name,
173                           int ov, RSET rset);
174 ZServerSet *resultSetGet (ZServerInfo *zi, const char *name);
175 void resultSetDestroy (ZServerInfo *zi);
176
177 ZServerSetSysno *resultSetSysnoGet (ZServerInfo *zi, const char *name,
178                                     int num, int *positions);
179 void resultSetSysnoDel (ZServerInfo *zi, ZServerSetSysno *records, int num);
180 void zlog_rpn (Z_RPNQuery *rpn);
181 void zlog_scan (Z_AttributesPlusTerm *zapt, oid_value ast);
182
183 int zebra_server_lock_init (ZServerInfo *zi);
184 int zebra_server_lock_destroy (ZServerInfo *zi);
185 int zebra_server_lock (ZServerInfo *zi, int lockCommit);
186 void zebra_server_unlock (ZServerInfo *zi, int commitPhase);
187 int zebra_server_lock_get_state (ZServerInfo *zi, time_t *timep);
188
189 typedef struct attent
190 {
191     int attset_ordinal;
192     data1_local_attribute *local_attributes;
193 } attent;
194
195 int att_getentbyatt(ZServerInfo *zi, attent *res, oid_value set, int att);