forked from tvondra/shared_ispell
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshared_ispell.h
75 lines (59 loc) · 1.67 KB
/
shared_ispell.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef __SHARED_ISPELL_H__
#define __SHARED_ISPELL_H__
#include "storage/lwlock.h"
#include "utils/memutils.h"
#include "utils/timestamp.h"
#include "tsearch/dicts/spell.h"
#include "tsearch/ts_public.h"
/* This segment is initialized in the first process that accesses it (see
* ispell_shmem_startup function).
*/
#define SEGMENT_NAME "shared_ispell"
#define MAXLEN 255
typedef struct SharedIspellDict
{
/* this is used for selecting the dictionary */
char *dictFile;
char *affixFile;
int nbytes;
int nwords;
/* next dictionary in the chain (essentially a linked list) */
struct SharedIspellDict *next;
IspellDict dict;
} SharedIspellDict;
typedef struct SharedStopList
{
char *stopFile;
int nbytes;
struct SharedStopList *next;
StopList stop;
} SharedStopList;
/* used to allocate memory in the shared segment */
typedef struct SegmentInfo
{
LWLockId lock;
char *firstfree; /* first free address (always maxaligned) */
size_t available; /* free space remaining at firstfree */
instr_time lastReset; /* last reset of the dictionary */
/* the shared segment (info and data) */
SharedIspellDict *shdict;
SharedStopList *shstop;
} SegmentInfo;
/* used to keep track of dictionary in each backend */
typedef struct DictInfo
{
instr_time lookup;
char dictFile[MAXLEN];
char affixFile[MAXLEN];
char stopFile[MAXLEN];
/* We split word list and affix list.
* In shdict we store a word list, word list will be stored in shared segment.
* In dict we store an affix list in each process.
*/
SharedIspellDict *shdict;
IspellDict dict;
SharedStopList *shstop;
/* MemoryContext of dict local content */
MemoryContext infoCntx;
} DictInfo;
#endif