Thanks to visit codestin.com
Credit goes to doxygen.postgresql.org

PostgreSQL Source Code git master
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

typedef struct float8key 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
114 PG_RETURN_FLOAT8(fabs(r));
115}
double float8
Definition: c.h:636
#define unlikely(x)
Definition: c.h:403
pg_noinline void float_overflow_error(void)
Definition: float.c:86
#define PG_GETARG_FLOAT8(n)
Definition: fmgr.h:282
#define PG_RETURN_FLOAT8(x)
Definition: fmgr.h:367
int b
Definition: isn.c:74
int a
Definition: isn.c:73

References a, b, 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
Definition: btree_float8.c:87
GISTENTRY * gbt_num_compress(GISTENTRY *entry, const gbtree_ninfo *tinfo)
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:276
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:361

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
145 /* Oid subtype = PG_GETARG_OID(3); */
146 bool *recheck = (bool *) PG_GETARG_POINTER(4);
147 float8KEY *kkk = (float8KEY *) DatumGetPointer(entry->key);
149
150 /* All cases served by this function are exact */
151 *recheck = false;
152
153 key.lower = (GBT_NUMKEY *) &kkk->lower;
154 key.upper = (GBT_NUMKEY *) &kkk->upper;
155
156 PG_RETURN_BOOL(gbt_num_consistent(&key, &query, &strategy,
157 GIST_LEAF(entry), &tinfo,
158 fcinfo->flinfo));
159}
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_UINT16(n)
Definition: fmgr.h:272
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:359
#define GIST_LEAF(entry)
Definition: gist.h:171
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:322
uint16 StrategyNumber
Definition: stratnum.h:22
Datum key
Definition: gist.h:161
float8 upper
Definition: btree_float8.c:15
float8 lower
Definition: btree_float8.c:14

References DatumGetPointer(), gbt_num_consistent(), GIST_LEAF, GISTENTRY::key, sort-test::key, float8key::lower, PG_GETARG_FLOAT8, PG_GETARG_POINTER, PG_GETARG_UINT16, PG_RETURN_BOOL, tinfo, and float8key::upper.

◆ 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, float_overflow_error(), and unlikely.

◆ gbt_float8_distance()

Datum gbt_float8_distance ( PG_FUNCTION_ARGS  )

Definition at line 162 of file btree_float8.c.

163{
164 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
165 float8 query = PG_GETARG_FLOAT8(1);
166
167 /* Oid subtype = PG_GETARG_OID(3); */
168 float8KEY *kkk = (float8KEY *) DatumGetPointer(entry->key);
170
171 key.lower = (GBT_NUMKEY *) &kkk->lower;
172 key.upper = (GBT_NUMKEY *) &kkk->upper;
173
175 &tinfo, fcinfo->flinfo));
176}
float8 gbt_num_distance(const GBT_NUMKEY_R *key, const void *query, bool is_leaf, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)

References DatumGetPointer(), gbt_num_distance(), GIST_LEAF, GISTENTRY::key, sort-test::key, float8key::lower, PG_GETARG_FLOAT8, PG_GETARG_POINTER, PG_RETURN_FLOAT8, tinfo, and float8key::upper.

◆ 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 189 of file btree_float8.c.

190{
191 float8KEY *origentry = (float8KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
193 float *result = (float *) PG_GETARG_POINTER(2);
194
195 penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper);
196
197 PG_RETURN_POINTER(result);
198}
#define penalty_num(result, olower, oupper, nlower, nupper)

References DatumGetPointer(), sort-test::key, float8key::lower, penalty_num, PG_GETARG_POINTER, PG_RETURN_POINTER, and float8key::upper.

◆ gbt_float8_picksplit()

Datum gbt_float8_picksplit ( PG_FUNCTION_ARGS  )

Definition at line 201 of file btree_float8.c.

202{
205 &tinfo, fcinfo->flinfo));
206}
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 209 of file btree_float8.c.

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

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

◆ gbt_float8_sortsupport()

Datum gbt_float8_sortsupport ( PG_FUNCTION_ARGS  )

Definition at line 230 of file btree_float8.c.

231{
233
235 ssup->ssup_extra = NULL;
236
238}
static int gbt_float8_ssup_cmp(Datum x, Datum y, SortSupport ssup)
Definition: btree_float8.c:220
#define PG_RETURN_VOID()
Definition: fmgr.h:349
struct SortSupportData * SortSupport
Definition: sortsupport.h:58
int(* comparator)(Datum x, Datum y, SortSupport ssup)
Definition: sortsupport.h:106
void * ssup_extra
Definition: sortsupport.h:87

References SortSupportData::comparator, 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 220 of file btree_float8.c.

221{
224
225 /* for leaf items we expect lower == upper, so only compare lower */
226 return float8_cmp_internal(arg1->lower, arg2->lower);
227}
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(), float8_cmp_internal(), float8key::lower, x, and y.

Referenced by gbt_float8_sortsupport().

◆ gbt_float8_union()

Datum gbt_float8_union ( PG_FUNCTION_ARGS  )

Definition at line 179 of file btree_float8.c.

180{
182 void *out = palloc(sizeof(float8KEY));
183
184 *(int *) PG_GETARG_POINTER(1) = sizeof(float8KEY);
185 PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo));
186}
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:1365

References 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, float8key::lower, and float8key::upper.

◆ 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)
Definition: btree_float8.c:41
static bool gbt_float8gt(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_float8.c:31
static float8 gbt_float8_dist(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_float8.c:74
static bool gbt_float8le(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_float8.c:46
static bool gbt_float8ge(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_float8.c:36
static int gbt_float8key_cmp(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_float8.c:57
static bool gbt_float8lt(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_float8.c:51
@ gbt_t_float8
Definition: btree_gist.h:21

Definition at line 87 of file btree_float8.c.

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