mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Add KNNGIST support to contrib/btree_gist.
This extends GiST's support for nearest-neighbor searches to many of the standard data types. Teodor Sigaev
This commit is contained in:
@ -40,24 +40,25 @@ typedef struct
|
||||
|
||||
/* Methods */
|
||||
|
||||
bool (*f_gt) (const void *, const void *); /* greater then */
|
||||
bool (*f_ge) (const void *, const void *); /* greater equal */
|
||||
bool (*f_gt) (const void *, const void *); /* greater than */
|
||||
bool (*f_ge) (const void *, const void *); /* greater or equal */
|
||||
bool (*f_eq) (const void *, const void *); /* equal */
|
||||
bool (*f_le) (const void *, const void *); /* less equal */
|
||||
bool (*f_lt) (const void *, const void *); /* less then */
|
||||
bool (*f_le) (const void *, const void *); /* less or equal */
|
||||
bool (*f_lt) (const void *, const void *); /* less than */
|
||||
int (*f_cmp) (const void *, const void *); /* key compare function */
|
||||
float8 (*f_dist) (const void *, const void *); /* key distance function */
|
||||
} gbtree_ninfo;
|
||||
|
||||
|
||||
/*
|
||||
* Numeric btree functions
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Note: The factor 0.49 in following macro avoids floating point overflows
|
||||
*/
|
||||
*/
|
||||
#define penalty_num(result,olower,oupper,nlower,nupper) do { \
|
||||
double tmp = 0.0F; \
|
||||
(*(result)) = 0.0F; \
|
||||
@ -91,11 +92,37 @@ typedef struct
|
||||
(ivp)->month * (30.0 * SECS_PER_DAY))
|
||||
#endif
|
||||
|
||||
#define GET_FLOAT_DISTANCE(t, arg1, arg2) Abs( ((float8) *((const t *) (arg1))) - ((float8) *((const t *) (arg2))) )
|
||||
|
||||
#define SAMESIGN(a,b) (((a) < 0) == ((b) < 0))
|
||||
|
||||
/*
|
||||
* check to see if a float4/8 val has underflowed or overflowed
|
||||
* borrowed from src/backend/utils/adt/float.c
|
||||
*/
|
||||
#define CHECKFLOATVAL(val, inf_is_valid, zero_is_valid) \
|
||||
do { \
|
||||
if (isinf(val) && !(inf_is_valid)) \
|
||||
ereport(ERROR, \
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), \
|
||||
errmsg("value out of range: overflow"))); \
|
||||
\
|
||||
if ((val) == 0.0 && !(zero_is_valid)) \
|
||||
ereport(ERROR, \
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), \
|
||||
errmsg("value out of range: underflow"))); \
|
||||
} while(0)
|
||||
|
||||
|
||||
extern Interval *abs_interval(Interval *a);
|
||||
|
||||
extern bool gbt_num_consistent(const GBT_NUMKEY_R *key, const void *query,
|
||||
const StrategyNumber *strategy, bool is_leaf,
|
||||
const gbtree_ninfo *tinfo);
|
||||
|
||||
extern float8 gbt_num_distance(const GBT_NUMKEY_R *key, const void *query,
|
||||
bool is_leaf, const gbtree_ninfo *tinfo);
|
||||
|
||||
extern GIST_SPLITVEC *gbt_num_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v,
|
||||
const gbtree_ninfo *tinfo);
|
||||
|
||||
|
Reference in New Issue
Block a user