1 /* $Id: index.h,v 1.193 2007-01-17 13:22:53 adam Exp $
2 Copyright (C) 1995-2007
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 #include <idzebra/version.h>
29 #include <idzebra/util.h>
30 #include <idzebra/flock.h>
34 #include <sys/times.h>
38 #include <yaz/timing.h>
39 #include <idzebra/dict.h>
40 #include <idzebra/isams.h>
41 #include <idzebra/isamc.h>
42 #include <idzebra/isamb.h>
44 #include <idzebra/recgrs.h>
46 #include <idzebra/api.h>
57 #define ISAM_DEFAULT "b"
59 enum dirsKind { dirs_dir, dirs_file };
74 void getFnameTmp(Res res, char *fname, int no);
76 struct dirs_info *dirs_open(Dict dict, const char *rep, int rw);
77 struct dirs_info *dirs_fopen(Dict dict, const char *path, int rw);
78 struct dirs_entry *dirs_read(struct dirs_info *p);
79 struct dirs_entry *dirs_last(struct dirs_info *p);
80 void dirs_mkdir(struct dirs_info *p, const char *src, time_t mtime);
81 void dirs_rmdir(struct dirs_info *p, const char *src);
82 void dirs_add(struct dirs_info *p, const char *src, zint sysno, time_t mtime);
83 void dirs_del(struct dirs_info *p, const char *src);
84 void dirs_free(struct dirs_info **pp);
86 struct dir_entry *dir_open(const char *rep, const char *base,
88 void dir_sort(struct dir_entry *e);
89 void dir_free(struct dir_entry **e_p);
91 void repositoryUpdate(ZebraHandle zh, const char *path);
92 void repositoryAdd(ZebraHandle zh, const char *path);
93 void repositoryDelete(ZebraHandle zh, const char *path);
94 void repositoryShow(ZebraHandle zh, const char *path);
96 void inv_prstat(ZebraHandle zh);
97 void inv_compact(BFiles bfs);
98 void key_input(ZebraHandle zh, int nkeys, int cache, Res res);
99 ISAMS_M *key_isams_m(Res res, ISAMS_M *me);
100 ISAMC_M *key_isamc_m(Res res, ISAMC_M *me);
102 #define FNAME_DICT "dict"
103 #define FNAME_ISAM "isam"
104 #define FNAME_ISAMC "isamc"
105 #define FNAME_ISAMS "isams"
106 #define FNAME_CONFIG "zebra.cfg"
108 #define GMATCH_DICT "gmatch"
109 #define FMATCH_DICT "fmatch%d"
111 void zebra_lock_prefix(Res res, char *dst);
113 #define FNAME_MAIN_LOCK "zebraidx.LCK"
114 #define FNAME_COMMIT_LOCK "zebracmt.LCK"
115 #define FNAME_ORG_LOCK "zebraorg.LCK"
116 #define FNAME_TOUCH_TIME "zebraidx.time"
118 typedef struct zebra_set *ZebraSet;
120 typedef struct zebra_rank_class {
121 struct rank_control *control;
124 struct zebra_rank_class *next;
128 #include "key_block.h"
130 struct zebra_register {
138 zebra_sort_index_t sort_index;
139 int registerState; /* 0 (no commit pages), 1 (use commit pages) */
140 time_t registerChange;
143 ZebraExplainInfo zei;
145 char *server_path_prefix;
147 ZebraMaps zebra_maps;
148 ZebraRankClass rank_classes;
154 zebra_rec_keys_t keys;
155 zebra_rec_keys_t sortKeys;
157 zebra_key_block_t key_block;
160 struct zebra_service {
163 struct zebra_session *sessions;
164 struct zebra_register *regs;
165 Zebra_mutex_cond session_lock;
168 const char *path_root;
169 RecTypeClass record_classes;
175 struct zebra_session {
176 struct zebra_session *next;
177 struct zebra_service *service;
178 struct zebra_register *reg;
180 char *xadmin_databaseName;
188 ZebraLockHandle lock_normal;
189 ZebraLockHandle lock_shadow;
210 int m_segment_indexing;
212 zint records_inserted;
213 zint records_updated;
214 zint records_deleted;
215 zint records_processed;
216 char *record_encoding;
218 yaz_iconv_t iconv_to_utf8;
219 yaz_iconv_t iconv_from_utf8;
223 const char *m_record_id;
224 const char *m_record_type;
227 int m_explain_database;
229 int m_file_verbose_limit;
231 void *store_data_buf;
232 size_t store_data_size;
235 struct zebra_limit *m_limit;
237 int (*busy_handler_func)(void *client_data);
238 void *busy_handler_data;
242 struct term_set_entry {
244 struct term_set_entry *next;
247 struct term_set_list {
248 struct term_set_entry *first;
249 struct term_set_entry *last;
253 void zebra_limit_destroy(struct zebra_limit *zl);
254 struct zebra_limit *zebra_limit_create(int exclude_flag, zint *ids);
255 void zebra_limit_for_rset(struct zebra_limit *zl,
256 int (**filter_func)(const void *buf, void *data),
257 void (**filter_destroy)(void *data),
260 struct rset_key_control *zebra_key_control_create(ZebraHandle zh);
262 ZEBRA_RES rpn_search_top(ZebraHandle zh, Z_RPNStructure *zs,
263 oid_value attributeSet,
264 NMEM stream, NMEM rset_nmem,
265 Z_SortKeySpecList *sort_sequence,
266 int num_bases, char **basenames,
269 ZEBRA_RES rpn_get_top_approx_limit(ZebraHandle zh, Z_RPNStructure *zs,
272 ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
273 oid_value attributeset,
274 int num_bases, char **basenames,
275 int *position, int *num_entries, ZebraScanEntry **list,
276 int *is_partial, RSET limit_set);
278 RSET rset_trunc(ZebraHandle zh, ISAM_P *isam_p, int no,
279 const char *term, int length_term, const char *flags,
280 int preserve_position, int term_type, NMEM rset_nmem,
281 struct rset_key_control *kctrl, int scope,
282 struct ord_list *ol, int reg_type,
283 zint hits_limit, const char *term_ref_id);
285 void resultSetAddTerm(ZebraHandle zh, ZebraSet s, int reg_type,
286 const char *db, const char *index_name,
288 ZebraSet resultSetAdd(ZebraHandle zh, const char *name, int ov);
289 ZebraSet resultSetGet(ZebraHandle zh, const char *name);
290 ZEBRA_RES resultSetAddRPN(ZebraHandle zh, NMEM m, Z_RPNQuery *rpn,
291 int num_bases, char **basenames,
293 zint *hits, int *estimated_hit_count);
294 RSET resultSetRef(ZebraHandle zh, const char *resultSetId);
295 void resultSetDestroy(ZebraHandle zh, int num_names, char **names,
297 ZEBRA_RES resultSetSort(ZebraHandle zh, NMEM nmem,
298 int num_input_setnames, const char **input_setnames,
299 const char *output_setname,
300 Z_SortKeySpecList *sort_sequence, int *sort_status);
301 ZEBRA_RES resultSetSortSingle(ZebraHandle zh, NMEM nmem,
302 ZebraSet sset, RSET rset,
303 Z_SortKeySpecList *sort_sequence,
305 ZEBRA_RES resultSetRank(ZebraHandle zh, ZebraSet zebraSet, RSET rset,
307 void resultSetInvalidate(ZebraHandle zh);
309 int zebra_record_fetch(ZebraHandle zh, zint sysno, int score,
310 zebra_snippets *hit_snippet, ODR stream,
311 oid_value input_format, Z_RecordComposition *comp,
312 oid_value *output_format, char **rec_bufp,
313 int *rec_lenp, char **basenamep,
316 void extract_get_fname_tmp(ZebraHandle zh, char *fname, int no);
318 void zebra_index_merge(ZebraHandle zh);
320 ZEBRA_RES zebra_buffer_extract_record(ZebraHandle zh,
321 const char *buf, size_t buf_size,
324 const char *recordType,
326 const char *match_criteria,
331 ZEBRA_RES zebra_extract_record_stream(ZebraHandle zh,
332 struct ZebraRecStream *stream,
335 const char *recordType,
337 const char *match_criteria,
342 void *recTypeClientData,
345 YAZ_EXPORT void zebra_create_stream_mem(struct ZebraRecStream *stream,
346 const char *buf, size_t sz);
347 YAZ_EXPORT void zebra_create_stream_fd(struct ZebraRecStream *stream,
348 int fd, off_t start_offset);
349 void print_rec_keys(ZebraHandle zh, zebra_rec_keys_t reckeys);
351 ZEBRA_RES zebra_rec_keys_to_snippets(ZebraHandle zh, zebra_rec_keys_t reckeys,
352 zebra_snippets *snippets);
353 ZEBRA_RES zebra_snippets_hit_vector(ZebraHandle zh, const char *setname,
354 zint sysno, zebra_snippets *snippets);
356 ZEBRA_RES zebra_extract_explain(void *handle, Record rec, data1_node *n);
358 ZEBRA_RES zebra_extract_file(ZebraHandle zh, zint *sysno, const char *fname,
361 ZEBRA_RES zebra_begin_read(ZebraHandle zh);
362 ZEBRA_RES zebra_end_read(ZebraHandle zh);
364 int zebra_file_stat(const char *file_name, struct stat *buf,
367 Dict dict_open_res(BFiles bfs, const char *name, int cache, int rw,
368 int compact_flag, Res res);
370 void zebra_setError(ZebraHandle zh, int code, const char *addinfo);
371 void zebra_setError_zint(ZebraHandle zh, int code, zint i);
373 void zebra_term_untrans_iconv(ZebraHandle zh, NMEM stream, int reg_type,
374 char **dst, const char *src);
376 ZEBRA_RES zebra_get_hit_vector(ZebraHandle zh, const char *setname, zint sysno);
378 void zebra_term_untrans(ZebraHandle zh, int reg_type,
379 char *dst, const char *src);
381 ZEBRA_RES zebra_apt_get_ord(ZebraHandle zh,
382 Z_AttributesPlusTerm *zapt,
384 const char *xpath_use,
385 oid_value curAttributeSet,
388 ZEBRA_RES zebra_attr_list_get_ord(ZebraHandle zh,
389 Z_AttributeList *attr_list,
390 zinfo_index_category_t cat,
392 oid_value curAttributeSet,
395 ZEBRA_RES zebra_sort_get_ord(ZebraHandle zh,
396 Z_SortAttributes *sortAttributes,
400 ZEBRA_RES zebra_update_file_match(ZebraHandle zh, const char *path);
401 ZEBRA_RES zebra_update_from_path(ZebraHandle zh, const char *path);
402 ZEBRA_RES zebra_delete_from_path(ZebraHandle zh, const char *path);
403 ZEBRA_RES zebra_remove_file_match(ZebraHandle zh);
405 struct rpn_char_map_info
411 void rpn_char_map_prepare(struct zebra_register *reg, int reg_type,
412 struct rpn_char_map_info *map_info);
414 ZEBRA_RES zapt_term_to_utf8(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
418 void zebra_set_partial_result(ZebraHandle zh);
420 int zebra_check_res(Res res);
422 #define FIRST_IN_FIELD_STR "\001^"
423 #define FIRST_IN_FIELD_CHAR 1
424 #define FIRST_IN_FIELD_LEN 2
432 * indent-tabs-mode: nil
434 * vim: shiftwidth=4 tabstop=8 expandtab