PostgreSQL Source Code  git master
btree_macaddr8.c File Reference
#include "postgres.h"
#include "btree_gist.h"
#include "btree_utils_num.h"
#include "utils/builtins.h"
#include "utils/inet.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)
 
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)
 

Variables

static const gbtree_ninfo tinfo
 

Function Documentation

◆ gbt_macad8_compress()

Datum gbt_macad8_compress ( PG_FUNCTION_ARGS  )

Definition at line 111 of file btree_macaddr8.c.

References gbt_num_compress(), PG_GETARG_POINTER, and PG_RETURN_POINTER.

112 {
113  GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
114 
116 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
GISTENTRY * gbt_num_compress(GISTENTRY *entry, const gbtree_ninfo *tinfo)
static const gbtree_ninfo tinfo

◆ gbt_macad8_consistent()

Datum gbt_macad8_consistent ( PG_FUNCTION_ARGS  )

Definition at line 127 of file btree_macaddr8.c.

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

128 {
129  GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
130  macaddr8 *query = (macaddr8 *) PG_GETARG_POINTER(1);
132 
133  /* Oid subtype = PG_GETARG_OID(3); */
134  bool *recheck = (bool *) PG_GETARG_POINTER(4);
135  mac8KEY *kkk = (mac8KEY *) DatumGetPointer(entry->key);
137 
138  /* All cases served by this function are exact */
139  *recheck = false;
140 
141  key.lower = (GBT_NUMKEY *) &kkk->lower;
142  key.upper = (GBT_NUMKEY *) &kkk->upper;
143 
145  gbt_num_consistent(&key, (void *) query, &strategy, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
146  );
147 }
#define GIST_LEAF(entry)
Definition: gist.h:141
const GBT_NUMKEY * lower
macaddr8 lower
uint16 StrategyNumber
Definition: stratnum.h:22
const GBT_NUMKEY * upper
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
bool gbt_num_consistent(const GBT_NUMKEY_R *key, const void *query, const StrategyNumber *strategy, bool is_leaf, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)
Definition: inet.h:107
Datum key
Definition: gist.h:131
static const gbtree_ninfo tinfo
char GBT_NUMKEY
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:349
#define PG_GETARG_UINT16(n)
Definition: fmgr.h:267
#define DatumGetPointer(X)
Definition: postgres.h:549
macaddr8 upper

◆ gbt_macad8_fetch()

Datum gbt_macad8_fetch ( PG_FUNCTION_ARGS  )

Definition at line 119 of file btree_macaddr8.c.

References gbt_num_fetch(), PG_GETARG_POINTER, and PG_RETURN_POINTER.

120 {
121  GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
122 
124 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
GISTENTRY * gbt_num_fetch(GISTENTRY *entry, const gbtree_ninfo *tinfo)
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
static const gbtree_ninfo tinfo

◆ gbt_macad8_penalty()

Datum gbt_macad8_penalty ( PG_FUNCTION_ARGS  )

Definition at line 162 of file btree_macaddr8.c.

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

163 {
164  mac8KEY *origentry = (mac8KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
165  mac8KEY *newentry = (mac8KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
166  float *result = (float *) PG_GETARG_POINTER(2);
167  uint64 iorg[2],
168  inew[2];
169 
170  iorg[0] = mac8_2_uint64(&origentry->lower);
171  iorg[1] = mac8_2_uint64(&origentry->upper);
172  inew[0] = mac8_2_uint64(&newentry->lower);
173  inew[1] = mac8_2_uint64(&newentry->upper);
174 
175  penalty_num(result, iorg[0], iorg[1], inew[0], inew[1]);
176 
177  PG_RETURN_POINTER(result);
178 
179 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
macaddr8 lower
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
#define penalty_num(result, olower, oupper, nlower, nupper)
static uint64 mac8_2_uint64(macaddr8 *m)
#define DatumGetPointer(X)
Definition: postgres.h:549
macaddr8 upper

◆ gbt_macad8_picksplit()

Datum gbt_macad8_picksplit ( PG_FUNCTION_ARGS  )

Definition at line 182 of file btree_macaddr8.c.

References gbt_num_picksplit(), PG_GETARG_POINTER, and PG_RETURN_POINTER.

183 {
187  &tinfo, fcinfo->flinfo
188  ));
189 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
static const gbtree_ninfo tinfo
GIST_SPLITVEC * gbt_num_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)

◆ gbt_macad8_same()

Datum gbt_macad8_same ( PG_FUNCTION_ARGS  )

Definition at line 192 of file btree_macaddr8.c.

References gbt_num_same(), PG_GETARG_POINTER, and PG_RETURN_POINTER.

193 {
194  mac8KEY *b1 = (mac8KEY *) PG_GETARG_POINTER(0);
195  mac8KEY *b2 = (mac8KEY *) PG_GETARG_POINTER(1);
196  bool *result = (bool *) PG_GETARG_POINTER(2);
197 
198  *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
199  PG_RETURN_POINTER(result);
200 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
bool gbt_num_same(const GBT_NUMKEY *a, const GBT_NUMKEY *b, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
static const gbtree_ninfo tinfo

◆ gbt_macad8_union()

Datum gbt_macad8_union ( PG_FUNCTION_ARGS  )

Definition at line 151 of file btree_macaddr8.c.

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

152 {
154  void *out = palloc0(sizeof(mac8KEY));
155 
156  *(int *) PG_GETARG_POINTER(1) = sizeof(mac8KEY);
157  PG_RETURN_POINTER(gbt_num_union((void *) out, entryvec, &tinfo, fcinfo->flinfo));
158 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
static const gbtree_ninfo tinfo
void * palloc0(Size size)
Definition: mcxt.c:980
void * gbt_num_union(GBT_NUMKEY *out, const GistEntryVector *entryvec, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)

◆ gbt_macad8eq()

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

Definition at line 42 of file btree_macaddr8.c.

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

43 {
45 }
#define PointerGetDatum(X)
Definition: postgres.h:556
Datum macaddr8_eq(PG_FUNCTION_ARGS)
Definition: mac8.c:364
#define DatumGetBool(X)
Definition: postgres.h:393
#define DirectFunctionCall2(func, arg1, arg2)
Definition: fmgr.h:617

◆ gbt_macad8ge()

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

Definition at line 36 of file btree_macaddr8.c.

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

37 {
39 }
#define PointerGetDatum(X)
Definition: postgres.h:556
#define DatumGetBool(X)
Definition: postgres.h:393
Datum macaddr8_ge(PG_FUNCTION_ARGS)
Definition: mac8.c:373
#define DirectFunctionCall2(func, arg1, arg2)
Definition: fmgr.h:617

◆ gbt_macad8gt()

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

Definition at line 31 of file btree_macaddr8.c.

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

32 {
34 }
#define PointerGetDatum(X)
Definition: postgres.h:556
Datum macaddr8_gt(PG_FUNCTION_ARGS)
Definition: mac8.c:382
#define DatumGetBool(X)
Definition: postgres.h:393
#define DirectFunctionCall2(func, arg1, arg2)
Definition: fmgr.h:617

◆ gbt_macad8key_cmp()

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

Definition at line 61 of file btree_macaddr8.c.

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

62 {
63  mac8KEY *ia = (mac8KEY *) (((const Nsrt *) a)->t);
64  mac8KEY *ib = (mac8KEY *) (((const Nsrt *) b)->t);
65  int res;
66 
68  if (res == 0)
70 
71  return res;
72 }
Datum macaddr8_cmp(PG_FUNCTION_ARGS)
Definition: mac8.c:333
#define DatumGetInt32(X)
Definition: postgres.h:472
macaddr8 lower
#define Macaddr8PGetDatum(X)
Definition: inet.h:138
macaddr8 upper
#define DirectFunctionCall2(func, arg1, arg2)
Definition: fmgr.h:617

◆ gbt_macad8le()

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

Definition at line 48 of file btree_macaddr8.c.

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

49 {
51 }
#define PointerGetDatum(X)
Definition: postgres.h:556
#define DatumGetBool(X)
Definition: postgres.h:393
Datum macaddr8_le(PG_FUNCTION_ARGS)
Definition: mac8.c:355
#define DirectFunctionCall2(func, arg1, arg2)
Definition: fmgr.h:617

◆ gbt_macad8lt()

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

Definition at line 54 of file btree_macaddr8.c.

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

55 {
57 }
#define PointerGetDatum(X)
Definition: postgres.h:556
Datum macaddr8_lt(PG_FUNCTION_ARGS)
Definition: mac8.c:346
#define DatumGetBool(X)
Definition: postgres.h:393
#define DirectFunctionCall2(func, arg1, arg2)
Definition: fmgr.h:617

◆ mac8_2_uint64()

static uint64 mac8_2_uint64 ( macaddr8 m)
static

Definition at line 97 of file btree_macaddr8.c.

References i.

Referenced by gbt_macad8_penalty().

98 {
99  unsigned char *mi = (unsigned char *) m;
100  uint64 res = 0;
101  int i;
102 
103  for (i = 0; i < 8; i++)
104  res += (((uint64) mi[i]) << ((uint64) ((7 - i) * 8)));
105  return res;
106 }
int i

◆ PG_FUNCTION_INFO_V1() [1/7]

PG_FUNCTION_INFO_V1 ( gbt_macad8_compress  )

◆ PG_FUNCTION_INFO_V1() [2/7]

PG_FUNCTION_INFO_V1 ( gbt_macad8_fetch  )

◆ PG_FUNCTION_INFO_V1() [3/7]

PG_FUNCTION_INFO_V1 ( gbt_macad8_union  )

◆ PG_FUNCTION_INFO_V1() [4/7]

PG_FUNCTION_INFO_V1 ( gbt_macad8_picksplit  )

◆ PG_FUNCTION_INFO_V1() [5/7]

PG_FUNCTION_INFO_V1 ( gbt_macad8_consistent  )

◆ PG_FUNCTION_INFO_V1() [6/7]

PG_FUNCTION_INFO_V1 ( gbt_macad8_penalty  )

◆ PG_FUNCTION_INFO_V1() [7/7]

PG_FUNCTION_INFO_V1 ( gbt_macad8_same  )

Variable Documentation

◆ tinfo

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

Definition at line 75 of file btree_macaddr8.c.