Start work on ICU based regexp searches
[idzebra-moved-to-github.git] / index / zinfo.h
1 /* This file is part of the Zebra server.
2    Copyright (C) 1994-2011 Index Data
3
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
18 */
19
20
21 #ifndef ZINFO_H
22 #define ZINFO_H
23
24 #include <d1_absyn.h>
25 #include <idzebra/api.h>
26 #include "recindex.h"
27
28 /* Compare string (ignore case) */
29 #ifdef WIN32
30 #define STRCASECMP      stricmp
31 #else
32 #define STRCASECMP      strcasecmp
33 #endif
34
35 YAZ_BEGIN_CDECL
36
37 typedef enum {
38     zinfo_index_category_index,
39     zinfo_index_category_sort,
40     zinfo_index_category_alwaysmatches,
41     zinfo_index_category_anchor
42 } zinfo_index_category_t;
43     
44 typedef ZEBRA_RES ZebraExplainUpdateFunc(void *handle,
45                                          Record drec, 
46                                          data1_node *n);
47
48 typedef struct zebraExplainInfo *ZebraExplainInfo;
49 typedef struct zebDatabaseInfo ZebDatabaseInfo;
50 ZebraExplainInfo zebraExplain_open(Records records, data1_handle dh,
51                                    Res res,
52                                    int writeFlag,
53                                    void *updateHandle,
54                                    ZebraExplainUpdateFunc *);
55
56 void zebraExplain_close(ZebraExplainInfo zei);
57 int zebraExplain_curDatabase(ZebraExplainInfo zei, const char *database);
58 int zebraExplain_newDatabase(ZebraExplainInfo zei, const char *database,
59                               int explain_database);
60 int zebraExplain_add_attr_su(ZebraExplainInfo zei, int index_type,
61                              int set, int use);
62
63 /** \brief lookup ordinal from string index + index type 
64     \param zei explain info
65     \param cat category
66     \param index_type index type
67     \param str index string
68     \returns  -1 no such index+type exist; ordinal otherwise
69 */
70     
71 int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, 
72                                  zinfo_index_category_t cat,
73                                  const char *index_type,
74                                  const char *str);
75 int zebraExplain_add_attr_str(ZebraExplainInfo zei, 
76                               zinfo_index_category_t cat,
77                               const char *index_type,
78                               const char *str);
79 void zebraExplain_addSchema(ZebraExplainInfo zei, Odr_oid *oid);
80 void zebraExplain_recordCountIncrement(ZebraExplainInfo zei, int adjust_num);
81 void zebraExplain_recordBytesIncrement(ZebraExplainInfo zei, int adjust_num);
82 zint zebraExplain_runNumberIncrement(ZebraExplainInfo zei, int adjust_num);
83 void zebraExplain_loadAttsets(data1_handle dh, Res res);
84 void zebraExplain_flush(ZebraExplainInfo zei, void *updateHandle);
85
86 int zebraExplain_lookup_ord(ZebraExplainInfo zei, int ord,
87                              const char **index_type, const char **db,
88                              const char **string_index);
89
90 int zebraExplain_ord_adjust_occurrences(ZebraExplainInfo zei, int ord,
91                                         int term_delta, int doc_delta);
92
93 zint zebraExplain_ord_get_term_occurrences(ZebraExplainInfo zei, int ord);
94 zint zebraExplain_ord_get_doc_occurrences(ZebraExplainInfo zei, int ord);
95
96 int zebraExplain_trav_ord(ZebraExplainInfo zei, void *handle,
97                           int (*f)(void *handle, int ord,
98                                    const char *index_type,
99                                    const char *string_index,
100                                    zinfo_index_category_t cat));
101
102 int zebraExplain_get_database_ord(ZebraExplainInfo zei);
103 int zebraExplain_removeDatabase(ZebraExplainInfo zei, void *updateHandle);
104
105 typedef struct {
106     int recordSize;
107     off_t recordOffset;
108     zint runNumber;
109     zint staticrank;
110 } RecordAttr;
111 RecordAttr *rec_init_attr(ZebraExplainInfo zei, Record rec);
112
113 YAZ_END_CDECL
114
115 #endif
116 /*
117  * Local variables:
118  * c-basic-offset: 4
119  * c-file-style: "Stroustrup"
120  * indent-tabs-mode: nil
121  * End:
122  * vim: shiftwidth=4 tabstop=8 expandtab
123  */
124