2 * Copyright (C) 1994-1998, Index Data
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.37 1998-09-02 13:53:22 adam
8 * Extra parameter decode added to search routines to implement
11 * Revision 1.36 1998/06/24 12:16:16 adam
12 * Support for relations on text operands. Open range support in
13 * DFA module (i.e. [-j], [g-]).
15 * Revision 1.35 1998/06/23 15:33:35 adam
16 * Added feature to specify sort criteria in query (type 7 specifies
19 * Revision 1.34 1998/06/22 11:36:50 adam
20 * Added authentication check facility to zebra.
22 * Revision 1.33 1998/06/12 12:22:14 adam
25 * Revision 1.32 1998/05/27 16:57:47 adam
26 * Zebra returns surrogate diagnostic for single records when
29 * Revision 1.31 1998/05/20 10:12:23 adam
30 * Implemented automatic EXPLAIN database maintenance.
31 * Modified Zebra to work with ASN.1 compiled version of YAZ.
33 * Revision 1.30 1998/03/05 08:45:13 adam
34 * New result set model and modular ranking system. Moved towards
35 * descent server API. System information stored as "SGML" records.
37 * Revision 1.29 1998/02/10 12:03:06 adam
40 * Revision 1.28 1998/01/29 13:40:11 adam
41 * Better logging for scan service.
43 * Revision 1.27 1997/10/27 14:33:06 adam
44 * Moved towards generic character mapping depending on "structure"
45 * field in abstract syntax file. Fixed a few memory leaks. Fixed
46 * bug with negative integers when doing searches with relational
49 * Revision 1.26 1997/09/29 12:41:35 adam
50 * Fixed bug regarding USE_TIMES var.
52 * Revision 1.25 1997/09/29 09:08:36 adam
53 * Revised locking system to be thread safe for the server.
55 * Revision 1.24 1997/09/17 12:19:19 adam
56 * Zebra version corresponds to YAZ version 1.4.
57 * Changed Zebra server so that it doesn't depend on global common_resource.
59 * Revision 1.23 1996/12/23 15:30:46 adam
61 * Bug fix: result sets weren't deleted after server shut down.
63 * Revision 1.22 1996/11/04 14:07:49 adam
64 * Moved truncation code to trunc.c.
66 * Revision 1.21 1996/10/29 14:09:58 adam
67 * Use of cisam system - enabled if setting isamc is 1.
69 * Revision 1.20 1996/06/04 10:19:02 adam
70 * Minor changes - removed include of ctype.h.
72 * Revision 1.19 1996/05/14 11:34:01 adam
73 * Scan support in multiple registers/databases.
75 * Revision 1.18 1996/05/14 06:16:50 adam
76 * Compact use/set bytes used in search service.
78 * Revision 1.17 1995/12/08 16:22:57 adam
79 * Work on update while servers are running. Three lock files introduced.
80 * The servers reload their registers when necessary, but they don't
81 * reestablish result sets yet.
83 * Revision 1.16 1995/12/07 17:38:48 adam
84 * Work locking mechanisms for concurrent updates/commit.
86 * Revision 1.15 1995/11/21 15:29:13 adam
87 * Config file 'base' read by default by both indexer and server.
89 * Revision 1.14 1995/11/16 17:00:57 adam
90 * Better logging of rpn query.
92 * Revision 1.13 1995/11/16 15:34:56 adam
93 * Uses new record management system in both indexer and server.
95 * Revision 1.12 1995/10/27 14:00:12 adam
96 * Implemented detection of database availability.
98 * Revision 1.11 1995/10/17 18:02:12 adam
99 * New feature: databases. Implemented as prefix to words in dictionary.
101 * Revision 1.10 1995/10/09 16:18:38 adam
102 * Function dict_lookup_grep got extra client data parameter.
104 * Revision 1.9 1995/10/06 14:38:01 adam
105 * New result set method: r_score.
106 * Local no (sysno) and score is transferred to retrieveCtrl.
108 * Revision 1.8 1995/10/06 13:52:06 adam
109 * Bug fixes. Handler may abort further scanning.
111 * Revision 1.7 1995/10/06 10:43:57 adam
112 * Scan added. 'occurrences' in scan entries not set yet.
114 * Revision 1.6 1995/09/28 09:19:48 adam
115 * xfree/xmalloc used everywhere.
116 * Extract/retrieve method seems to work for text records.
118 * Revision 1.5 1995/09/27 16:17:32 adam
119 * More work on retrieve.
121 * Revision 1.4 1995/09/14 11:53:28 adam
122 * First work on regular expressions/truncations.
124 * Revision 1.3 1995/09/08 08:53:23 adam
125 * Record buffer maintained in server_info.
127 * Revision 1.2 1995/09/06 16:11:19 adam
128 * Option: only one word key per file.
130 * Revision 1.1 1995/09/05 15:28:40 adam
131 * More work on search engine.
145 #include <sys/times.h>
152 #include <passwddb.h>
154 #include "zebraapi.h"
162 typedef struct zebra_set *ZebraSet;
164 typedef struct zebra_rank_class {
165 struct rank_control *control;
168 struct zebra_rank_class *next;
172 int registerState; /* 0 (no commit pages), 1 (use commit pages) */
173 time_t registerChange;
183 ZebraExplainInfo zei;
188 ZebraLockHandle server_lock_cmt;
189 ZebraLockHandle server_lock_org;
190 char *server_path_prefix;
195 ZebraMaps zebra_maps;
196 ZebraRankClass rank_classes;
201 struct rank_control {
203 void *(*create)(ZebraHandle zh);
204 void (*destroy)(ZebraHandle zh, void *class_handle);
205 void *(*begin)(ZebraHandle zh, void *class_handle, RSET rset);
206 void (*end)(ZebraHandle zh, void *set_handle);
207 int (*calc)(void *set_handle, int sysno);
208 void (*add)(void *set_handle, int seqno, int term_index);
211 void rpn_search (ZebraHandle zh, ODR stream, ODR decode,
212 Z_RPNQuery *rpn, int num_bases, char **basenames,
213 const char *setname);
216 void rpn_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
217 oid_value attributeset,
218 int num_bases, char **basenames,
219 int *position, int *num_entries, ZebraScanEntry **list,
222 RSET rset_trunc (ZebraHandle zh, ISAM_P *isam_p, int no,
223 const char *term, int length_term, const char *flags);
225 ZebraSet resultSetAdd (ZebraHandle zh, const char *name,
226 int ov, RSET rset, int *hits);
227 ZebraSet resultSetGet (ZebraHandle zh, const char *name);
228 RSET resultSetRef (ZebraHandle zh, Z_ResultSetId *resultSetId);
229 void resultSetDestroy (ZebraHandle zh);
231 ZebraPosSet zebraPosSetCreate (ZebraHandle zh, const char *name,
232 int num, int *positions);
233 void zebraPosSetDestroy (ZebraHandle zh, ZebraPosSet records, int num);
235 void resultSetSort (ZebraHandle zh, ODR stream,
236 int num_input_setnames, const char **input_setnames,
237 const char *output_setname,
238 Z_SortKeySpecList *sort_sequence, int *sort_status);
240 void zebra_sort (ZebraHandle zh, ODR stream,
241 int num_input_setnames, const char **input_setnames,
242 const char *output_setname, Z_SortKeySpecList *sort_sequence,
245 void zlog_rpn (Z_RPNQuery *rpn);
246 void zlog_scan (Z_AttributesPlusTerm *zapt, oid_value ast);
248 int zebra_server_lock_init (ZebraHandle zh);
249 int zebra_server_lock_destroy (ZebraHandle zh);
250 int zebra_server_lock (ZebraHandle zh, int lockCommit);
251 void zebra_server_unlock (ZebraHandle zh, int commitPhase);
252 int zebra_server_lock_get_state (ZebraHandle zh, time_t *timep);
254 typedef struct attent
257 data1_local_attribute *local_attributes;
260 void zebraRankInstall (ZebraHandle zh, struct rank_control *ctrl);
261 ZebraRankClass zebraRankLookup (ZebraHandle zh, const char *name);
262 void zebraRankDestroy (ZebraHandle zh);
264 int att_getentbyatt(ZebraHandle zh, attent *res, oid_value set, int att);
266 extern struct rank_control *rank1_class;
268 int zebra_record_fetch (ZebraHandle zh, int sysno, int score, ODR stream,
269 oid_value input_format, Z_RecordComposition *comp,
270 oid_value *output_format, char **rec_bufp,
271 int *rec_lenp, char **basenamep);