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