PostgreSQL Source Code: contrib/hstore/hstore_gist.c Source File (original) (raw)
1
2
3
5
13
14
20
21
22#define BITBYTE 8
23#define SIGLEN_DEFAULT (sizeof(int32) * 4)
24#define SIGLEN_MAX GISTMaxIndexKeySize
25#define SIGLENBIT(siglen) ((siglen) * BITBYTE)
26#define GET_SIGLEN() (PG_HAS_OPCLASS_OPTIONS() ? \
27 ((GistHstoreOptions *) PG_GET_OPCLASS_OPTIONS())->siglen : \
28 SIGLEN_DEFAULT)
29
30
32
33#define LOOPBYTE(siglen) \
34 for (i = 0; i < (siglen); i++)
35
36#define LOOPBIT(siglen) \
37 for (i = 0; i < SIGLENBIT(siglen); i++)
38
39
40#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
41#define GETBITBYTE(x,i) ( (*((char*)(x)) >> (i)) & 0x01 )
42#define CLRBIT(x,i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) )
43#define SETBIT(x,i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITBYTE ) )
44#define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 )
45#define HASHVAL(val, siglen) (((unsigned int)(val)) % SIGLENBIT(siglen))
46#define HASH(sign, val, siglen) SETBIT((sign), HASHVAL(val, siglen))
47
54
55#define ALLISTRUE 0x04
56
57#define ISALLTRUE(x) ( ((GISTTYPE*)x)->flag & ALLISTRUE )
58
59#define GTHDRSIZE (VARHDRSZ + sizeof(int32))
60#define CALCGTSIZE(flag, siglen) ( GTHDRSIZE+(((flag) & ALLISTRUE) ? 0 : (siglen)) )
61
62#define GETSIGN(x) ( (BITVECP)( (char*)x+GTHDRSIZE ) )
63
64#define SUMBIT(val) ( \
65 GETBITBYTE((val),0) + \
66 GETBITBYTE((val),1) + \
67 GETBITBYTE((val),2) + \
68 GETBITBYTE((val),3) + \
69 GETBITBYTE((val),4) + \
70 GETBITBYTE((val),5) + \
71 GETBITBYTE((val),6) + \
72 GETBITBYTE((val),7) \
74
75#define GETENTRY(vec,pos) ((GISTTYPE *) DatumGetPointer((vec)->vector[(pos)].key))
76
77#define WISH_F(a,b,c) (double)( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c) )
78
79
82{
84
88
89 return crc;
90}
91
92
95
96
99{
102 errmsg("cannot accept a value of type %s", "ghstore")));
103
105}
106
109{
112 errmsg("cannot display a value of type %s", "ghstore")));
113
115}
116
119{
123
126
127 if (!allistrue)
128 {
131 else
133 }
134
135 return res;
136}
137
146
149{
153
155 {
161 int i;
162
163 for (i = 0; i < count; ++i)
164 {
165 int h;
166
171 {
175 }
176 }
177
182 false);
183 }
185 {
189
191 {
192 if ((sign[i] & 0xff) != 0xff)
194 }
195
197
202 false);
203 }
204
206}
207
208
209
210
211
217
220{
225
226
228 *result = true;
230 *result = false;
232 *result = false;
233 else
234 {
238
239 *result = true;
241 {
243 {
244 *result = false;
245 break;
246 }
247 }
248 }
250}
251
254{
256 i;
257
259 {
262 }
263 return size;
264}
265
266static int
268{
269 int i,
271
273 {
276 }
278}
279
280static int
282{
284 {
286 return 0;
287 else
289 }
292
294}
295
298{
301
303 return 1;
306 return 0;
307}
308
311{
314
320
322 {
324 {
327 break;
328 }
329 }
330
332
334}
335
349
350
356
357static int
363
364
367{
370
374 j;
382 waste = -1;
387 *right;
389 int i;
393
394 nbytes = (maxoff + 2) * sizeof(OffsetNumber);
397
399 {
402 {
405 {
409 }
410 }
411 }
412
417
419 {
422 }
423
424
429
431
434 {
440 }
442
445
446 for (k = 0; k < maxoff; k++)
447 {
450 {
451 *left++ = j;
453 continue;
454 }
456 {
457 *right++ = j;
459 continue;
460 }
464
466 {
468 {
471 }
472 else
473 {
477 }
478 *left++ = j;
480 }
481 else
482 {
484 {
487 }
488 else
489 {
493 }
494 *right++ = j;
496 }
497 }
498
500
503
505}
506
507
510{
513#ifdef NOT_USED
515#endif
518 bool res = true;
520
521
522 *recheck = true;
523
526
528
531 {
536 int i;
537
538 for (i = 0; res && i < count; ++i)
539 {
542
544 {
546 {
550 res = false;
551 }
552 }
553 else
554 res = false;
555 }
556 }
558 {
561
563 }
565 {
570 int i;
571
573
575 {
577
579 continue;
582 res = false;
583 }
584 }
586 {
591 int i;
592
594
595 res = false;
596
598 {
600
602 continue;
605 res = true;
606 }
607 }
608 else
609 elog(ERROR, "Unsupported strategy number: %d", strategy);
610
612}
613
616{
618
621 "signature length in bytes",
624
626}
#define PG_GETARG_ARRAYTYPE_P(n)
void deconstruct_array_builtin(const ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
#define FLEXIBLE_ARRAY_MEMBER
int errcode(int sqlerrcode)
#define ereport(elevel,...)
#define palloc_object(type)
#define palloc_array(type, count)
#define PG_GETARG_TEXT_PP(n)
#define PG_GETARG_POINTER(n)
#define PG_FUNCTION_INFO_V1(funcname)
#define PG_GETARG_UINT16(n)
#define PG_RETURN_POINTER(x)
#define PG_RETURN_BOOL(x)
#define gistentryinit(e, k, r, pg, o, l)
#define HStoreExistsAllStrategyNumber
#define HStoreExistsStrategyNumber
#define DatumGetHStoreP(d)
#define HSTORE_KEY(arr_, str_, i_)
#define PG_GETARG_HSTORE_P(x)
#define HStoreOldContainsStrategyNumber
#define HStoreExistsAnyStrategyNumber
#define HStoreContainsStrategyNumber
#define HSTORE_VALISNULL(arr_, i_)
#define HSTORE_VALLEN(arr_, i_)
#define HSTORE_KEYLEN(arr_, i_)
#define HSTORE_VAL(arr_, str_, i_)
#define HASHVAL(val, siglen)
Datum ghstore_options(PG_FUNCTION_ARGS)
Datum ghstore_union(PG_FUNCTION_ARGS)
Datum ghstore_picksplit(PG_FUNCTION_ARGS)
static int hemdist(GISTTYPE *a, GISTTYPE *b, int siglen)
static int32 sizebitvec(BITVECP sign, int siglen)
static int hemdistsign(BITVECP a, BITVECP b, int siglen)
Datum ghstore_compress(PG_FUNCTION_ARGS)
Datum ghstore_out(PG_FUNCTION_ARGS)
#define CALCGTSIZE(flag, siglen)
#define GETENTRY(vec, pos)
Datum ghstore_consistent(PG_FUNCTION_ARGS)
static int32 unionkey(BITVECP sbase, GISTTYPE *add, int siglen)
static pg_crc32 crc32_sz(const char *buf, int size)
Datum ghstore_penalty(PG_FUNCTION_ARGS)
#define SIGLENBIT(siglen)
Datum ghstore_decompress(PG_FUNCTION_ARGS)
Datum ghstore_in(PG_FUNCTION_ARGS)
Datum ghstore_same(PG_FUNCTION_ARGS)
static GISTTYPE * ghstore_alloc(bool allistrue, int siglen, BITVECP sign)
#define HASH(sign, val, siglen)
static int comparecost(const void *a, const void *b)
static int pg_cmp_s32(int32 a, int32 b)
#define OffsetNumberNext(offsetNumber)
#define FirstOffsetNumber
#define FIN_TRADITIONAL_CRC32(crc)
#define INIT_TRADITIONAL_CRC32(crc)
#define COMP_TRADITIONAL_CRC32(crc, data, len)
static char buf[DEFAULT_XLOG_SEG_SIZE]
#define qsort(a, b, c, d)
static Datum PointerGetDatum(const void *X)
static Pointer DatumGetPointer(Datum X)
void init_local_reloptions(local_relopts *relopts, Size relopt_struct_size)
void add_local_int_reloption(local_relopts *relopts, const char *name, const char *desc, int default_val, int min_val, int max_val, int offset)
static Size VARSIZE_ANY_EXHDR(const void *PTR)
static Size VARSIZE(const void *PTR)
static char * VARDATA(const void *PTR)
static char * VARDATA_ANY(const void *PTR)
static void SET_VARSIZE(void *PTR, Size len)