30 #define SimilarityStrategyNumber 1
31 #define DistanceStrategyNumber 2
32 #define LikeStrategyNumber 3
33 #define ILikeStrategyNumber 4
34 #define RegExpStrategyNumber 5
35 #define RegExpICaseStrategyNumber 6
36 #define WordSimilarityStrategyNumber 7
37 #define WordDistanceStrategyNumber 8
38 #define StrictWordSimilarityStrategyNumber 9
39 #define StrictWordDistanceStrategyNumber 10
40 #define EqualStrategyNumber 11
44 #define CMPCHAR(a,b) ( ((a)==(b)) ? 0 : ( ((a)<(b)) ? -1 : 1 ) )
45 #define CMPPCHAR(a,b,i) CMPCHAR( *(((const char*)(a))+i), *(((const char*)(b))+i) )
46 #define CMPTRGM(a,b) ( CMPPCHAR(a,b,0) ? CMPPCHAR(a,b,0) : ( CMPPCHAR(a,b,1) ? CMPPCHAR(a,b,1) : CMPPCHAR(a,b,2) ) )
48 #define CPTRGM(a,b) do { \
49 *(((char*)(a))+0) = *(((char*)(b))+0); \
50 *(((char*)(a))+1) = *(((char*)(b))+1); \
51 *(((char*)(a))+2) = *(((char*)(b))+2); \
55 #define ISWORDCHR(c) (t_isalnum(c))
56 #define ISPRINTABLECHAR(a) ( isascii( *(unsigned char*)(a) ) && (isalnum( *(unsigned char*)(a) ) || *(unsigned char*)(a)==' ') )
58 #define ISWORDCHR(c) (!t_isspace(c))
59 #define ISPRINTABLECHAR(a) ( isascii( *(unsigned char*)(a) ) && isprint( *(unsigned char*)(a) ) )
61 #define ISPRINTABLETRGM(t) ( ISPRINTABLECHAR( ((char*)(t)) ) && ISPRINTABLECHAR( ((char*)(t))+1 ) && ISPRINTABLECHAR( ((char*)(t))+2 ) )
63 #define ISESCAPECHAR(x) (*(x) == '\\')
64 #define ISWILDCARDCHAR(x) (*(x) == '_' || *(x) == '%')
74 #define TRGMHDRSIZE (VARHDRSZ + sizeof(uint8))
77 #define SIGLEN_DEFAULT (sizeof(int) * 3)
78 #define SIGLEN_MAX GISTMaxIndexKeySize
81 #define SIGLENBIT(siglen) ((siglen) * BITBYTE - 1)
85 #define LOOPBYTE(siglen) \
86 for (i = 0; i < (siglen); i++)
88 #define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
89 #define GETBITBYTE(x,i) ( (((char)(x)) >> (i)) & 0x01 )
90 #define CLRBIT(x,i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) )
91 #define SETBIT(x,i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITBYTE ) )
92 #define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 )
94 #define HASHVAL(val, siglen) (((unsigned int)(val)) % SIGLENBIT(siglen))
95 #define HASH(sign, val, siglen) SETBIT((sign), HASHVAL(val, siglen))
99 #define ALLISTRUE 0x04
101 #define ISARRKEY(x) ( ((TRGM*)x)->flag & ARRKEY )
102 #define ISSIGNKEY(x) ( ((TRGM*)x)->flag & SIGNKEY )
103 #define ISALLTRUE(x) ( ((TRGM*)x)->flag & ALLISTRUE )
105 #define CALCGTSIZE(flag, len) ( TRGMHDRSIZE + ( ( (flag) & ARRKEY ) ? ((len)*sizeof(trgm)) : (((flag) & ALLISTRUE) ? 0 : (len)) ) )
106 #define GETSIGN(x) ( (BITVECP)( (char*)x+TRGMHDRSIZE ) )
107 #define GETARR(x) ( (trgm*)( (char*)x+TRGMHDRSIZE ) )
108 #define ARRNELEM(x) ( ( VARSIZE(x) - TRGMHDRSIZE )/sizeof(trgm) )
117 #define CALCSML(count, len1, len2) ((float4) (count)) / ((float4) ((len1) + (len2) - (count)))
119 #define CALCSML(count, len1, len2) ((float4) (count)) / ((float4) (((len1) > (len2)) ? (len1) : (len2)))
#define FLEXIBLE_ARRAY_MEMBER
bool * trgm_presence_map(TRGM *query, TRGM *key)
TRGM * generate_trgm(char *str, int slen)
double strict_word_similarity_threshold
TRGM * generate_wildcard_trgm(const char *str, int slen)
uint32 trgm2int(trgm *ptr)
void compact_trigram(trgm *tptr, char *str, int bytelen)
double word_similarity_threshold
double index_strategy_get_limit(StrategyNumber strategy)
double similarity_threshold
bool trigramsMatchGraph(TrgmPackedGraph *graph, bool *check)
bool trgm_contained_by(TRGM *trg1, TRGM *trg2)
TRGM * createTrgmNFA(text *text_re, Oid collation, TrgmPackedGraph **graph, MemoryContext rcontext)
float4 cnt_sml(TRGM *trg1, TRGM *trg2, bool inexact)