3c5dae6f6eee7ca8f35b1fee6cf7f96d4ad12bbd
[idzebra-moved-to-github.git] / index / recindxp.h
1 /*
2  * Copyright (C) 1994-2000, Index Data
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: recindxp.h,v $
7  * Revision 1.11  2002-08-02 10:07:48  adam
8  * XPATH fixes - leaf attributes part of tag path
9  *
10  * Revision 1.10  2001/10/15 19:53:43  adam
11  * POSIX thread updates. First work on term sets.
12  *
13  * Revision 1.9  2000/12/05 10:01:44  adam
14  * Fixed bug regarding user-defined attribute sets.
15  *
16  * Revision 1.8  2000/04/05 09:49:35  adam
17  * On Unix, zebra/z'mbol uses automake.
18  *
19  * Revision 1.7  1999/07/06 12:28:04  adam
20  * Updated record index structure. Format includes version ID. Compression
21  * algorithm ID is stored for each record block.
22  *
23  * Revision 1.6  1999/05/26 07:49:13  adam
24  * C++ compilation.
25  *
26  * Revision 1.5  1999/02/02 14:51:05  adam
27  * Updated WIN32 code specific sections. Changed header.
28  *
29  * Revision 1.4  1998/03/05 08:45:12  adam
30  * New result set model and modular ranking system. Moved towards
31  * descent server API. System information stored as "SGML" records.
32  *
33  * Revision 1.3  1995/12/11 11:45:55  adam
34  * Removed commented code.
35  *
36  * Revision 1.2  1995/12/11  09:12:51  adam
37  * The rec_get function returns NULL if record doesn't exist - will
38  * happen in the server if the result set records have been deleted since
39  * the creation of the set (i.e. the search).
40  * The server saves a result temporarily if it is 'volatile', i.e. the
41  * set is register dependent.
42  *
43  * Revision 1.1  1995/12/06  12:41:25  adam
44  * New command 'stat' for the index program.
45  * Filenames can be read from stdin by specifying '-'.
46  * Bug fix/enhancement of the transformation from terms to regular
47  * expressons in the search engine.
48  *
49  */
50
51 #include "recindex.h"
52
53 #include <bfile.h>
54
55 YAZ_BEGIN_CDECL
56
57 #define REC_BLOCK_TYPES 2
58 #define REC_HEAD_MAGIC "recindex"
59 #define REC_VERSION 4
60
61 struct records_info {
62     int rw;
63     int compression_method;
64
65     char *index_fname;
66     BFile index_BFile;
67
68     char *data_fname[REC_BLOCK_TYPES];
69     BFile data_BFile[REC_BLOCK_TYPES];
70
71     char *tmp_buf;
72     int tmp_size;
73
74     struct record_cache_entry *record_cache;
75     int cache_size;
76     int cache_cur;
77     int cache_max;
78
79     Zebra_mutex mutex;
80
81     struct records_head {
82         char magic[8];
83         char version[4];
84         int block_size[REC_BLOCK_TYPES];
85         int block_free[REC_BLOCK_TYPES];
86         int block_last[REC_BLOCK_TYPES];
87         int block_used[REC_BLOCK_TYPES];
88         int block_move[REC_BLOCK_TYPES];
89
90         int total_bytes;
91         int index_last;
92         int index_free;
93         int no_records;
94
95     } head;
96 };
97
98 enum recordCacheFlag { recordFlagNop, recordFlagWrite, recordFlagNew,
99                        recordFlagDelete };
100
101 struct record_cache_entry {
102     Record rec;
103     enum recordCacheFlag flag;
104 };
105
106 struct record_index_entry {
107     int next;         /* first block of record info / next free entry */
108     int size;         /* size of record or 0 if free entry */
109 };
110
111 YAZ_END_CDECL