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_isalnum(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 ARRNELEM | ( | x | ) | ( ( VARSIZE(x) - TRGMHDRSIZE )/sizeof(trgm) ) |
#define ISPRINTABLETRGM | ( | t | ) | ( ISPRINTABLECHAR( ((char*)(t)) ) && ISPRINTABLECHAR( ((char*)(t))+1 ) && ISPRINTABLECHAR( ((char*)(t))+2 ) ) |
#define ISWILDCARDCHAR | ( | x | ) |
#define SIGLEN_MAX GISTMaxIndexKeySize |
typedef struct TrgmPackedGraph TrgmPackedGraph |
Definition at line 992 of file trgm_op.c.
References ARRNELEM, CALCSML, CMPTRGM, GETARR, and res.
Referenced by gtrgm_consistent(), gtrgm_distance(), and similarity().
void compact_trigram | ( | trgm * | tptr, |
char * | str, | ||
int | bytelen | ||
) |
Definition at line 199 of file trgm_op.c.
References COMP_LEGACY_CRC32, CPTRGM, crc, FIN_LEGACY_CRC32, INIT_LEGACY_CRC32, and str.
Referenced by fillTrgm(), and make_trigrams().
TRGM* createTrgmNFA | ( | text * | text_re, |
Oid | collation, | ||
TrgmPackedGraph ** | graph, | ||
MemoryContext | rcontext | ||
) |
Definition at line 522 of file trgm_regexp.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, createTrgmNFAInternal(), CurrentMemoryContext, MemoryContextDelete(), MemoryContextSwitchTo(), RE_compile(), REG_ADVANCED, REG_ICASE, REG_NOSUB, and regex_t.
Referenced by gin_extract_query_trgm(), and gtrgm_consistent().
TRGM* generate_trgm | ( | char * | str, |
int | slen | ||
) |
Definition at line 357 of file trgm_op.c.
References ARRKEY, CALCGTSIZE, comp_trgm(), TRGM::flag, generate_trgm_only(), GETARR, len, palloc(), protect_out_of_mem(), qsort, qunique(), SET_VARSIZE, str, 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 867 of file trgm_op.c.
References ARRKEY, buf, CALCGTSIZE, comp_trgm(), TRGM::flag, get_wildcard_part(), GETARR, len, lowerstr_with_len(), LPADDING, make_trigrams(), palloc(), pfree(), protect_out_of_mem(), qsort, qunique(), RPADDING, SET_VARSIZE, str, and TRGMHDRSIZE.
Referenced by gin_extract_query_trgm(), and gtrgm_consistent().
double index_strategy_get_limit | ( | StrategyNumber | strategy | ) |
Definition at line 133 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 936 of file trgm_op.c.
References val.
Referenced by gin_extract_query_trgm(), gin_extract_value_trgm(), and show_trgm().
Definition at line 1079 of file trgm_op.c.
References ARRNELEM, CMPTRGM, GETARR, i, sort-test::key, palloc0(), and res.
Referenced by gtrgm_consistent().
bool trigramsMatchGraph | ( | TrgmPackedGraph * | graph, |
bool * | check | ||
) |
Definition at line 626 of file trgm_regexp.c.
References TrgmPackedGraph::colorTrigramGroups, TrgmPackedGraph::colorTrigramsActive, TrgmPackedGraph::colorTrigramsCount, i, j, TrgmPackedGraph::states, TrgmPackedGraph::statesActive, TrgmPackedGraph::statesCount, and TrgmPackedGraph::statesQueue.
Referenced by gin_trgm_consistent(), gin_trgm_triconsistent(), and gtrgm_consistent().
|
extern |
Definition at line 22 of file trgm_op.c.
Referenced by _PG_init(), index_strategy_get_limit(), set_limit(), show_limit(), and similarity_op().
|
extern |
Definition at line 24 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().
|
extern |
Definition at line 23 of file trgm_op.c.
Referenced by _PG_init(), index_strategy_get_limit(), iterate_word_similarity(), word_similarity_commutator_op(), and word_similarity_op().