New general match criteria implemented.
[idzebra-moved-to-github.git] / index / index.h
1 /*
2  * Copyright (C) 1994-1995, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: index.h,v $
7  * Revision 1.24  1995-11-21 15:01:15  adam
8  * New general match criteria implemented.
9  * New feature: document groups.
10  *
11  * Revision 1.23  1995/11/20  16:59:45  adam
12  * New update method: the 'old' keys are saved for each records.
13  *
14  * Revision 1.22  1995/11/20  11:56:26  adam
15  * Work on new traversal.
16  *
17  * Revision 1.21  1995/11/16  15:34:55  adam
18  * Uses new record management system in both indexer and server.
19  *
20  * Revision 1.20  1995/11/15  14:46:18  adam
21  * Started work on better record management system.
22  *
23  * Revision 1.19  1995/10/27  14:00:11  adam
24  * Implemented detection of database availability.
25  *
26  * Revision 1.18  1995/10/17  18:02:08  adam
27  * New feature: databases. Implemented as prefix to words in dictionary.
28  *
29  * Revision 1.17  1995/10/13  16:01:49  adam
30  * Work on relations.
31  *
32  * Revision 1.16  1995/10/10  12:24:38  adam
33  * Temporary sort files are compressed.
34  *
35  * Revision 1.15  1995/10/04  16:57:19  adam
36  * Key input and merge sort in one pass.
37  *
38  * Revision 1.14  1995/09/29  14:01:40  adam
39  * Bug fixes.
40  *
41  * Revision 1.13  1995/09/28  14:22:56  adam
42  * Sort uses smaller temporary files.
43  *
44  * Revision 1.12  1995/09/28  12:10:32  adam
45  * Bug fixes. Field prefix used in queries.
46  *
47  * Revision 1.11  1995/09/27  12:22:28  adam
48  * More work on extract in record control.
49  * Field name is not in isam keys but in prefix in dictionary words.
50  *
51  * Revision 1.10  1995/09/14  07:48:23  adam
52  * Record control management.
53  *
54  * Revision 1.9  1995/09/11  13:09:33  adam
55  * More work on relevance feedback.
56  *
57  * Revision 1.8  1995/09/08  14:52:27  adam
58  * Minor changes. Dictionary is lower case now.
59  *
60  * Revision 1.7  1995/09/06  16:11:16  adam
61  * Option: only one word key per file.
62  *
63  * Revision 1.6  1995/09/05  15:28:39  adam
64  * More work on search engine.
65  *
66  * Revision 1.5  1995/09/04  12:33:42  adam
67  * Various cleanup. YAZ util used instead.
68  *
69  * Revision 1.4  1995/09/04  09:10:35  adam
70  * More work on index add/del/update.
71  * Merge sort implemented.
72  * Initial work on z39 server.
73  *
74  * Revision 1.3  1995/09/01  14:06:35  adam
75  * Split of work into more files.
76  *
77  * Revision 1.2  1995/09/01  10:30:24  adam
78  * More work on indexing. Not working yet.
79  *
80  * Revision 1.1  1995/08/31  14:50:24  adam
81  * New simple file index tool.
82  *
83  */
84
85 #include <alexutil.h>
86 #include <dict.h>
87 #include <isam.h>
88
89 #define IT_MAX_WORD 256
90 #define IT_KEY_HAVE_SEQNO 1
91 #define IT_KEY_HAVE_FIELD 0
92
93 struct it_key {
94     int  sysno;
95     int   seqno;
96 };
97
98 enum dirsKind { dirs_dir, dirs_file };
99
100 struct dir_entry {
101     enum dirsKind kind;
102     char *name;
103     int ctime;
104 };
105
106 struct dirs_entry {
107     enum dirsKind kind;
108     char path[256];
109     SYSNO sysno;
110     int ctime;
111 };
112
113 struct recordGroup {
114     char *groupName;
115     char *databaseName;
116     char *path;
117 };
118
119 struct dirs_info *dirs_open (Dict dict, const char *rep);
120 struct dirs_entry *dirs_read (struct dirs_info *p);
121 struct dirs_entry *dirs_last (struct dirs_info *p);
122 void dirs_mkdir (struct dirs_info *p, const char *src, int ctime);
123 void dirs_rmdir (struct dirs_info *p, const char *src);
124 void dirs_add (struct dirs_info *p, const char *src, int sysno, int ctime);
125 void dirs_del (struct dirs_info *p, const char *src);
126 void dirs_free (struct dirs_info **pp);
127
128 struct dir_entry *dir_open (const char *rep);
129 void dir_sort (struct dir_entry *e);
130 void dir_free (struct dir_entry **e_p);
131
132 void repositoryUpdate (struct recordGroup *rGroup);
133 void repositoryExtract (struct recordGroup *rGroup);
134
135 void key_open (int mem);
136 int key_close (void);
137 void key_write (int cmd, struct it_key *k, const char *str);
138 int key_compare (const void *p1, const void *p2);
139 int key_qsort_compare (const void *p1, const void *p2);
140 void key_logdump (int mask, const void *p);
141 void key_input (const char *dict_fname, const char *isam_fname,
142                  int nkeys, int cache);
143 int merge_sort (char **buf, int from, int to);
144
145 #define TEMP_FNAME  "keys%d.tmp"
146 #define FNAME_WORD_DICT "worddict"
147 #define FNAME_WORD_ISAM "wordisam"
148 #define FNAME_FILE_DICT "filedict"
149
150 #define RECORD_BASE 1
151
152 #if !RECORD_BASE
153 #define FNAME_SYS_IDX "sysidx"
154 #define SYS_IDX_ENTRY_LEN 120
155 #endif
156
157 struct strtab *strtab_mk (void);
158 int strtab_src (struct strtab *t, const char *name, void ***infop);
159 void strtab_del (struct strtab *t,
160                  void (*func)(const char *name, void *info, void *data),
161                  void *data);
162 int index_char_cvt (int c);
163 int index_word_prefix (char *string, int attset_ordinal,
164                        int local_attribute, const char *databaseName);
165
166 int fileExtract (SYSNO *sysno, const char *fname,
167                  struct recordGroup *rGroup, int deleteFlag);