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