29#define SimilarityStrategyNumber 1
30#define DistanceStrategyNumber 2
31#define LikeStrategyNumber 3
32#define ILikeStrategyNumber 4
33#define RegExpStrategyNumber 5
34#define RegExpICaseStrategyNumber 6
35#define WordSimilarityStrategyNumber 7
36#define WordDistanceStrategyNumber 8
37#define StrictWordSimilarityStrategyNumber 9
38#define StrictWordDistanceStrategyNumber 10
39#define EqualStrategyNumber 11
43#define CMPCHAR(a,b) ( ((a)==(b)) ? 0 : ( ((a)<(b)) ? -1 : 1 ) )
44#define CMPPCHAR(a,b,i) CMPCHAR( *(((const char*)(a))+i), *(((const char*)(b))+i) )
45#define CMPTRGM(a,b) ( CMPPCHAR(a,b,0) ? CMPPCHAR(a,b,0) : ( CMPPCHAR(a,b,1) ? CMPPCHAR(a,b,1) : CMPPCHAR(a,b,2) ) )
47#define CPTRGM(a,b) do { \
48 *(((char*)(a))+0) = *(((char*)(b))+0); \
49 *(((char*)(a))+1) = *(((char*)(b))+1); \
50 *(((char*)(a))+2) = *(((char*)(b))+2); \
53#define ISWORDCHR(c) (t_isalnum(c))
54#define ISPRINTABLECHAR(a) ( isascii( *(unsigned char*)(a) ) && (isalnum( *(unsigned char*)(a) ) || *(unsigned char*)(a)==' ') )
55#define ISPRINTABLETRGM(t) ( ISPRINTABLECHAR( ((char*)(t)) ) && ISPRINTABLECHAR( ((char*)(t))+1 ) && ISPRINTABLECHAR( ((char*)(t))+2 ) )
57#define ISESCAPECHAR(x) (*(x) == '\\')
58#define ISWILDCARDCHAR(x) (*(x) == '_' || *(x) == '%')
68#define TRGMHDRSIZE (VARHDRSZ + sizeof(uint8))
71#define SIGLEN_DEFAULT (sizeof(int) * 3)
72#define SIGLEN_MAX GISTMaxIndexKeySize
75#define SIGLENBIT(siglen) ((siglen) * BITBYTE - 1)
79#define LOOPBYTE(siglen) \
80 for (i = 0; i < (siglen); i++)
82#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
83#define GETBITBYTE(x,i) ( (((char)(x)) >> (i)) & 0x01 )
84#define CLRBIT(x,i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) )
85#define SETBIT(x,i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITBYTE ) )
86#define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 )
88#define HASHVAL(val, siglen) (((unsigned int)(val)) % SIGLENBIT(siglen))
89#define HASH(sign, val, siglen) SETBIT((sign), HASHVAL(val, siglen))
95#define ISARRKEY(x) ( ((TRGM*)x)->flag & ARRKEY )
96#define ISSIGNKEY(x) ( ((TRGM*)x)->flag & SIGNKEY )
97#define ISALLTRUE(x) ( ((TRGM*)x)->flag & ALLISTRUE )
99#define CALCGTSIZE(flag, len) ( TRGMHDRSIZE + ( ( (flag) & ARRKEY ) ? ((len)*sizeof(trgm)) : (((flag) & ALLISTRUE) ? 0 : (len)) ) )
100#define GETSIGN(x) ( (BITVECP)( (char*)x+TRGMHDRSIZE ) )
101#define GETARR(x) ( (trgm*)( (char*)x+TRGMHDRSIZE ) )
102#define ARRNELEM(x) ( ( VARSIZE(x) - TRGMHDRSIZE )/sizeof(trgm) )
111#define CALCSML(count, len1, len2) ((float4) (count)) / ((float4) ((len1) + (len2) - (count)))
113#define CALCSML(count, len1, len2) ((float4) (count)) / ((float4) (((len1) > (len2)) ? (len1) : (len2)))
#define FLEXIBLE_ARRAY_MEMBER
double strict_word_similarity_threshold
TRGM * generate_trgm(char *str, int slen)
uint32 trgm2int(trgm *ptr)
void compact_trigram(trgm *tptr, char *str, int bytelen)
bool * trgm_presence_map(TRGM *query, TRGM *key)
double word_similarity_threshold
double index_strategy_get_limit(StrategyNumber strategy)
TRGM * createTrgmNFA(text *text_re, Oid collation, TrgmPackedGraph **graph, MemoryContext rcontext)
double similarity_threshold
bool trigramsMatchGraph(TrgmPackedGraph *graph, bool *check)
bool trgm_contained_by(TRGM *trg1, TRGM *trg2)
TRGM * generate_wildcard_trgm(const char *str, int slen)
float4 cnt_sml(TRGM *trg1, TRGM *trg2, bool inexact)