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