1 /*-------------------------------------------------------------------------
3 * Portions Copyright (c) 2004-2012, PostgreSQL Global Development Group
4 * Portions Copyright (c) 2013-2015, NTT DATA Corporation
8 * Support full text search using bigrams.
9 * Author: NTT DATA Corporation
11 *-------------------------------------------------------------------------
16 #include "access/itup.h"
17 #include "storage/bufpage.h"
18 #include "utils/builtins.h"
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;
30 /* operator strategy numbers */
31 #define LikeStrategyNumber 1
32 #define SimilarityStrategyNumber 2
36 bool pmatch; /* partial match is required? */
37 int8 bytelen; /* byte length of bi-gram string */
40 * Bi-gram string; we assume here that the maximum bytes for a character
46 #define BIGMSIZE sizeof(bigm)
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) )
51 #define CPBIGM(bptr, s, len) do { \
53 memcpy(bptr->str, s, len); \
54 bptr->bytelen = len; \
55 bptr->pmatch = false; \
58 #define ISESCAPECHAR(x) (*(x) == '\\') /* Wildcard escape character */
59 #define ISWILDCARDCHAR(x) (*(x) == '%' || *(x) == '_') /* Wildcard
63 int32 vl_len_; /* varlena header (do not touch directly!) */
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) )
71 extern BIGM *generate_bigm(char *str, int slen);
72 extern BIGM *generate_wildcard_bigm(const char *str, int slen, bool *removeDups);
74 #endif /* __BIGM_H__ */