IDZEBRA  2.2.7
dict-p.h
Go to the documentation of this file.
1 /* This file is part of the Zebra server.
2  Copyright (C) Index Data
3 
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8 
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 
18 */
19 
20 #ifndef DICT_P_H
21 #define DICT_P_H
22 
23 #include <yaz/log.h>
24 #include <yaz/xmalloc.h>
25 #include <idzebra/dict.h>
26 
27 YAZ_BEGIN_CDECL
28 
29 #define DICT_MAGIC "dict01"
30 
31 #define DICT_DEFAULT_PAGESIZE 4096
32 
33 typedef unsigned char Dict_char;
34 typedef unsigned Dict_ptr;
35 
36 struct Dict_head {
37  char magic_str[8];
38  int page_size;
41 };
42 
44 {
47  void *data;
48  int dirty;
49  int no;
50  int nbytes;
51 };
52 
53 typedef struct Dict_file_struct
54 {
55  int cache;
57 
61 
63  int hash_size;
64  void *all_data;
65 
67  int hits;
68  int misses;
71 
72 struct Dict_struct {
73  int rw;
75  const char **(*grep_cmap)(void *vp, const char **from, int len);
83  struct Dict_head head;
84 };
85 
86 int dict_bf_readp (Dict_BFile bf, int no, void **bufp);
87 int dict_bf_newp (Dict_BFile bf, int no, void **bufp, int nbytes);
88 int dict_bf_touch (Dict_BFile bf, int no);
89 void dict_bf_flush_blocks (Dict_BFile bf, int no_to_flush);
90 Dict_BFile dict_bf_open (BFiles bfs, const char *name, int block_size,
91  int cache, int rw);
92 int dict_bf_close (Dict_BFile dbf);
93 void dict_bf_compact (Dict_BFile dbf);
94 
95 int dict_strcmp (const Dict_char *s1, const Dict_char *s2);
96 
97 int dict_strncmp (const Dict_char *s1, const Dict_char *s2, size_t n);
98 
99 int dict_strlen (const Dict_char *s);
100 
101 
102 #define DICT_EOS 0
103 #define DICT_type(x) 0[(Dict_ptr*) x]
104 #define DICT_backptr(x) 1[(Dict_ptr*) x]
105 #define DICT_bsize(x) 2[(short*)((char*)(x)+2*sizeof(Dict_ptr))]
106 #define DICT_nodir(x) 0[(short*)((char*)(x)+2*sizeof(Dict_ptr))]
107 #define DICT_size(x) 1[(short*)((char*)(x)+2*sizeof(Dict_ptr))]
108 #define DICT_infoffset (2*sizeof(Dict_ptr)+3*sizeof(short))
109 #define DICT_xxxxpagesize(x) ((x)->head.page_size)
110 
111 #define DICT_to_str(x) sizeof(Dict_info)+sizeof(Dict_ptr)
112 
113 /*
114  type type of page
115  backptr pointer to parent
116  nextptr pointer to next page (if any)
117  nodir no of words
118  size size of strings,info,ptr entries
119 
120  dir[0..nodir-1]
121  ptr,info,string
122  */
123 
124 YAZ_END_CDECL
125 
126 #endif
127 /*
128  * Local variables:
129  * c-basic-offset: 4
130  * c-file-style: "Stroustrup"
131  * indent-tabs-mode: nil
132  * End:
133  * vim: shiftwidth=4 tabstop=8 expandtab
134  */
135 
Dict_BFile dict_bf_open(BFiles bfs, const char *name, int block_size, int cache, int rw)
Definition: dopen.c:75
int dict_strncmp(const Dict_char *s1, const Dict_char *s2, size_t n)
Definition: open.c:113
unsigned Dict_ptr
Definition: dict-p.h:34
void dict_bf_flush_blocks(Dict_BFile bf, int no_to_flush)
Definition: drdwr.c:82
void dict_bf_compact(Dict_BFile dbf)
Definition: dopen.c:91
struct Dict_file_struct * Dict_BFile
int dict_bf_touch(Dict_BFile bf, int no)
Definition: drdwr.c:244
int dict_bf_readp(Dict_BFile bf, int no, void **bufp)
Definition: drdwr.c:188
int dict_strlen(const Dict_char *s)
Definition: open.c:118
int dict_strcmp(const Dict_char *s1, const Dict_char *s2)
Definition: open.c:108
unsigned char Dict_char
Definition: dict-p.h:33
int dict_bf_newp(Dict_BFile bf, int no, void **bufp, int nbytes)
Definition: drdwr.c:226
int dict_bf_close(Dict_BFile dbf)
Definition: dclose.c:32
Zebra dictionary.
struct Dict_file_block ** h_prev
Definition: dict-p.h:45
struct Dict_file_block * lru_next
Definition: dict-p.h:46
struct Dict_file_block * lru_prev
Definition: dict-p.h:46
void * data
Definition: dict-p.h:47
struct Dict_file_block * h_next
Definition: dict-p.h:45
int compact_flag
Definition: dict-p.h:69
struct Dict_file_block * free_list
Definition: dict-p.h:59
int block_size
Definition: dict-p.h:66
struct Dict_file_block * lru_front
Definition: dict-p.h:62
struct Dict_file_block * lru_back
Definition: dict-p.h:62
struct Dict_file_block ** hash_array
Definition: dict-p.h:60
void * all_data
Definition: dict-p.h:64
struct Dict_file_block * all_blocks
Definition: dict-p.h:58
int page_size
Definition: dict-p.h:38
Dict_ptr root
Definition: dict-p.h:40
int compact_flag
Definition: dict-p.h:39
Dict_ptr freelist
Definition: dict-p.h:40
Dict_ptr last
Definition: dict-p.h:40
char magic_str[8]
Definition: dict-p.h:37
zint no_lookup
Definition: dict-p.h:82
zint no_split
Definition: dict-p.h:78
int rw
Definition: dict-p.h:73
struct Dict_head head
Definition: dict-p.h:83
zint no_insert
Definition: dict-p.h:80
void * grep_cmap_data
Definition: dict-p.h:76
Dict_BFile dbf
Definition: dict-p.h:74
long zint
Zebra integer.
Definition: util.h:66