1 /*-------------------------------------------------------------------------
3 * Portions Copyright (c) 2004-2012, PostgreSQL Global Development Group
7 * Support full text search using bigrams.
8 * Author: NTT DATA Corporation
10 *-------------------------------------------------------------------------
15 #include "access/itup.h"
16 #include "storage/bufpage.h"
17 #include "utils/builtins.h"
20 extern bool bigm_enable_recheck;
21 extern int bigm_gin_key_limit;
27 /* operator strategy numbers */
28 #define LikeStrategyNumber 1
32 bool pmatch; /* partial match is required? */
33 int bytelen; /* byte length of bi-gram string */
35 * Bi-gram string; we assume here that the maximum bytes for
36 * a character are four.
41 #define BIGMSIZE sizeof(bigm)
43 int bigmstrcmp(char *arg1, int len1, char *arg2, int len2);
44 #define CMPBIGM(a,b) ( bigmstrcmp(((bigm *)a)->str, ((bigm *)a)->bytelen, ((bigm *)b)->str, ((bigm *)b)->bytelen) )
46 #define CPBIGM(bptr, s, len) do { \
48 memcpy(bptr->str, s, len); \
49 bptr->bytelen = len; \
50 bptr->pmatch = false; \
53 #define ISESCAPECHAR(x) (*(x) == '\\') /* Wildcard escape character */
54 #define ISWILDCARDCHAR(x) (*(x) == '%' || *(x) == '_') /* Wildcard
58 int32 vl_len_; /* varlena header (do not touch directly!) */
62 #define CALCGTSIZE(len) (VARHDRSZ + len * sizeof(bigm))
63 #define GETARR(x) ( (bigm *)( (char*)x + VARHDRSZ ) )
64 #define ARRNELEM(x) ( ( VARSIZE(x) - VARHDRSZ )/sizeof(bigm) )
66 BIGM *generate_bigm(char *str, int slen);
67 BIGM *generate_wildcard_bigm(const char *str, int slen, bool *removeDups);
69 #endif /* __BIGM_H__ */