PostgreSQL Source Code git master
Loading...
Searching...
No Matches
btree_float8.c File Reference
#include "postgres.h"
#include "btree_gist.h"
#include "btree_utils_num.h"
#include "utils/float.h"
#include "utils/rel.h"
#include "utils/sortsupport.h"
Include dependency graph for btree_float8.c:

Go to the source code of this file.

Data Structures

struct  float8key
 

Typedefs

typedef struct float8key float8KEY
 

Functions

 PG_FUNCTION_INFO_V1 (gbt_float8_compress)
 
 PG_FUNCTION_INFO_V1 (gbt_float8_fetch)
 
 PG_FUNCTION_INFO_V1 (gbt_float8_union)
 
 PG_FUNCTION_INFO_V1 (gbt_float8_picksplit)
 
 PG_FUNCTION_INFO_V1 (gbt_float8_consistent)
 
 PG_FUNCTION_INFO_V1 (gbt_float8_distance)
 
 PG_FUNCTION_INFO_V1 (gbt_float8_penalty)
 
 PG_FUNCTION_INFO_V1 (gbt_float8_same)
 
 PG_FUNCTION_INFO_V1 (gbt_float8_sortsupport)
 
static bool gbt_float8gt (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_float8ge (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_float8eq (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_float8le (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_float8lt (const void *a, const void *b, FmgrInfo *flinfo)
 
static int gbt_float8key_cmp (const void *a, const void *b, FmgrInfo *flinfo)
 
static float8 gbt_float8_dist (const void *a, const void *b, FmgrInfo *flinfo)
 
 PG_FUNCTION_INFO_V1 (float8_dist)
 
Datum float8_dist (PG_FUNCTION_ARGS)
 
Datum gbt_float8_compress (PG_FUNCTION_ARGS)
 
Datum gbt_float8_fetch (PG_FUNCTION_ARGS)
 
Datum gbt_float8_consistent (PG_FUNCTION_ARGS)
 
Datum gbt_float8_distance (PG_FUNCTION_ARGS)
 
Datum gbt_float8_union (PG_FUNCTION_ARGS)
 
Datum gbt_float8_penalty (PG_FUNCTION_ARGS)
 
Datum gbt_float8_picksplit (PG_FUNCTION_ARGS)
 
Datum gbt_float8_same (PG_FUNCTION_ARGS)
 
static int gbt_float8_ssup_cmp (Datum x, Datum y, SortSupport ssup)
 
Datum gbt_float8_sortsupport (PG_FUNCTION_ARGS)
 

Variables

static const gbtree_ninfo tinfo
 

Typedef Documentation

◆ float8KEY

Function Documentation

◆ float8_dist()

Datum float8_dist ( PG_FUNCTION_ARGS  )

Definition at line 104 of file btree_float8.c.

105{
108 float8 r;
109
110 r = a - b;
111 if (unlikely(isinf(r)) && !isinf(a) && !isinf(b))
113
115}
double float8
Definition c.h:644
#define unlikely(x)
Definition c.h:412
pg_noinline void float_overflow_error(void)
Definition float.c:86
#define PG_GETARG_FLOAT8(n)
Definition fmgr.h:283
#define PG_RETURN_FLOAT8(x)
Definition fmgr.h:369
int b
Definition isn.c:74
int a
Definition isn.c:73
static int fb(int x)

References a, b, fb(), float_overflow_error(), PG_GETARG_FLOAT8, PG_RETURN_FLOAT8, and unlikely.

◆ gbt_float8_compress()

Datum gbt_float8_compress ( PG_FUNCTION_ARGS  )

Definition at line 123 of file btree_float8.c.

124{
125 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
126
128}
static const gbtree_ninfo tinfo
GISTENTRY * gbt_num_compress(GISTENTRY *entry, const gbtree_ninfo *tinfo)
#define PG_GETARG_POINTER(n)
Definition fmgr.h:277
#define PG_RETURN_POINTER(x)
Definition fmgr.h:363

References gbt_num_compress(), PG_GETARG_POINTER, PG_RETURN_POINTER, and tinfo.

◆ gbt_float8_consistent()

Datum gbt_float8_consistent ( PG_FUNCTION_ARGS  )

Definition at line 139 of file btree_float8.c.

140{
141 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
142 float8 query = PG_GETARG_FLOAT8(1);
144#ifdef NOT_USED
145 Oid subtype = PG_GETARG_OID(3);
146#endif
147 bool *recheck = (bool *) PG_GETARG_POINTER(4);
150
151 /* All cases served by this function are exact */
152 *recheck = false;
153
154 key.lower = (GBT_NUMKEY *) &kkk->lower;
155 key.upper = (GBT_NUMKEY *) &kkk->upper;
156
157 PG_RETURN_BOOL(gbt_num_consistent(&key, &query, &strategy,
158 GIST_LEAF(entry), &tinfo,
159 fcinfo->flinfo));
160}
bool gbt_num_consistent(const GBT_NUMKEY_R *key, const void *query, const StrategyNumber *strategy, bool is_leaf, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)
char GBT_NUMKEY
#define PG_GETARG_OID(n)
Definition fmgr.h:275
#define PG_GETARG_UINT16(n)
Definition fmgr.h:272
#define PG_RETURN_BOOL(x)
Definition fmgr.h:360
#define GIST_LEAF(entry)
Definition gist.h:171
static Pointer DatumGetPointer(Datum X)
Definition postgres.h:342
unsigned int Oid
uint16 StrategyNumber
Definition stratnum.h:22
Datum key
Definition gist.h:161

References DatumGetPointer(), fb(), gbt_num_consistent(), GIST_LEAF, GISTENTRY::key, PG_GETARG_FLOAT8, PG_GETARG_OID, PG_GETARG_POINTER, PG_GETARG_UINT16, PG_RETURN_BOOL, and tinfo.

◆ gbt_float8_dist()

static float8 gbt_float8_dist ( const void a,
const void b,
FmgrInfo flinfo 
)
static

Definition at line 74 of file btree_float8.c.

75{
76 float8 arg1 = *(const float8 *) a;
77 float8 arg2 = *(const float8 *) b;
78 float8 r;
79
80 r = arg1 - arg2;
81 if (unlikely(isinf(r)) && !isinf(arg1) && !isinf(arg2))
83 return fabs(r);
84}

References a, b, fb(), float_overflow_error(), and unlikely.

◆ gbt_float8_distance()

Datum gbt_float8_distance ( PG_FUNCTION_ARGS  )

Definition at line 163 of file btree_float8.c.

164{
165 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
166 float8 query = PG_GETARG_FLOAT8(1);
167#ifdef NOT_USED
168 Oid subtype = PG_GETARG_OID(3);
169#endif
172
173 key.lower = (GBT_NUMKEY *) &kkk->lower;
174 key.upper = (GBT_NUMKEY *) &kkk->upper;
175
176 PG_RETURN_FLOAT8(gbt_num_distance(&key, &query, GIST_LEAF(entry),
177 &tinfo, fcinfo->flinfo));
178}
float8 gbt_num_distance(const GBT_NUMKEY_R *key, const void *query, bool is_leaf, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)

References DatumGetPointer(), fb(), gbt_num_distance(), GIST_LEAF, GISTENTRY::key, PG_GETARG_FLOAT8, PG_GETARG_OID, PG_GETARG_POINTER, PG_RETURN_FLOAT8, and tinfo.

◆ gbt_float8_fetch()

Datum gbt_float8_fetch ( PG_FUNCTION_ARGS  )

Definition at line 131 of file btree_float8.c.

132{
133 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
134
136}
GISTENTRY * gbt_num_fetch(GISTENTRY *entry, const gbtree_ninfo *tinfo)

References gbt_num_fetch(), PG_GETARG_POINTER, PG_RETURN_POINTER, and tinfo.

◆ gbt_float8_penalty()

Datum gbt_float8_penalty ( PG_FUNCTION_ARGS  )

Definition at line 191 of file btree_float8.c.

192{
195 float *result = (float *) PG_GETARG_POINTER(2);
196
197 penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper);
198
199 PG_RETURN_POINTER(result);
200}
#define penalty_num(result, olower, oupper, nlower, nupper)

References DatumGetPointer(), fb(), penalty_num, PG_GETARG_POINTER, and PG_RETURN_POINTER.

◆ gbt_float8_picksplit()

Datum gbt_float8_picksplit ( PG_FUNCTION_ARGS  )

Definition at line 203 of file btree_float8.c.

204{
207 &tinfo, fcinfo->flinfo));
208}
GIST_SPLITVEC * gbt_num_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)

References gbt_num_picksplit(), PG_GETARG_POINTER, PG_RETURN_POINTER, and tinfo.

◆ gbt_float8_same()

Datum gbt_float8_same ( PG_FUNCTION_ARGS  )

Definition at line 211 of file btree_float8.c.

212{
215 bool *result = (bool *) PG_GETARG_POINTER(2);
216
217 *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
218 PG_RETURN_POINTER(result);
219}
bool gbt_num_same(const GBT_NUMKEY *a, const GBT_NUMKEY *b, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)

References fb(), gbt_num_same(), PG_GETARG_POINTER, PG_RETURN_POINTER, and tinfo.

◆ gbt_float8_sortsupport()

Datum gbt_float8_sortsupport ( PG_FUNCTION_ARGS  )

Definition at line 232 of file btree_float8.c.

233{
235
237 ssup->ssup_extra = NULL;
238
240}
static int gbt_float8_ssup_cmp(Datum x, Datum y, SortSupport ssup)
#define PG_RETURN_VOID()
Definition fmgr.h:350
struct SortSupportData * SortSupport
Definition sortsupport.h:58
int(* comparator)(Datum x, Datum y, SortSupport ssup)

References SortSupportData::comparator, fb(), gbt_float8_ssup_cmp(), PG_GETARG_POINTER, PG_RETURN_VOID, and SortSupportData::ssup_extra.

◆ gbt_float8_ssup_cmp()

static int gbt_float8_ssup_cmp ( Datum  x,
Datum  y,
SortSupport  ssup 
)
static

Definition at line 222 of file btree_float8.c.

223{
226
227 /* for leaf items we expect lower == upper, so only compare lower */
228 return float8_cmp_internal(arg1->lower, arg2->lower);
229}
int float8_cmp_internal(float8 a, float8 b)
Definition float.c:910
int y
Definition isn.c:76
int x
Definition isn.c:75

References DatumGetPointer(), fb(), float8_cmp_internal(), x, and y.

Referenced by gbt_float8_sortsupport().

◆ gbt_float8_union()

Datum gbt_float8_union ( PG_FUNCTION_ARGS  )

Definition at line 181 of file btree_float8.c.

182{
184 void *out = palloc(sizeof(float8KEY));
185
186 *(int *) PG_GETARG_POINTER(1) = sizeof(float8KEY);
187 PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo));
188}
struct float8key float8KEY
void * gbt_num_union(GBT_NUMKEY *out, const GistEntryVector *entryvec, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)
void * palloc(Size size)
Definition mcxt.c:1387

References fb(), gbt_num_union(), palloc(), PG_GETARG_POINTER, PG_RETURN_POINTER, and tinfo.

◆ gbt_float8eq()

static bool gbt_float8eq ( const void a,
const void b,
FmgrInfo flinfo 
)
static

Definition at line 41 of file btree_float8.c.

42{
43 return (*((const float8 *) a) == *((const float8 *) b));
44}

References a, and b.

◆ gbt_float8ge()

static bool gbt_float8ge ( const void a,
const void b,
FmgrInfo flinfo 
)
static

Definition at line 36 of file btree_float8.c.

37{
38 return (*((const float8 *) a) >= *((const float8 *) b));
39}

References a, and b.

◆ gbt_float8gt()

static bool gbt_float8gt ( const void a,
const void b,
FmgrInfo flinfo 
)
static

Definition at line 31 of file btree_float8.c.

32{
33 return (*((const float8 *) a) > *((const float8 *) b));
34}

References a, and b.

◆ gbt_float8key_cmp()

static int gbt_float8key_cmp ( const void a,
const void b,
FmgrInfo flinfo 
)
static

Definition at line 57 of file btree_float8.c.

58{
59 float8KEY *ia = (float8KEY *) (((const Nsrt *) a)->t);
60 float8KEY *ib = (float8KEY *) (((const Nsrt *) b)->t);
61
62 if (ia->lower == ib->lower)
63 {
64 if (ia->upper == ib->upper)
65 return 0;
66
67 return (ia->upper > ib->upper) ? 1 : -1;
68 }
69
70 return (ia->lower > ib->lower) ? 1 : -1;
71}

References a, b, and fb().

◆ gbt_float8le()

static bool gbt_float8le ( const void a,
const void b,
FmgrInfo flinfo 
)
static

Definition at line 46 of file btree_float8.c.

47{
48 return (*((const float8 *) a) <= *((const float8 *) b));
49}

References a, and b.

◆ gbt_float8lt()

static bool gbt_float8lt ( const void a,
const void b,
FmgrInfo flinfo 
)
static

Definition at line 51 of file btree_float8.c.

52{
53 return (*((const float8 *) a) < *((const float8 *) b));
54}

References a, and b.

◆ PG_FUNCTION_INFO_V1() [1/10]

PG_FUNCTION_INFO_V1 ( float8_dist  )

◆ PG_FUNCTION_INFO_V1() [2/10]

PG_FUNCTION_INFO_V1 ( gbt_float8_compress  )

◆ PG_FUNCTION_INFO_V1() [3/10]

PG_FUNCTION_INFO_V1 ( gbt_float8_consistent  )

◆ PG_FUNCTION_INFO_V1() [4/10]

PG_FUNCTION_INFO_V1 ( gbt_float8_distance  )

◆ PG_FUNCTION_INFO_V1() [5/10]

PG_FUNCTION_INFO_V1 ( gbt_float8_fetch  )

◆ PG_FUNCTION_INFO_V1() [6/10]

PG_FUNCTION_INFO_V1 ( gbt_float8_penalty  )

◆ PG_FUNCTION_INFO_V1() [7/10]

PG_FUNCTION_INFO_V1 ( gbt_float8_picksplit  )

◆ PG_FUNCTION_INFO_V1() [8/10]

PG_FUNCTION_INFO_V1 ( gbt_float8_same  )

◆ PG_FUNCTION_INFO_V1() [9/10]

PG_FUNCTION_INFO_V1 ( gbt_float8_sortsupport  )

◆ PG_FUNCTION_INFO_V1() [10/10]

PG_FUNCTION_INFO_V1 ( gbt_float8_union  )

Variable Documentation

◆ tinfo

const gbtree_ninfo tinfo
static
Initial value:
=
{
sizeof(float8),
16,
}
static bool gbt_float8eq(const void *a, const void *b, FmgrInfo *flinfo)
static bool gbt_float8gt(const void *a, const void *b, FmgrInfo *flinfo)
static float8 gbt_float8_dist(const void *a, const void *b, FmgrInfo *flinfo)
static bool gbt_float8le(const void *a, const void *b, FmgrInfo *flinfo)
static bool gbt_float8ge(const void *a, const void *b, FmgrInfo *flinfo)
static int gbt_float8key_cmp(const void *a, const void *b, FmgrInfo *flinfo)
static bool gbt_float8lt(const void *a, const void *b, FmgrInfo *flinfo)
@ gbt_t_float8
Definition btree_gist.h:21

Definition at line 87 of file btree_float8.c.

88{
90 sizeof(float8),
91 16, /* sizeof(gbtreekey16) */
99};

Referenced by gbt_float8_compress(), gbt_float8_consistent(), gbt_float8_distance(), gbt_float8_fetch(), gbt_float8_picksplit(), gbt_float8_same(), and gbt_float8_union().