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