6db107c955e2ce0ea4f7bf9e1fa5e3475c27f075
[idzebra-moved-to-github.git] / index / zinfo.h
1 /* $Id: zinfo.h,v 1.40 2007-10-29 16:57:53 adam Exp $
2    Copyright (C) 1995-2007
3    Index Data ApS
4
5 This file is part of the Zebra server.
6
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
10 version.
11
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
15 for more details.
16
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
20
21 */
22
23
24 #ifndef ZINFO_H
25 #define ZINFO_H
26
27 #include <d1_absyn.h>
28 #include <idzebra/api.h>
29 #include "recindex.h"
30
31 /* Compare string (ignore case) */
32 #ifdef WIN32
33 #define STRCASECMP      stricmp
34 #else
35 #define STRCASECMP      strcasecmp
36 #endif
37
38 YAZ_BEGIN_CDECL
39
40 typedef enum {
41     zinfo_index_category_index,
42     zinfo_index_category_sort,
43     zinfo_index_category_alwaysmatches,
44     zinfo_index_category_anchor
45 } zinfo_index_category_t;
46     
47 typedef ZEBRA_RES ZebraExplainUpdateFunc(void *handle,
48                                          Record drec, 
49                                          data1_node *n);
50
51 typedef struct zebraExplainInfo *ZebraExplainInfo;
52 typedef struct zebDatabaseInfo ZebDatabaseInfo;
53 ZebraExplainInfo zebraExplain_open(Records records, data1_handle dh,
54                                    Res res,
55                                    int writeFlag,
56                                    void *updateHandle,
57                                    ZebraExplainUpdateFunc *);
58
59 void zebraExplain_close(ZebraExplainInfo zei);
60 int zebraExplain_curDatabase(ZebraExplainInfo zei, const char *database);
61 int zebraExplain_newDatabase(ZebraExplainInfo zei, const char *database,
62                               int explain_database);
63 int zebraExplain_add_attr_su(ZebraExplainInfo zei, int index_type,
64                              int set, int use);
65
66 /** \brief lookup ordinal from string index + index type 
67     \param zei explain info
68     \param cat category
69     \param index_type index type
70     \param str index string
71     \returns  -1 no such index+type exist; ordinal otherwise
72 */
73     
74 int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, 
75                                  zinfo_index_category_t cat,
76                                  const char *index_type,
77                                  const char *str);
78 int zebraExplain_add_attr_str(ZebraExplainInfo zei, 
79                               zinfo_index_category_t cat,
80                               const char *index_type,
81                               const char *str);
82 void zebraExplain_addSchema(ZebraExplainInfo zei, Odr_oid *oid);
83 void zebraExplain_recordCountIncrement(ZebraExplainInfo zei, int adjust_num);
84 void zebraExplain_recordBytesIncrement(ZebraExplainInfo zei, int adjust_num);
85 zint zebraExplain_runNumberIncrement(ZebraExplainInfo zei, int adjust_num);
86 void zebraExplain_loadAttsets(data1_handle dh, Res res);
87 void zebraExplain_flush(ZebraExplainInfo zei, void *updateHandle);
88
89 int zebraExplain_lookup_ord(ZebraExplainInfo zei, int ord,
90                              const char **index_type, const char **db,
91                              const char **string_index);
92
93 int zebraExplain_ord_adjust_occurrences(ZebraExplainInfo zei, int ord,
94                                         int term_delta, int doc_delta);
95
96 zint zebraExplain_ord_get_term_occurrences(ZebraExplainInfo zei, int ord);
97 zint zebraExplain_ord_get_doc_occurrences(ZebraExplainInfo zei, int ord);
98
99 int zebraExplain_trav_ord(ZebraExplainInfo zei, void *handle,
100                           int (*f)(void *handle, int ord));
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  * indent-tabs-mode: nil
120  * End:
121  * vim: shiftwidth=4 tabstop=8 expandtab
122  */
123