2 * Copyright (C) 1994-2001, Index Data
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Id: zserver.h,v 1.51 2001-10-15 19:53:43 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;
51 int registerState; /* 0 (no commit pages), 1 (use commit pages) */
52 time_t registerChange;
57 ZebraLockHandle server_lock_cmt;
58 ZebraLockHandle server_lock_org;
59 char *server_path_prefix;
62 ZebraRankClass rank_classes;
65 Zebra_mutex_cond session_lock;
67 int active; /* 0=shutdown, 1=enabled and inactive, 2=activated */
87 struct zebra_session {
88 struct zebra_session *next;
89 struct zebra_service *service;
92 struct sortKey *sortKeys;
99 char *admin_databaseName;
112 struct rank_control {
114 void *(*create)(ZebraService zh);
115 void (*destroy)(ZebraService zh, void *class_handle);
116 void *(*begin)(ZebraHandle zh, void *class_handle, RSET rset);
117 void (*end)(ZebraHandle zh, void *set_handle);
118 int (*calc)(void *set_handle, int sysno);
119 void (*add)(void *set_handle, int seqno, int term_index);
122 struct term_set_entry {
124 struct term_set_entry *next;
127 struct term_set_list {
128 struct term_set_entry *first;
129 struct term_set_entry *last;
132 RSET rpn_search (ZebraHandle zh, NMEM mem,
133 Z_RPNQuery *rpn, int num_bases, char **basenames,
134 const char *setname, ZebraSet sset);
137 void rpn_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
138 oid_value attributeset,
139 int num_bases, char **basenames,
140 int *position, int *num_entries, ZebraScanEntry **list,
143 RSET rset_trunc (ZebraHandle zh, ISAMS_P *isam_p, int no,
144 const char *term, int length_term, const char *flags);
146 void resultSetAddTerm (ZebraHandle zh, ZebraSet s, int reg_type,
147 const char *db, int set,
148 int use, const char *term);
149 ZebraSet resultSetAdd (ZebraHandle zh, const char *name, int ov);
150 ZebraSet resultSetGet (ZebraHandle zh, const char *name);
151 ZebraSet resultSetAddRPN (ZebraHandle zh, ODR stream, ODR decode,
152 Z_RPNQuery *rpn, int num_bases, char **basenames,
153 const char *setname);
154 RSET resultSetRef (ZebraHandle zh, Z_ResultSetId *resultSetId);
155 void resultSetDestroy (ZebraHandle zh, int num_names, char **names,
158 ZebraPosSet zebraPosSetCreate (ZebraHandle zh, const char *name,
159 int num, int *positions);
160 void zebraPosSetDestroy (ZebraHandle zh, ZebraPosSet records, int num);
162 void resultSetSort (ZebraHandle zh, NMEM nmem,
163 int num_input_setnames, const char **input_setnames,
164 const char *output_setname,
165 Z_SortKeySpecList *sort_sequence, int *sort_status);
166 void resultSetSortSingle (ZebraHandle zh, NMEM nmem,
167 ZebraSet sset, RSET rset,
168 Z_SortKeySpecList *sort_sequence, int *sort_status);
169 void resultSetRank (ZebraHandle zh, ZebraSet zebraSet, RSET rset);
171 void zebra_sort (ZebraHandle zh, ODR stream,
172 int num_input_setnames, const char **input_setnames,
173 const char *output_setname, Z_SortKeySpecList *sort_sequence,
176 int zebra_server_lock_init (ZebraService zh);
177 int zebra_server_lock_destroy (ZebraService zh);
178 int zebra_server_lock (ZebraService zh, int lockCommit);
179 void zebra_server_unlock (ZebraService zh, int commitPhase);
180 int zebra_server_lock_get_state (ZebraService zh, time_t *timep);
182 typedef struct attent
185 data1_local_attribute *local_attributes;
188 void zebraRankInstall (ZebraService zh, struct rank_control *ctrl);
189 ZebraRankClass zebraRankLookup (ZebraHandle zh, const char *name);
190 void zebraRankDestroy (ZebraService zh);
192 int att_getentbyatt(ZebraHandle zh, attent *res, oid_value set, int att);
194 extern struct rank_control *rank1_class;
196 int zebra_record_fetch (ZebraHandle zh, int sysno, int score, ODR stream,
197 oid_value input_format, Z_RecordComposition *comp,
198 oid_value *output_format, char **rec_bufp,
199 int *rec_lenp, char **basenamep);
201 void extract_get_fname_tmp (ZebraHandle zh, char *fname, int no);
202 void zebra_index_merge (ZebraHandle zh);
205 struct zebra_fetch_control {
208 off_t record_int_pos;
209 const char *record_int_buf;
214 int zebra_record_ext_read (void *fh, char *buf, size_t count);
215 off_t zebra_record_ext_seek (void *fh, off_t offset);
216 off_t zebra_record_ext_tell (void *fh);
217 off_t zebra_record_int_seek (void *fh, off_t offset);
218 off_t zebra_record_int_tell (void *fh);
219 int zebra_record_int_read (void *fh, char *buf, size_t count);
220 void zebra_record_int_end (void *fh, off_t offset);