Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
PostgreSQL Source Code git master
btree_macaddr8.c File Reference
#include "postgres.h"
#include "btree_gist.h"
#include "btree_utils_num.h"
#include "utils/fmgrprotos.h"
#include "utils/inet.h"
#include "utils/sortsupport.h"
Include dependency graph for btree_macaddr8.c:

Go to the source code of this file.

Data Structures

struct  mac8KEY
 

Functions

 PG_FUNCTION_INFO_V1 (gbt_macad8_compress)
 
 PG_FUNCTION_INFO_V1 (gbt_macad8_fetch)
 
 PG_FUNCTION_INFO_V1 (gbt_macad8_union)
 
 PG_FUNCTION_INFO_V1 (gbt_macad8_picksplit)
 
 PG_FUNCTION_INFO_V1 (gbt_macad8_consistent)
 
 PG_FUNCTION_INFO_V1 (gbt_macad8_penalty)
 
 PG_FUNCTION_INFO_V1 (gbt_macad8_same)
 
 PG_FUNCTION_INFO_V1 (gbt_macad8_sortsupport)
 
static bool gbt_macad8gt (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_macad8ge (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_macad8eq (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_macad8le (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_macad8lt (const void *a, const void *b, FmgrInfo *flinfo)
 
static int gbt_macad8key_cmp (const void *a, const void *b, FmgrInfo *flinfo)
 
static uint64 mac8_2_uint64 (macaddr8 *m)
 
Datum gbt_macad8_compress (PG_FUNCTION_ARGS)
 
Datum gbt_macad8_fetch (PG_FUNCTION_ARGS)
 
Datum gbt_macad8_consistent (PG_FUNCTION_ARGS)
 
Datum gbt_macad8_union (PG_FUNCTION_ARGS)
 
Datum gbt_macad8_penalty (PG_FUNCTION_ARGS)
 
Datum gbt_macad8_picksplit (PG_FUNCTION_ARGS)
 
Datum gbt_macad8_same (PG_FUNCTION_ARGS)
 
static int gbt_macaddr8_ssup_cmp (Datum x, Datum y, SortSupport ssup)
 
Datum gbt_macad8_sortsupport (PG_FUNCTION_ARGS)
 

Variables

static const gbtree_ninfo tinfo
 

Function Documentation

◆ gbt_macad8_compress()

Datum gbt_macad8_compress ( PG_FUNCTION_ARGS  )

Definition at line 106 of file btree_macaddr8.c.

107{
108 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
109
111}
static const gbtree_ninfo tinfo
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_macad8_consistent()

Datum gbt_macad8_consistent ( PG_FUNCTION_ARGS  )

Definition at line 122 of file btree_macaddr8.c.

123{
124 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
125 macaddr8 *query = (macaddr8 *) PG_GETARG_POINTER(1);
127
128 /* Oid subtype = PG_GETARG_OID(3); */
129 bool *recheck = (bool *) PG_GETARG_POINTER(4);
130 mac8KEY *kkk = (mac8KEY *) DatumGetPointer(entry->key);
132
133 /* All cases served by this function are exact */
134 *recheck = false;
135
136 key.lower = (GBT_NUMKEY *) &kkk->lower;
137 key.upper = (GBT_NUMKEY *) &kkk->upper;
138
139 PG_RETURN_BOOL(gbt_num_consistent(&key, query, &strategy,
140 GIST_LEAF(entry), &tinfo, fcinfo->flinfo));
141}
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:317
uint16 StrategyNumber
Definition: stratnum.h:22
Datum key
Definition: gist.h:161
macaddr8 upper
macaddr8 lower
Definition: inet.h:108

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

◆ gbt_macad8_fetch()

Datum gbt_macad8_fetch ( PG_FUNCTION_ARGS  )

Definition at line 114 of file btree_macaddr8.c.

115{
116 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
117
119}
GISTENTRY * gbt_num_fetch(GISTENTRY *entry, const gbtree_ninfo *tinfo)

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

◆ gbt_macad8_penalty()

Datum gbt_macad8_penalty ( PG_FUNCTION_ARGS  )

Definition at line 154 of file btree_macaddr8.c.

155{
156 mac8KEY *origentry = (mac8KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
158 float *result = (float *) PG_GETARG_POINTER(2);
159 uint64 iorg[2],
160 inew[2];
161
162 iorg[0] = mac8_2_uint64(&origentry->lower);
163 iorg[1] = mac8_2_uint64(&origentry->upper);
164 inew[0] = mac8_2_uint64(&newentry->lower);
165 inew[1] = mac8_2_uint64(&newentry->upper);
166
167 penalty_num(result, iorg[0], iorg[1], inew[0], inew[1]);
168
169 PG_RETURN_POINTER(result);
170}
static uint64 mac8_2_uint64(macaddr8 *m)
#define penalty_num(result, olower, oupper, nlower, nupper)
uint64_t uint64
Definition: c.h:503

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

◆ gbt_macad8_picksplit()

Datum gbt_macad8_picksplit ( PG_FUNCTION_ARGS  )

Definition at line 173 of file btree_macaddr8.c.

174{
177 &tinfo, fcinfo->flinfo));
178}
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_macad8_same()

Datum gbt_macad8_same ( PG_FUNCTION_ARGS  )

Definition at line 181 of file btree_macaddr8.c.

182{
183 mac8KEY *b1 = (mac8KEY *) PG_GETARG_POINTER(0);
184 mac8KEY *b2 = (mac8KEY *) PG_GETARG_POINTER(1);
185 bool *result = (bool *) PG_GETARG_POINTER(2);
186
187 *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
188 PG_RETURN_POINTER(result);
189}
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_macad8_sortsupport()

Datum gbt_macad8_sortsupport ( PG_FUNCTION_ARGS  )

Definition at line 204 of file btree_macaddr8.c.

205{
207
209 ssup->ssup_extra = NULL;
210
212}
static int gbt_macaddr8_ssup_cmp(Datum x, Datum y, SortSupport ssup)
#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_macaddr8_ssup_cmp(), PG_GETARG_POINTER, PG_RETURN_VOID, and SortSupportData::ssup_extra.

◆ gbt_macad8_union()

Datum gbt_macad8_union ( PG_FUNCTION_ARGS  )

Definition at line 144 of file btree_macaddr8.c.

145{
147 void *out = palloc0(sizeof(mac8KEY));
148
149 *(int *) PG_GETARG_POINTER(1) = sizeof(mac8KEY);
150 PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo));
151}
void * gbt_num_union(GBT_NUMKEY *out, const GistEntryVector *entryvec, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)
void * palloc0(Size size)
Definition: mcxt.c:1351

References gbt_num_union(), palloc0(), PG_GETARG_POINTER, PG_RETURN_POINTER, and tinfo.

◆ gbt_macad8eq()

static bool gbt_macad8eq ( const void *  a,
const void *  b,
FmgrInfo flinfo 
)
static

Definition at line 41 of file btree_macaddr8.c.

42{
44}
#define DirectFunctionCall2(func, arg1, arg2)
Definition: fmgr.h:684
int b
Definition: isn.c:74
int a
Definition: isn.c:73
Datum macaddr8_eq(PG_FUNCTION_ARGS)
Definition: mac8.c:356
static bool DatumGetBool(Datum X)
Definition: postgres.h:95
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:327

References a, b, DatumGetBool(), DirectFunctionCall2, macaddr8_eq(), and PointerGetDatum().

◆ gbt_macad8ge()

static bool gbt_macad8ge ( const void *  a,
const void *  b,
FmgrInfo flinfo 
)
static

Definition at line 35 of file btree_macaddr8.c.

36{
38}
Datum macaddr8_ge(PG_FUNCTION_ARGS)
Definition: mac8.c:365

References a, b, DatumGetBool(), DirectFunctionCall2, macaddr8_ge(), and PointerGetDatum().

◆ gbt_macad8gt()

static bool gbt_macad8gt ( const void *  a,
const void *  b,
FmgrInfo flinfo 
)
static

Definition at line 30 of file btree_macaddr8.c.

31{
33}
Datum macaddr8_gt(PG_FUNCTION_ARGS)
Definition: mac8.c:374

References a, b, DatumGetBool(), DirectFunctionCall2, macaddr8_gt(), and PointerGetDatum().

◆ gbt_macad8key_cmp()

static int gbt_macad8key_cmp ( const void *  a,
const void *  b,
FmgrInfo flinfo 
)
static

Definition at line 60 of file btree_macaddr8.c.

61{
62 mac8KEY *ia = (mac8KEY *) (((const Nsrt *) a)->t);
63 mac8KEY *ib = (mac8KEY *) (((const Nsrt *) b)->t);
64 int res;
65
67 if (res == 0)
69
70 return res;
71}
Datum macaddr8_cmp(PG_FUNCTION_ARGS)
Definition: mac8.c:325
static int32 DatumGetInt32(Datum X)
Definition: postgres.h:207
static Datum Macaddr8PGetDatum(const macaddr8 *X)
Definition: inet.h:169

References a, b, DatumGetInt32(), DirectFunctionCall2, mac8KEY::lower, macaddr8_cmp(), Macaddr8PGetDatum(), and mac8KEY::upper.

◆ gbt_macad8le()

static bool gbt_macad8le ( const void *  a,
const void *  b,
FmgrInfo flinfo 
)
static

Definition at line 47 of file btree_macaddr8.c.

48{
50}
Datum macaddr8_le(PG_FUNCTION_ARGS)
Definition: mac8.c:347

References a, b, DatumGetBool(), DirectFunctionCall2, macaddr8_le(), and PointerGetDatum().

◆ gbt_macad8lt()

static bool gbt_macad8lt ( const void *  a,
const void *  b,
FmgrInfo flinfo 
)
static

Definition at line 53 of file btree_macaddr8.c.

54{
56}
Datum macaddr8_lt(PG_FUNCTION_ARGS)
Definition: mac8.c:338

References a, b, DatumGetBool(), DirectFunctionCall2, macaddr8_lt(), and PointerGetDatum().

◆ gbt_macaddr8_ssup_cmp()

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

Definition at line 192 of file btree_macaddr8.c.

193{
194 mac8KEY *arg1 = (mac8KEY *) DatumGetPointer(x);
195 mac8KEY *arg2 = (mac8KEY *) DatumGetPointer(y);
196
197 /* for leaf items we expect lower == upper, so only compare lower */
199 Macaddr8PGetDatum(&arg1->lower),
200 Macaddr8PGetDatum(&arg2->lower)));
201}
int y
Definition: isn.c:76
int x
Definition: isn.c:75

References DatumGetInt32(), DatumGetPointer(), DirectFunctionCall2, mac8KEY::lower, macaddr8_cmp(), Macaddr8PGetDatum(), x, and y.

Referenced by gbt_macad8_sortsupport().

◆ mac8_2_uint64()

static uint64 mac8_2_uint64 ( macaddr8 m)
static

Definition at line 94 of file btree_macaddr8.c.

95{
96 unsigned char *mi = (unsigned char *) m;
97 uint64 res = 0;
98 int i;
99
100 for (i = 0; i < 8; i++)
101 res += (((uint64) mi[i]) << ((uint64) ((7 - i) * 8)));
102 return res;
103}
int i
Definition: isn.c:77

References i.

Referenced by gbt_macad8_penalty().

◆ PG_FUNCTION_INFO_V1() [1/8]

PG_FUNCTION_INFO_V1 ( gbt_macad8_compress  )

◆ PG_FUNCTION_INFO_V1() [2/8]

PG_FUNCTION_INFO_V1 ( gbt_macad8_consistent  )

◆ PG_FUNCTION_INFO_V1() [3/8]

PG_FUNCTION_INFO_V1 ( gbt_macad8_fetch  )

◆ PG_FUNCTION_INFO_V1() [4/8]

PG_FUNCTION_INFO_V1 ( gbt_macad8_penalty  )

◆ PG_FUNCTION_INFO_V1() [5/8]

PG_FUNCTION_INFO_V1 ( gbt_macad8_picksplit  )

◆ PG_FUNCTION_INFO_V1() [6/8]

PG_FUNCTION_INFO_V1 ( gbt_macad8_same  )

◆ PG_FUNCTION_INFO_V1() [7/8]

PG_FUNCTION_INFO_V1 ( gbt_macad8_sortsupport  )

◆ PG_FUNCTION_INFO_V1() [8/8]

PG_FUNCTION_INFO_V1 ( gbt_macad8_union  )

Variable Documentation

◆ tinfo

const gbtree_ninfo tinfo
static
Initial value:
=
{
sizeof(macaddr8),
16,
NULL
}
@ gbt_t_macad8
Definition: btree_gist.h:30
static int gbt_macad8key_cmp(const void *a, const void *b, FmgrInfo *flinfo)
static bool gbt_macad8lt(const void *a, const void *b, FmgrInfo *flinfo)
static bool gbt_macad8eq(const void *a, const void *b, FmgrInfo *flinfo)
static bool gbt_macad8le(const void *a, const void *b, FmgrInfo *flinfo)
static bool gbt_macad8gt(const void *a, const void *b, FmgrInfo *flinfo)
static bool gbt_macad8ge(const void *a, const void *b, FmgrInfo *flinfo)
struct macaddr8 macaddr8

Definition at line 74 of file btree_macaddr8.c.

Referenced by gbt_macad8_compress(), gbt_macad8_consistent(), gbt_macad8_fetch(), gbt_macad8_picksplit(), gbt_macad8_same(), and gbt_macad8_union().