PostgreSQL Source Code
git master
|
#include "access/gist.h"
#include "access/itup.h"
#include "access/stratnum.h"
#include "storage/bufpage.h"
Go to the source code of this file.
Data Structures | |
struct | TRGM |
Macros | |
#define | LPADDING 2 |
#define | RPADDING 1 |
#define | KEEPONLYALNUM |
#define | IGNORECASE |
#define | DIVUNION |
#define | SimilarityStrategyNumber 1 |
#define | DistanceStrategyNumber 2 |
#define | LikeStrategyNumber 3 |
#define | ILikeStrategyNumber 4 |
#define | RegExpStrategyNumber 5 |
#define | RegExpICaseStrategyNumber 6 |
#define | WordSimilarityStrategyNumber 7 |
#define | WordDistanceStrategyNumber 8 |
#define | StrictWordSimilarityStrategyNumber 9 |
#define | StrictWordDistanceStrategyNumber 10 |
#define | EqualStrategyNumber 11 |
#define | CMPCHAR(a, b) ( ((a)==(b)) ? 0 : ( ((a)<(b)) ? -1 : 1 ) ) |
#define | CMPPCHAR(a, b, i) CMPCHAR( *(((const char*)(a))+i), *(((const char*)(b))+i) ) |
#define | CMPTRGM(a, b) ( CMPPCHAR(a,b,0) ? CMPPCHAR(a,b,0) : ( CMPPCHAR(a,b,1) ? CMPPCHAR(a,b,1) : CMPPCHAR(a,b,2) ) ) |
#define | CPTRGM(a, b) |
#define | ISWORDCHR(c) (t_isalpha(c) || t_isdigit(c)) |
#define | ISPRINTABLECHAR(a) ( isascii( *(unsigned char*)(a) ) && (isalnum( *(unsigned char*)(a) ) || *(unsigned char*)(a)==' ') ) |
#define | ISPRINTABLETRGM(t) ( ISPRINTABLECHAR( ((char*)(t)) ) && ISPRINTABLECHAR( ((char*)(t))+1 ) && ISPRINTABLECHAR( ((char*)(t))+2 ) ) |
#define | ISESCAPECHAR(x) (*(x) == '\\') /* Wildcard escape character */ |
#define | ISWILDCARDCHAR(x) |
#define | TRGMHDRSIZE (VARHDRSZ + sizeof(uint8)) |
#define | SIGLEN_DEFAULT (sizeof(int) * 3) |
#define | SIGLEN_MAX GISTMaxIndexKeySize |
#define | BITBYTE 8 |
#define | SIGLENBIT(siglen) ((siglen) * BITBYTE - 1) /* see makesign */ |
#define | LOOPBYTE(siglen) for (i = 0; i < (siglen); i++) |
#define | GETBYTE(x, i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) ) |
#define | GETBITBYTE(x, i) ( (((char)(x)) >> (i)) & 0x01 ) |
#define | CLRBIT(x, i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) ) |
#define | SETBIT(x, i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITBYTE ) ) |
#define | GETBIT(x, i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 ) |
#define | HASHVAL(val, siglen) (((unsigned int)(val)) % SIGLENBIT(siglen)) |
#define | HASH(sign, val, siglen) SETBIT((sign), HASHVAL(val, siglen)) |
#define | ARRKEY 0x01 |
#define | SIGNKEY 0x02 |
#define | ALLISTRUE 0x04 |
#define | ISARRKEY(x) ( ((TRGM*)x)->flag & ARRKEY ) |
#define | ISSIGNKEY(x) ( ((TRGM*)x)->flag & SIGNKEY ) |
#define | ISALLTRUE(x) ( ((TRGM*)x)->flag & ALLISTRUE ) |
#define | CALCGTSIZE(flag, len) ( TRGMHDRSIZE + ( ( (flag) & ARRKEY ) ? ((len)*sizeof(trgm)) : (((flag) & ALLISTRUE) ? 0 : (len)) ) ) |
#define | GETSIGN(x) ( (BITVECP)( (char*)x+TRGMHDRSIZE ) ) |
#define | GETARR(x) ( (trgm*)( (char*)x+TRGMHDRSIZE ) ) |
#define | ARRNELEM(x) ( ( VARSIZE(x) - TRGMHDRSIZE )/sizeof(trgm) ) |
#define | CALCSML(count, len1, len2) ((float4) (count)) / ((float4) ((len1) + (len2) - (count))) |
Typedefs | |
typedef char | trgm[3] |
typedef char * | BITVECP |
typedef struct TrgmPackedGraph | TrgmPackedGraph |
Functions | |
double | index_strategy_get_limit (StrategyNumber strategy) |
uint32 | trgm2int (trgm *ptr) |
void | compact_trigram (trgm *tptr, char *str, int bytelen) |
TRGM * | generate_trgm (char *str, int slen) |
TRGM * | generate_wildcard_trgm (const char *str, int slen) |
float4 | cnt_sml (TRGM *trg1, TRGM *trg2, bool inexact) |
bool | trgm_contained_by (TRGM *trg1, TRGM *trg2) |
bool * | trgm_presence_map (TRGM *query, TRGM *key) |
TRGM * | createTrgmNFA (text *text_re, Oid collation, TrgmPackedGraph **graph, MemoryContext rcontext) |
bool | trigramsMatchGraph (TrgmPackedGraph *graph, bool *check) |
Variables | |
double | similarity_threshold |
double | word_similarity_threshold |
double | strict_word_similarity_threshold |
#define ARRKEY 0x01 |
Definition at line 97 of file trgm.h.
Referenced by expandColorTrigrams(), generate_trgm(), and generate_wildcard_trgm().
#define ARRNELEM | ( | x | ) | ( ( VARSIZE(x) - TRGMHDRSIZE )/sizeof(trgm) ) |
Definition at line 108 of file trgm.h.
Referenced by cnt_sml(), cnt_sml_sign_common(), gin_extract_query_trgm(), gin_extract_value_trgm(), gtrgm_consistent(), gtrgm_distance(), gtrgm_same(), makesign(), show_trgm(), trgm_contained_by(), trgm_presence_map(), and unionkey().
Definition at line 117 of file trgm.h.
Referenced by cnt_sml(), and iterate_word_similarity().
#define CMPCHAR | ( | a, | |
b | |||
) | ( ((a)==(b)) ? 0 : ( ((a)<(b)) ? -1 : 1 ) ) |
#define CMPTRGM | ( | a, | |
b | |||
) | ( CMPPCHAR(a,b,0) ? CMPPCHAR(a,b,0) : ( CMPPCHAR(a,b,1) ? CMPPCHAR(a,b,1) : CMPPCHAR(a,b,2) ) ) |
Definition at line 46 of file trgm.h.
Referenced by calc_word_similarity(), cnt_sml(), comp_ptrgm(), comp_trgm(), gtrgm_same(), trgm_contained_by(), and trgm_presence_map().
#define CPTRGM | ( | a, | |
b | |||
) |
Definition at line 48 of file trgm.h.
Referenced by cnt_sml_sign_common(), compact_trigram(), gtrgm_consistent(), make_trigrams(), makesign(), show_trgm(), and unionkey().
#define DistanceStrategyNumber 2 |
Definition at line 31 of file trgm.h.
Referenced by gtrgm_distance().
#define EqualStrategyNumber 11 |
Definition at line 40 of file trgm.h.
Referenced by gin_extract_query_trgm(), gin_trgm_consistent(), gin_trgm_triconsistent(), and gtrgm_consistent().
#define GETARR | ( | x | ) | ( (trgm*)( (char*)x+TRGMHDRSIZE ) ) |
Definition at line 107 of file trgm.h.
Referenced by cnt_sml(), cnt_sml_sign_common(), expandColorTrigrams(), generate_trgm(), generate_wildcard_trgm(), gin_extract_query_trgm(), gin_extract_value_trgm(), gtrgm_consistent(), gtrgm_same(), makesign(), packArcInfoCmp(), show_trgm(), trgm_contained_by(), trgm_presence_map(), and unionkey().
#define GETSIGN | ( | x | ) | ( (BITVECP)( (char*)x+TRGMHDRSIZE ) ) |
#define ILikeStrategyNumber 4 |
Definition at line 33 of file trgm.h.
Referenced by gin_extract_query_trgm(), gin_trgm_consistent(), gin_trgm_triconsistent(), and gtrgm_consistent().
Definition at line 101 of file trgm.h.
Referenced by fillcache(), and gtrgm_penalty().
#define ISESCAPECHAR | ( | x | ) | (*(x) == '\\') /* Wildcard escape character */ |
Definition at line 63 of file trgm.h.
Referenced by get_wildcard_part().
#define ISPRINTABLECHAR | ( | a | ) | ( isascii( *(unsigned char*)(a) ) && (isalnum( *(unsigned char*)(a) ) || *(unsigned char*)(a)==' ') ) |
#define ISPRINTABLETRGM | ( | t | ) | ( ISPRINTABLECHAR( ((char*)(t)) ) && ISPRINTABLECHAR( ((char*)(t))+1 ) && ISPRINTABLECHAR( ((char*)(t))+2 ) ) |
Definition at line 61 of file trgm.h.
Referenced by show_trgm().
Definition at line 102 of file trgm.h.
Referenced by gtrgm_compress(), gtrgm_same(), and unionkey().
#define ISWILDCARDCHAR | ( | x | ) |
Definition at line 64 of file trgm.h.
Referenced by get_wildcard_part().
Definition at line 55 of file trgm.h.
Referenced by find_word(), get_wildcard_part(), and getColorInfo().
#define LikeStrategyNumber 3 |
Definition at line 32 of file trgm.h.
Referenced by gin_extract_query_trgm(), gin_trgm_consistent(), gin_trgm_triconsistent(), and gtrgm_consistent().
#define LPADDING 2 |
Definition at line 16 of file trgm.h.
Referenced by generate_trgm_only(), generate_wildcard_trgm(), and get_wildcard_part().
#define RegExpICaseStrategyNumber 6 |
Definition at line 35 of file trgm.h.
Referenced by gin_extract_query_trgm(), gin_trgm_consistent(), gin_trgm_triconsistent(), and gtrgm_consistent().
#define RegExpStrategyNumber 5 |
Definition at line 34 of file trgm.h.
Referenced by gin_extract_query_trgm(), gin_trgm_consistent(), gin_trgm_triconsistent(), and gtrgm_consistent().
#define RPADDING 1 |
Definition at line 17 of file trgm.h.
Referenced by generate_trgm_only(), generate_wildcard_trgm(), and get_wildcard_part().
#define SIGLEN_MAX GISTMaxIndexKeySize |
#define SIGNKEY 0x02 |
Definition at line 98 of file trgm.h.
Referenced by gtrgm_alloc().
#define SimilarityStrategyNumber 1 |
Definition at line 30 of file trgm.h.
Referenced by gin_extract_query_trgm(), gin_trgm_consistent(), gin_trgm_triconsistent(), gtrgm_consistent(), and index_strategy_get_limit().
#define StrictWordDistanceStrategyNumber 10 |
Definition at line 39 of file trgm.h.
Referenced by gtrgm_distance().
#define StrictWordSimilarityStrategyNumber 9 |
Definition at line 38 of file trgm.h.
Referenced by gin_extract_query_trgm(), gin_trgm_consistent(), gin_trgm_triconsistent(), gtrgm_consistent(), and index_strategy_get_limit().
Definition at line 74 of file trgm.h.
Referenced by expandColorTrigrams(), generate_trgm(), and generate_wildcard_trgm().
#define WordDistanceStrategyNumber 8 |
Definition at line 37 of file trgm.h.
Referenced by gtrgm_distance().
#define WordSimilarityStrategyNumber 7 |
Definition at line 36 of file trgm.h.
Referenced by gin_extract_query_trgm(), gin_trgm_consistent(), gin_trgm_triconsistent(), gtrgm_consistent(), and index_strategy_get_limit().
typedef struct TrgmPackedGraph TrgmPackedGraph |
Definition at line 996 of file trgm_op.c.
References ARRNELEM, CALCSML, CMPTRGM, and GETARR.
Referenced by gtrgm_consistent(), gtrgm_distance(), and similarity().
void compact_trigram | ( | trgm * | tptr, |
char * | str, | ||
int | bytelen | ||
) |
Definition at line 198 of file trgm_op.c.
References COMP_LEGACY_CRC32, CPTRGM, FIN_LEGACY_CRC32, and INIT_LEGACY_CRC32.
Referenced by fillTrgm(), and make_trigrams().
TRGM* createTrgmNFA | ( | text * | text_re, |
Oid | collation, | ||
TrgmPackedGraph ** | graph, | ||
MemoryContext | rcontext | ||
) |
Definition at line 521 of file trgm_regexp.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, createTrgmNFAInternal(), CurrentMemoryContext, MemoryContextDelete(), MemoryContextSwitchTo(), PG_END_TRY, PG_FINALLY, pg_regfree(), PG_TRY, RE_compile(), REG_ADVANCED, and REG_ICASE.
Referenced by gin_extract_query_trgm(), and gtrgm_consistent().
TRGM* generate_trgm | ( | char * | str, |
int | slen | ||
) |
Definition at line 356 of file trgm_op.c.
References ARRKEY, CALCGTSIZE, comp_trgm(), TRGM::flag, generate_trgm_only(), GETARR, palloc(), protect_out_of_mem(), qsort, qunique(), SET_VARSIZE, and TRGMHDRSIZE.
Referenced by gin_extract_query_trgm(), gin_extract_value_trgm(), gtrgm_compress(), gtrgm_consistent(), gtrgm_distance(), show_trgm(), and similarity().
TRGM* generate_wildcard_trgm | ( | const char * | str, |
int | slen | ||
) |
Definition at line 866 of file trgm_op.c.
References ARRKEY, buf, CALCGTSIZE, comp_trgm(), TRGM::flag, get_wildcard_part(), GETARR, lowerstr_with_len(), LPADDING, make_trigrams(), palloc(), pfree(), protect_out_of_mem(), qsort, qunique(), RPADDING, SET_VARSIZE, generate_unaccent_rules::str, and TRGMHDRSIZE.
Referenced by gin_extract_query_trgm(), and gtrgm_consistent().
double index_strategy_get_limit | ( | StrategyNumber | strategy | ) |
Definition at line 132 of file trgm_op.c.
References elog, ERROR, similarity_threshold, SimilarityStrategyNumber, strict_word_similarity_threshold, StrictWordSimilarityStrategyNumber, word_similarity_threshold, and WordSimilarityStrategyNumber.
Referenced by gin_trgm_consistent(), gin_trgm_triconsistent(), and gtrgm_consistent().
Definition at line 935 of file trgm_op.c.
References val.
Referenced by gin_extract_query_trgm(), gin_extract_value_trgm(), and show_trgm().
bool trigramsMatchGraph | ( | TrgmPackedGraph * | graph, |
bool * | check | ||
) |
Definition at line 636 of file trgm_regexp.c.
References TrgmPackedState::arcs, TrgmPackedState::arcsCount, TrgmPackedArc::colorTrgm, TrgmPackedGraph::colorTrigramGroups, TrgmPackedGraph::colorTrigramsActive, TrgmPackedGraph::colorTrigramsCount, i, TrgmPackedGraph::states, TrgmPackedGraph::statesActive, TrgmPackedGraph::statesCount, TrgmPackedGraph::statesQueue, and TrgmPackedArc::targetState.
Referenced by gin_trgm_consistent(), gin_trgm_triconsistent(), and gtrgm_consistent().
double similarity_threshold |
Definition at line 19 of file trgm_op.c.
Referenced by _PG_init(), index_strategy_get_limit(), set_limit(), show_limit(), and similarity_op().
double strict_word_similarity_threshold |
Definition at line 21 of file trgm_op.c.
Referenced by _PG_init(), index_strategy_get_limit(), iterate_word_similarity(), strict_word_similarity_commutator_op(), and strict_word_similarity_op().
double word_similarity_threshold |
Definition at line 20 of file trgm_op.c.
Referenced by _PG_init(), index_strategy_get_limit(), iterate_word_similarity(), word_similarity_commutator_op(), and word_similarity_op().