OSDN Git Service

Add missing <p> HTML tag to Japanese version of document.
[pgbigm/pg_bigm.git] / bigm.h
1 /*-------------------------------------------------------------------------
2  *
3  * Portions Copyright (c) 2004-2012, PostgreSQL Global Development Group
4  * Portions Copyright (c) 2013-2015, NTT DATA Corporation
5  *
6  * Changelog:
7  *       2013/01/09
8  *       Support full text search using bigrams.
9  *       Author: NTT DATA Corporation
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef __BIGM_H__
14 #define __BIGM_H__
15
16 #include "access/itup.h"
17 #include "storage/bufpage.h"
18 #include "utils/builtins.h"
19
20 /* GUC variable */
21 extern bool bigm_enable_recheck;
22 extern int      bigm_gin_key_limit;
23 extern double bigm_similarity_limit;
24 extern char     *bigm_last_update;
25
26 /* options */
27 #define LPADDING                1
28 #define RPADDING                1
29
30 /* operator strategy numbers */
31 #define LikeStrategyNumber                      1
32 #define SimilarityStrategyNumber        2
33
34 typedef struct
35 {
36         bool            pmatch;                 /* partial match is required? */
37         int8            bytelen;                /* byte length of bi-gram string */
38
39         /*
40          * Bi-gram string; we assume here that the maximum bytes for a character
41          * are four.
42          */
43         char            str[8];
44 }       bigm;
45
46 #define BIGMSIZE        sizeof(bigm)
47
48 extern inline int       bigmstrcmp(char *arg1, int len1, char *arg2, int len2);
49 #define CMPBIGM(a,b) ( bigmstrcmp(((bigm *)a)->str, ((bigm *)a)->bytelen, ((bigm *)b)->str, ((bigm *)b)->bytelen) )
50
51 #define CPBIGM(bptr, s, len) do {               \
52         Assert(len <= 8);                               \
53         memcpy(bptr->str, s, len);              \
54         bptr->bytelen = len;                    \
55         bptr->pmatch = false;                   \
56 } while(0);
57
58 #define ISESCAPECHAR(x) (*(x) == '\\')  /* Wildcard escape character */
59 #define ISWILDCARDCHAR(x) (*(x) == '%' || *(x) == '_')  /* Wildcard
60                                                                                                                  * meta-character */
61 typedef struct
62 {
63         int32           vl_len_;                /* varlena header (do not touch directly!) */
64         char            data[1];
65 }       BIGM;
66
67 #define CALCGTSIZE(len) (VARHDRSZ + len * sizeof(bigm))
68 #define GETARR(x)               ( (bigm *)( (char*)x + VARHDRSZ ) )
69 #define ARRNELEM(x) ( ( VARSIZE(x) - VARHDRSZ )/sizeof(bigm) )
70
71 extern BIGM *generate_bigm(char *str, int slen);
72 extern BIGM *generate_wildcard_bigm(const char *str, int slen, bool *removeDups);
73
74 #endif   /* __BIGM_H__ */