2 * Copyright (C) 1994-2002, Index Data
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Id: zserver.h,v 1.52 2002-02-20 17:30:01 adam Exp $
10 #include <sys/times.h>
13 #include <yaz/backend.h>
31 typedef struct zebra_set *ZebraSet;
33 typedef struct zebra_rank_class {
34 struct rank_control *control;
37 struct zebra_rank_class *next;
40 struct zebra_service {
42 struct zebra_session *sessions;
52 int registerState; /* 0 (no commit pages), 1 (use commit pages) */
53 time_t registerChange;
58 ZebraLockHandle server_lock_cmt;
59 ZebraLockHandle server_lock_org;
61 char *server_path_prefix;
64 ZebraRankClass rank_classes;
67 Zebra_mutex_cond session_lock;
69 int active; /* 0=shutdown, 1=enabled and inactive, 2=activated */
89 struct zebra_session {
90 struct zebra_session *next;
91 struct zebra_service *service;
94 struct sortKey *sortKeys;
101 char *admin_databaseName;
103 ZebraLockHandle lock_normal;
104 ZebraLockHandle lock_shadow;
118 struct recordGroup rGroup;
121 struct rank_control {
123 void *(*create)(ZebraService zh);
124 void (*destroy)(ZebraService zh, void *class_handle);
125 void *(*begin)(ZebraHandle zh, void *class_handle, RSET rset);
126 void (*end)(ZebraHandle zh, void *set_handle);
127 int (*calc)(void *set_handle, int sysno);
128 void (*add)(void *set_handle, int seqno, int term_index);
131 struct term_set_entry {
133 struct term_set_entry *next;
136 struct term_set_list {
137 struct term_set_entry *first;
138 struct term_set_entry *last;
141 RSET rpn_search (ZebraHandle zh, NMEM mem,
142 Z_RPNQuery *rpn, int num_bases, char **basenames,
143 const char *setname, ZebraSet sset);
146 void rpn_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
147 oid_value attributeset,
148 int num_bases, char **basenames,
149 int *position, int *num_entries, ZebraScanEntry **list,
152 RSET rset_trunc (ZebraHandle zh, ISAMS_P *isam_p, int no,
153 const char *term, int length_term, const char *flags);
155 void resultSetAddTerm (ZebraHandle zh, ZebraSet s, int reg_type,
156 const char *db, int set,
157 int use, const char *term);
158 ZebraSet resultSetAdd (ZebraHandle zh, const char *name, int ov);
159 ZebraSet resultSetGet (ZebraHandle zh, const char *name);
160 ZebraSet resultSetAddRPN (ZebraHandle zh, ODR stream, ODR decode,
161 Z_RPNQuery *rpn, int num_bases, char **basenames,
162 const char *setname);
163 RSET resultSetRef (ZebraHandle zh, Z_ResultSetId *resultSetId);
164 void resultSetDestroy (ZebraHandle zh, int num_names, char **names,
167 ZebraPosSet zebraPosSetCreate (ZebraHandle zh, const char *name,
168 int num, int *positions);
169 void zebraPosSetDestroy (ZebraHandle zh, ZebraPosSet records, int num);
171 void resultSetSort (ZebraHandle zh, NMEM nmem,
172 int num_input_setnames, const char **input_setnames,
173 const char *output_setname,
174 Z_SortKeySpecList *sort_sequence, int *sort_status);
175 void resultSetSortSingle (ZebraHandle zh, NMEM nmem,
176 ZebraSet sset, RSET rset,
177 Z_SortKeySpecList *sort_sequence, int *sort_status);
178 void resultSetRank (ZebraHandle zh, ZebraSet zebraSet, RSET rset);
179 void resultSetInvalidate (ZebraHandle zh);
181 void zebra_sort (ZebraHandle zh, ODR stream,
182 int num_input_setnames, const char **input_setnames,
183 const char *output_setname, Z_SortKeySpecList *sort_sequence,
186 int zebra_server_lock_init (ZebraService zh);
187 int zebra_server_lock_destroy (ZebraService zh);
188 int zebra_server_lock (ZebraService zh, int lockCommit);
189 void zebra_server_unlock (ZebraService zh, int commitPhase);
190 int zebra_server_lock_get_state (ZebraService zh, time_t *timep);
192 typedef struct attent
195 data1_local_attribute *local_attributes;
198 void zebraRankInstall (ZebraService zh, struct rank_control *ctrl);
199 ZebraRankClass zebraRankLookup (ZebraHandle zh, const char *name);
200 void zebraRankDestroy (ZebraService zh);
202 int att_getentbyatt(ZebraHandle zh, attent *res, oid_value set, int att);
204 extern struct rank_control *rank1_class;
206 int zebra_record_fetch (ZebraHandle zh, int sysno, int score, ODR stream,
207 oid_value input_format, Z_RecordComposition *comp,
208 oid_value *output_format, char **rec_bufp,
209 int *rec_lenp, char **basenamep);
211 void extract_get_fname_tmp (ZebraHandle zh, char *fname, int no);
212 void zebra_index_merge (ZebraHandle zh);
215 int extract_rec_in_mem (ZebraHandle zh, const char *recordType,
216 const char *buf, size_t buf_size,
217 const char *databaseName, int delete_flag,
218 int test_mode, int *sysno,
219 int store_keys, int store_data,
220 const char *match_criteria);
222 void extract_flushWriteKeys (ZebraHandle zh);
224 struct zebra_fetch_control {
227 off_t record_int_pos;
228 const char *record_int_buf;
233 int zebra_record_ext_read (void *fh, char *buf, size_t count);
234 off_t zebra_record_ext_seek (void *fh, off_t offset);
235 off_t zebra_record_ext_tell (void *fh);
236 off_t zebra_record_int_seek (void *fh, off_t offset);
237 off_t zebra_record_int_tell (void *fh);
238 int zebra_record_int_read (void *fh, char *buf, size_t count);
239 void zebra_record_int_end (void *fh, off_t offset);
241 void extract_flushRecordKeys (ZebraHandle zh, SYSNO sysno,
242 int cmd, struct recKeys *reckeys);
243 void extract_flushSortKeys (ZebraHandle zh, SYSNO sysno,
244 int cmd, struct sortKey **skp);
245 void extract_schema_add (struct recExtractCtrl *p, Odr_oid *oid);
246 void extract_token_add (RecWord *p);
247 int explain_extract (void *handle, Record rec, data1_node *n);