PostgreSQL Source Code: src/backend/access/gist/gistproc.c File Reference (original) (raw)
#include "[postgres.h](postgres%5F8h%5Fsource.html)"
#include <math.h>
#include "[access/gist.h](gist%5F8h%5Fsource.html)"
#include "[access/stratnum.h](stratnum%5F8h%5Fsource.html)"
#include "[utils/float.h](float%5F8h%5Fsource.html)"
#include "utils/fmgrprotos.h"
#include "[utils/geo_decls.h](geo%5F%5Fdecls%5F8h%5Fsource.html)"
#include "[utils/sortsupport.h](sortsupport%5F8h%5Fsource.html)"
Go to the source code of this file.
Data Structures | |
---|---|
struct | CommonEntry |
struct | ConsiderSplitContext |
struct | SplitInterval |
Macros | |
---|---|
#define | LIMIT_RATIO 0.3 |
#define | PLACE_LEFT(box, off) |
#define | PLACE_RIGHT(box, off) |
#define | point_point_distance(p1, p2) |
#define | GeoStrategyNumberOffset 20 |
#define | PointStrategyNumberGroup 0 |
#define | BoxStrategyNumberGroup 1 |
#define | PolygonStrategyNumberGroup 2 |
#define | CircleStrategyNumberGroup 3 |
◆ BoxStrategyNumberGroup
#define BoxStrategyNumberGroup 1
◆ CircleStrategyNumberGroup
#define CircleStrategyNumberGroup 3
◆ GeoStrategyNumberOffset
#define GeoStrategyNumberOffset 20
◆ LIMIT_RATIO
◆ PLACE_LEFT
| #define PLACE_LEFT | ( | | box, | | ------------------- | - | | ---- | | | off | | | | | ) | | | |
Value:
do { \
if (v->spl_nleft > 0) \
adjustBox(leftBox, box); \
else \
*leftBox = *(box); \
v->spl_left[v->spl_nleft++] = off; \
} while(0)
◆ PLACE_RIGHT
| #define PLACE_RIGHT | ( | | box, | | -------------------- | - | | ---- | | | off | | | | | ) | | | |
Value:
do { \
if (v->spl_nright > 0) \
adjustBox(rightBox, box); \
else \
*rightBox = *(box); \
v->spl_right[v->spl_nright++] = off; \
} while(0)
◆ point_point_distance
| #define point_point_distance | ( | | p1, | | ------------------------------ | - | | --- | | | p2 | | | | | ) | | | |
Value:
#define DirectFunctionCall2(func, arg1, arg2)
static Datum PointPGetDatum(const Point *X)
Datum point_distance(PG_FUNCTION_ARGS)
static float8 DatumGetFloat8(Datum X)
Definition at line 1216 of file gistproc.c.
◆ PointStrategyNumberGroup
#define PointStrategyNumberGroup 0
◆ PolygonStrategyNumberGroup
#define PolygonStrategyNumberGroup 2
◆ adjustBox()
static void adjustBox ( BOX * b, const BOX * addon ) | static |
---|
Definition at line 146 of file gistproc.c.
147{
149 b->high.x = addon->high.x;
153 b->high.y = addon->high.y;
156}
static bool float8_lt(const float8 val1, const float8 val2)
static bool float8_gt(const float8 val1, const float8 val2)
References b, float8_gt(), float8_lt(), BOX::high, BOX::low, Point::x, and Point::y.
Referenced by fallbackSplit(), gist_box_picksplit(), and gist_box_union().
◆ box_penalty()
static float8 box_penalty ( const BOX * original, const BOX * new ) | static |
---|
◆ common_entry_cmp()
static int common_entry_cmp ( const void * i1, const void * i2 ) | static |
---|
◆ computeDistance()
static float8 computeDistance ( bool isLeaf, BOX * box, Point * point ) | static |
---|
Definition at line 1221 of file gistproc.c.
1222{
1223 float8 result = 0.0;
1224
1225 if (isLeaf)
1226 {
1227
1229 }
1230 else if (point->x <= box->high.x && point->x >= box->low.x &&
1231 point->y <= box->high.y && point->y >= box->low.y)
1232 {
1233
1234 result = 0.0;
1235 }
1236 else if (point->x <= box->high.x && point->x >= box->low.x)
1237 {
1238
1240 if (point->y > box->high.y)
1242 else if (point->y < box->low.y)
1244 else
1245 elog(ERROR, "inconsistent point values");
1246 }
1247 else if (point->y <= box->high.y && point->y >= box->low.y)
1248 {
1249
1251 if (point->x > box->high.x)
1253 else if (point->x < box->low.x)
1255 else
1256 elog(ERROR, "inconsistent point values");
1257 }
1258 else
1259 {
1260
1263
1265
1267 if (result > subresult)
1268 result = subresult;
1269
1273 if (result > subresult)
1274 result = subresult;
1275
1279 if (result > subresult)
1280 result = subresult;
1281 }
1282
1283 return result;
1284}
#define point_point_distance(p1, p2)
Assert(PointerIsAligned(start, uint64))
References Assert(), elog, ERROR, float8_mi(), BOX::high, BOX::low, point_point_distance, Point::x, and Point::y.
Referenced by gist_bbox_distance(), and gist_point_distance().
◆ fallbackSplit()
Definition at line 216 of file gistproc.c.
217{
219 maxoff;
220 BOX *unionL = NULL,
221 *unionR = NULL;
222 int nbytes;
223
224 maxoff = entryvec->n - 1;
225
226 nbytes = (maxoff + 2) * sizeof(OffsetNumber);
230
232 {
234
236 {
238 if (unionL == NULL)
239 {
241 *unionL = *cur;
242 }
243 else
245
247 }
248 else
249 {
251 if (unionR == NULL)
252 {
254 *unionR = *cur;
255 }
256 else
258
260 }
261 }
262
265}
static BOX * DatumGetBoxP(Datum X)
static Datum BoxPGetDatum(const BOX *X)
static void adjustBox(BOX *b, const BOX *addon)
#define OffsetNumberNext(offsetNumber)
#define FirstOffsetNumber
GISTENTRY vector[FLEXIBLE_ARRAY_MEMBER]
References adjustBox(), BoxPGetDatum(), cur, DatumGetBoxP(), FirstOffsetNumber, i, GISTENTRY::key, GistEntryVector::n, OffsetNumberNext, palloc(), GIST_SPLITVEC::spl_ldatum, GIST_SPLITVEC::spl_left, GIST_SPLITVEC::spl_nleft, GIST_SPLITVEC::spl_nright, GIST_SPLITVEC::spl_rdatum, GIST_SPLITVEC::spl_right, and GistEntryVector::vector.
Referenced by gist_box_picksplit().
◆ g_box_consider_split()
static void g_box_consider_split ( ConsiderSplitContext * context, int dimNum, float8 rightLower, int minLeftCount, float8 leftUpper, int maxLeftCount ) | inlinestatic |
---|
Definition at line 351 of file gistproc.c.
354{
355 int leftCount,
356 rightCount;
358 overlap;
360
361
362
363
364
365 if (minLeftCount >= (context->entriesCount + 1) / 2)
366 {
367 leftCount = minLeftCount;
368 }
369 else
370 {
371 if (maxLeftCount <= context->entriesCount / 2)
372 leftCount = maxLeftCount;
373 else
375 }
376 rightCount = context->entriesCount - leftCount;
377
378
379
380
381
383
385 {
386 bool selectthis = false;
387
388
389
390
391
392
393
394
395 if (dimNum == 0)
398 else
401
403
404
405 if (context->first)
406 selectthis = true;
407 else if (context->dim == dimNum)
408 {
409
410
411
412
413 if (overlap < context->overlap ||
414 (overlap == context->overlap && ratio > context->ratio))
415 selectthis = true;
416 }
417 else
418 {
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
439 selectthis = true;
440 }
441
442 if (selectthis)
443 {
444
445 context->first = false;
446 context->ratio = ratio;
448 context->overlap = overlap;
451 context->dim = dimNum;
452 }
453 }
454}
static float4 float4_div(const float4 val1, const float4 val2)
static float8 float8_div(const float8 val1, const float8 val2)
static float non_negative(float val)
static struct cvec * range(struct vars *v, chr a, chr b, int cases)
References ConsiderSplitContext::boundingBox, ConsiderSplitContext::dim, ConsiderSplitContext::entriesCount, ConsiderSplitContext::first, float4_div(), float8_div(), float8_mi(), BOX::high, ConsiderSplitContext::leftUpper, LIMIT_RATIO, BOX::low, Min, non_negative(), ConsiderSplitContext::overlap, ConsiderSplitContext::range, range(), ConsiderSplitContext::ratio, ConsiderSplitContext::rightLower, Point::x, and Point::y.
Referenced by gist_box_picksplit().
◆ gist_bbox_distance()
Definition at line 1479 of file gistproc.c.
1480{
1483
1484 switch (strategyGroup)
1485 {
1490 break;
1491 default:
1492 elog(ERROR, "unrecognized strategy number: %d", strategy);
1493 distance = 0.0;
1494 }
1495
1496 return distance;
1497}
static Point * DatumGetPointP(Datum X)
#define GeoStrategyNumberOffset
#define PointStrategyNumberGroup
static float8 computeDistance(bool isLeaf, BOX *box, Point *point)
References computeDistance(), DatumGetBoxP(), DatumGetPointP(), elog, ERROR, GeoStrategyNumberOffset, GISTENTRY::key, and PointStrategyNumberGroup.
Referenced by gist_box_distance(), gist_circle_distance(), and gist_poly_distance().
◆ gist_bbox_zorder_abbrev_abort()
static bool gist_bbox_zorder_abbrev_abort ( int memtupcount, SortSupport ssup ) | static |
---|
◆ gist_bbox_zorder_abbrev_convert()
◆ gist_bbox_zorder_cmp()
◆ gist_box_consistent()
Definition at line 113 of file gistproc.c.
114{
118
119
121
122
123 *recheck = false;
124
127
128
129
130
131
134 query,
135 strategy));
136 else
138 query,
139 strategy));
140}
#define PG_GETARG_POINTER(n)
#define PG_GETARG_UINT16(n)
#define PG_RETURN_BOOL(x)
#define PG_GETARG_BOX_P(n)
static bool rtree_internal_consistent(BOX *key, BOX *query, StrategyNumber strategy)
static bool gist_box_leaf_consistent(BOX *key, BOX *query, StrategyNumber strategy)
References DatumGetBoxP(), gist_box_leaf_consistent(), GIST_LEAF, GISTENTRY::key, PG_GETARG_BOX_P, PG_GETARG_POINTER, PG_GETARG_UINT16, PG_RETURN_BOOL, and rtree_internal_consistent().
◆ gist_box_distance()
◆ gist_box_leaf_consistent()
Definition at line 872 of file gistproc.c.
873{
874 bool retval;
875
876 switch (strategy)
877 {
882 break;
887 break;
892 break;
897 break;
902 break;
907 break;
912 break;
917 break;
922 break;
927 break;
932 break;
937 break;
938 default:
939 elog(ERROR, "unrecognized strategy number: %d", strategy);
940 retval = false;
941 break;
942 }
943 return retval;
944}
Datum box_left(PG_FUNCTION_ARGS)
Datum box_right(PG_FUNCTION_ARGS)
Datum box_same(PG_FUNCTION_ARGS)
Datum box_below(PG_FUNCTION_ARGS)
Datum box_overright(PG_FUNCTION_ARGS)
Datum box_overabove(PG_FUNCTION_ARGS)
Datum box_overlap(PG_FUNCTION_ARGS)
Datum box_contain(PG_FUNCTION_ARGS)
Datum box_overbelow(PG_FUNCTION_ARGS)
Datum box_contained(PG_FUNCTION_ARGS)
Datum box_overleft(PG_FUNCTION_ARGS)
Datum box_above(PG_FUNCTION_ARGS)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
#define RTOverlapStrategyNumber
#define RTLeftStrategyNumber
#define RTOverRightStrategyNumber
#define RTRightStrategyNumber
#define RTSameStrategyNumber
#define RTOverAboveStrategyNumber
#define RTContainsStrategyNumber
#define RTOverBelowStrategyNumber
#define RTBelowStrategyNumber
#define RTAboveStrategyNumber
#define RTOverLeftStrategyNumber
#define RTContainedByStrategyNumber
References box_above(), box_below(), box_contain(), box_contained(), box_left(), box_overabove(), box_overbelow(), box_overlap(), box_overleft(), box_overright(), box_right(), box_same(), DatumGetBool(), DirectFunctionCall2, elog, ERROR, sort-test::key, PointerGetDatum(), RTAboveStrategyNumber, RTBelowStrategyNumber, RTContainedByStrategyNumber, RTContainsStrategyNumber, RTLeftStrategyNumber, RTOverAboveStrategyNumber, RTOverBelowStrategyNumber, RTOverlapStrategyNumber, RTOverLeftStrategyNumber, RTOverRightStrategyNumber, RTRightStrategyNumber, and RTSameStrategyNumber.
Referenced by gist_box_consistent().
◆ gist_box_penalty()
◆ gist_box_picksplit()
Definition at line 495 of file gistproc.c.
496{
500 maxoff;
502 BOX *box,
503 *leftBox,
504 *rightBox;
505 int dim,
506 commonEntriesCount;
508 *intervalsUpper;
510 int nentries;
511
513
514 maxoff = entryvec->n - 1;
516
517
520
521
522
523
525 {
529 else
531 }
532
533
534
535
536 context.first = true;
537 for (dim = 0; dim < 2; dim++)
538 {
540 rightLower;
541 int i1,
542 i2;
543
544
546 {
548 if (dim == 0)
549 {
552 }
553 else
554 {
557 }
558 }
559
560
561
562
563
564 memcpy(intervalsUpper, intervalsLower,
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605 i1 = 0;
606 i2 = 0;
607 rightLower = intervalsLower[i1].lower;
608 leftUpper = intervalsUpper[i2].lower;
609 while (true)
610 {
611
612
613
614 while (i1 < nentries &&
616 {
618 leftUpper = intervalsLower[i1].upper;
619 i1++;
620 }
621 if (i1 >= nentries)
622 break;
623 rightLower = intervalsLower[i1].lower;
624
625
626
627
628
629 while (i2 < nentries &&
631 i2++;
632
633
634
635
637 }
638
639
640
641
642
643 i1 = nentries - 1;
644 i2 = nentries - 1;
645 rightLower = intervalsLower[i1].upper;
646 leftUpper = intervalsUpper[i2].upper;
647 while (true)
648 {
649
650
651
652 while (i2 >= 0 && float8_eq(leftUpper, intervalsUpper[i2].upper))
653 {
655 rightLower = intervalsUpper[i2].lower;
656 i2--;
657 }
658 if (i2 < 0)
659 break;
660 leftUpper = intervalsUpper[i2].upper;
661
662
663
664
665
666 while (i1 >= 0 && float8_ge(intervalsLower[i1].lower, rightLower))
667 i1--;
668
669
670
671
673 rightLower, i1 + 1, leftUpper, i2 + 1);
674 }
675 }
676
677
678
679
680 if (context.first)
681 {
684 }
685
686
687
688
689
690
691
692
693
694
699
700
703
704
705
706
707
708 commonEntriesCount = 0;
710
711
712#define PLACE_LEFT(box, off) \
713 do { \
714 if (v->spl_nleft > 0) \
715 adjustBox(leftBox, box); \
716 else \
717 *leftBox = *(box); \
718 v->spl_left[v->spl_nleft++] = off; \
719 } while(0)
720
721#define PLACE_RIGHT(box, off) \
722 do { \
723 if (v->spl_nright > 0) \
724 adjustBox(rightBox, box); \
725 else \
726 *rightBox = *(box); \
727 v->spl_right[v->spl_nright++] = off; \
728 } while(0)
729
730
731
732
733
735 {
738
739
740
741
743 if (context.dim == 0)
744 {
747 }
748 else
749 {
752 }
753
755 {
756
758 {
759
760 commonEntries[commonEntriesCount++].index = i;
761 }
762 else
763 {
764
766 }
767 }
768 else
769 {
770
771
772
773
774
776
777
779 }
780 }
781
782
783
784
785 if (commonEntriesCount > 0)
786 {
787
788
789
790
792
793
794
795
796
797 for (i = 0; i < commonEntriesCount; i++)
798 {
802 }
803
804
805
806
807
809
810
811
812
813 for (i = 0; i < commonEntriesCount; i++)
814 {
816
817
818
819
820
821 if (v->spl_nleft + (commonEntriesCount - i) <= m)
823 else if (v->spl_nright + (commonEntriesCount - i) <= m)
825 else
826 {
827
830 else
832 }
833 }
834 }
835
839}
static bool float8_ge(const float8 val1, const float8 val2)
static bool float8_le(const float8 val1, const float8 val2)
static bool float8_eq(const float8 val1, const float8 val2)
static void fallbackSplit(GistEntryVector *entryvec, GIST_SPLITVEC *v)
static int interval_cmp_upper(const void *i1, const void *i2)
#define PLACE_RIGHT(box, off)
static void g_box_consider_split(ConsiderSplitContext *context, int dimNum, float8 rightLower, int minLeftCount, float8 leftUpper, int maxLeftCount)
static int interval_cmp_lower(const void *i1, const void *i2)
static int common_entry_cmp(const void *i1, const void *i2)
#define PLACE_LEFT(box, off)
void * palloc0(Size size)
Datum lower(PG_FUNCTION_ARGS)
Datum upper(PG_FUNCTION_ARGS)
#define qsort(a, b, c, d)
References adjustBox(), Assert(), ConsiderSplitContext::boundingBox, box_penalty(), common_entry_cmp(), DatumGetBoxP(), CommonEntry::delta, ConsiderSplitContext::dim, ConsiderSplitContext::entriesCount, fallbackSplit(), ConsiderSplitContext::first, FirstOffsetNumber, float8_eq(), float8_ge(), float8_gt(), float8_le(), float8_lt(), float8_mi(), g_box_consider_split(), BOX::high, i, CommonEntry::index, interval_cmp_lower(), interval_cmp_upper(), GISTENTRY::key, ConsiderSplitContext::leftUpper, LIMIT_RATIO, BOX::low, SplitInterval::lower, lower(), GistEntryVector::n, OffsetNumberNext, palloc(), palloc0(), PG_GETARG_POINTER, PG_RETURN_POINTER, PLACE_LEFT, PLACE_RIGHT, PointerGetDatum(), qsort, ConsiderSplitContext::rightLower, GIST_SPLITVEC::spl_ldatum, GIST_SPLITVEC::spl_left, GIST_SPLITVEC::spl_nleft, GIST_SPLITVEC::spl_nright, GIST_SPLITVEC::spl_rdatum, GIST_SPLITVEC::spl_right, SplitInterval::upper, upper(), GistEntryVector::vector, Point::x, and Point::y.
◆ gist_box_same()
◆ gist_box_union()
Definition at line 164 of file gistproc.c.
165{
168 int numranges,
169 i;
171 *pageunion;
172
173 numranges = entryvec->n;
176 memcpy(pageunion, cur, sizeof(BOX));
177
178 for (i = 1; i < numranges; i++)
179 {
182 }
183 *sizep = sizeof(BOX);
184
186}
References adjustBox(), cur, DatumGetBoxP(), i, GISTENTRY::key, GistEntryVector::n, palloc(), PG_GETARG_POINTER, PG_RETURN_POINTER, and GistEntryVector::vector.
◆ gist_circle_compress()
Definition at line 1100 of file gistproc.c.
1101{
1104
1106 {
1109
1115
1119 entry->offset, false);
1120 }
1121 else
1122 retval = entry;
1124}
static float8 float8_pl(const float8 val1, const float8 val2)
static CIRCLE * DatumGetCircleP(Datum X)
#define gistentryinit(e, k, r, pg, o, l)
References CIRCLE::center, DatumGetCircleP(), float8_mi(), float8_pl(), gistentryinit, BOX::high, GISTENTRY::key, GISTENTRY::leafkey, BOX::low, GISTENTRY::offset, GISTENTRY::page, palloc(), PG_GETARG_POINTER, PG_RETURN_POINTER, PointerGetDatum(), CIRCLE::radius, GISTENTRY::rel, Point::x, and Point::y.
◆ gist_circle_consistent()
Definition at line 1130 of file gistproc.c.
1131{
1135
1136
1138 BOX bbox;
1139 bool result;
1140
1141
1142 *recheck = true;
1143
1146
1147
1148
1149
1150
1151
1156
1158 &bbox, strategy);
1159
1161}
#define PG_GETARG_CIRCLE_P(n)
References CIRCLE::center, DatumGetBoxP(), float8_mi(), float8_pl(), BOX::high, GISTENTRY::key, BOX::low, PG_GETARG_CIRCLE_P, PG_GETARG_POINTER, PG_GETARG_UINT16, PG_RETURN_BOOL, CIRCLE::radius, rtree_internal_consistent(), Point::x, and Point::y.
Referenced by gist_point_consistent().
◆ gist_circle_distance()
◆ gist_point_compress()
Definition at line 1168 of file gistproc.c.
1169{
1171
1172 if (entry->leafkey)
1173 {
1177
1178 box->high = box->low = *point;
1179
1182
1184 }
1185
1187}
References BoxPGetDatum(), DatumGetPointP(), gistentryinit, BOX::high, GISTENTRY::key, GISTENTRY::leafkey, BOX::low, GISTENTRY::offset, GISTENTRY::page, palloc(), PG_GETARG_POINTER, PG_RETURN_POINTER, and GISTENTRY::rel.
◆ gist_point_consistent()
Definition at line 1337 of file gistproc.c.
1338{
1342 bool result;
1344
1345
1346
1347
1348
1353
1355 switch (strategyGroup)
1356 {
1362 *recheck = false;
1363 break;
1365 {
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378 BOX *query,
1380
1383
1384 result = (key->high.x >= query->low.x &&
1385 key->low.x <= query->high.x &&
1386 key->high.y >= query->low.y &&
1387 key->low.y <= query->high.y);
1388 *recheck = false;
1389 }
1390 break;
1392 {
1394
1400
1402 {
1403
1404
1405
1406
1408
1414 *recheck = false;
1415 }
1416 }
1417 break;
1419 {
1421
1427
1429 {
1430
1431
1432
1433
1435
1441 *recheck = false;
1442 }
1443 }
1444 break;
1445 default:
1446 elog(ERROR, "unrecognized strategy number: %d", strategy);
1447 result = false;
1448 break;
1449 }
1450
1452}
#define DirectFunctionCall5(func, arg1, arg2, arg3, arg4, arg5)
#define PG_GETARG_POINT_P(n)
static Datum PolygonPGetDatum(const POLYGON *X)
#define PG_GETARG_POLYGON_P(n)
static Datum CirclePGetDatum(const CIRCLE *X)
Datum poly_contain_pt(PG_FUNCTION_ARGS)
Datum circle_contain_pt(PG_FUNCTION_ARGS)
#define BoxStrategyNumberGroup
#define CircleStrategyNumberGroup
Datum gist_circle_consistent(PG_FUNCTION_ARGS)
#define PolygonStrategyNumberGroup
Datum gist_poly_consistent(PG_FUNCTION_ARGS)
static bool gist_point_consistent_internal(StrategyNumber strategy, bool isLeaf, BOX *key, Point *query)
static Datum Int16GetDatum(int16 X)
#define RTOldBelowStrategyNumber
#define RTOldAboveStrategyNumber
References Assert(), BoxStrategyNumberGroup, circle_contain_pt(), CirclePGetDatum(), CircleStrategyNumberGroup, DatumGetBool(), DatumGetBoxP(), DirectFunctionCall2, DirectFunctionCall5, elog, ERROR, GeoStrategyNumberOffset, gist_circle_consistent(), GIST_LEAF, gist_point_consistent_internal(), gist_poly_consistent(), BOX::high, Int16GetDatum(), GISTENTRY::key, sort-test::key, BOX::low, PG_GETARG_BOX_P, PG_GETARG_CIRCLE_P, PG_GETARG_POINT_P, PG_GETARG_POINTER, PG_GETARG_POLYGON_P, PG_GETARG_UINT16, PG_RETURN_BOOL, PointerGetDatum(), PointPGetDatum(), PointStrategyNumberGroup, poly_contain_pt(), PolygonPGetDatum(), PolygonStrategyNumberGroup, RTAboveStrategyNumber, RTBelowStrategyNumber, RTOldAboveStrategyNumber, RTOldBelowStrategyNumber, RTOverlapStrategyNumber, Point::x, and Point::y.
◆ gist_point_consistent_internal()
static bool gist_point_consistent_internal ( StrategyNumber strategy, bool isLeaf, BOX * key, Point * query ) | static |
---|
Definition at line 1287 of file gistproc.c.
1289{
1290 bool result = false;
1291
1292 switch (strategy)
1293 {
1295 result = FPlt(key->low.x, query->x);
1296 break;
1298 result = FPgt(key->high.x, query->x);
1299 break;
1301 result = FPgt(key->high.y, query->y);
1302 break;
1304 result = FPlt(key->low.y, query->y);
1305 break;
1307 if (isLeaf)
1308 {
1309
1310 result = (FPeq(key->low.x, query->x) &&
1311 FPeq(key->low.y, query->y));
1312 }
1313 else
1314 {
1315 result = (FPle(query->x, key->high.x) &&
1316 FPge(query->x, key->low.x) &&
1317 FPle(query->y, key->high.y) &&
1318 FPge(query->y, key->low.y));
1319 }
1320 break;
1321 default:
1322 elog(ERROR, "unrecognized strategy number: %d", strategy);
1323 result = false;
1324 break;
1325 }
1326
1327 return result;
1328}
static bool FPlt(double A, double B)
static bool FPge(double A, double B)
static bool FPgt(double A, double B)
static bool FPle(double A, double B)
static bool FPeq(double A, double B)
References elog, ERROR, FPeq(), FPge(), FPgt(), FPle(), FPlt(), sort-test::key, RTAboveStrategyNumber, RTBelowStrategyNumber, RTLeftStrategyNumber, RTRightStrategyNumber, RTSameStrategyNumber, Point::x, and Point::y.
Referenced by gist_point_consistent().
◆ gist_point_distance()
Definition at line 1455 of file gistproc.c.
1456{
1461
1462 switch (strategyGroup)
1463 {
1468 break;
1469 default:
1470 elog(ERROR, "unrecognized strategy number: %d", strategy);
1471 distance = 0.0;
1472 break;
1473 }
1474
1476}
References computeDistance(), DatumGetBoxP(), elog, ERROR, GeoStrategyNumberOffset, GIST_LEAF, GISTENTRY::key, PG_GETARG_POINT_P, PG_GETARG_POINTER, PG_GETARG_UINT16, PG_RETURN_FLOAT8, and PointStrategyNumberGroup.
◆ gist_point_fetch()
Definition at line 1196 of file gistproc.c.
1197{
1202
1204
1210 entry->offset, false);
1211
1213}
References DatumGetBoxP(), gistentryinit, BOX::high, GISTENTRY::key, GISTENTRY::offset, GISTENTRY::page, palloc(), PG_GETARG_POINTER, PG_RETURN_POINTER, PointerGetDatum(), GISTENTRY::rel, Point::x, and Point::y.
◆ gist_point_sortsupport()
Definition at line 1745 of file gistproc.c.
1746{
1748
1750 {
1755 }
1756 else
1757 {
1759 }
1761}
static int gist_bbox_zorder_cmp(Datum a, Datum b, SortSupport ssup)
static Datum gist_bbox_zorder_abbrev_convert(Datum original, SortSupport ssup)
static bool gist_bbox_zorder_abbrev_abort(int memtupcount, SortSupport ssup)
struct SortSupportData * SortSupport
int(* comparator)(Datum x, Datum y, SortSupport ssup)
Datum(* abbrev_converter)(Datum original, SortSupport ssup)
int(* abbrev_full_comparator)(Datum x, Datum y, SortSupport ssup)
bool(* abbrev_abort)(int memtupcount, SortSupport ssup)
int ssup_datum_unsigned_cmp(Datum x, Datum y, SortSupport ssup)
References SortSupportData::abbrev_abort, SortSupportData::abbrev_converter, SortSupportData::abbrev_full_comparator, SortSupportData::abbreviate, SortSupportData::comparator, gist_bbox_zorder_abbrev_abort(), gist_bbox_zorder_abbrev_convert(), gist_bbox_zorder_cmp(), PG_GETARG_POINTER, PG_RETURN_VOID, and ssup_datum_unsigned_cmp().
◆ gist_poly_compress()
Definition at line 1035 of file gistproc.c.
1036{
1039
1041 {
1044
1046 memcpy(r, &(in->boundbox), sizeof(BOX));
1047
1051 entry->offset, false);
1052 }
1053 else
1054 retval = entry;
1056}
static POLYGON * DatumGetPolygonP(Datum X)
References POLYGON::boundbox, DatumGetPolygonP(), gistentryinit, GISTENTRY::key, GISTENTRY::leafkey, GISTENTRY::offset, GISTENTRY::page, palloc(), PG_GETARG_POINTER, PG_RETURN_POINTER, PointerGetDatum(), and GISTENTRY::rel.
◆ gist_poly_consistent()
Definition at line 1062 of file gistproc.c.
1063{
1067
1068
1070 bool result;
1071
1072
1073 *recheck = true;
1074
1077
1078
1079
1080
1081
1082
1084 &(query->boundbox), strategy);
1085
1086
1088
1090}
#define PG_FREE_IF_COPY(ptr, n)
References POLYGON::boundbox, DatumGetBoxP(), GISTENTRY::key, PG_FREE_IF_COPY, PG_GETARG_POINTER, PG_GETARG_POLYGON_P, PG_GETARG_UINT16, PG_RETURN_BOOL, and rtree_internal_consistent().
Referenced by gist_point_consistent().
◆ gist_poly_distance()
◆ ieee_float32_to_uint32()
static uint32 ieee_float32_to_uint32 ( float f) | static |
---|
Definition at line 1603 of file gistproc.c.
1604{
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645 if (isnan(f))
1646 return 0xFFFFFFFF;
1647 else
1648 {
1649 union
1650 {
1651 float f;
1653 } u;
1654
1655 u.f = f;
1656
1657
1658 if ((u.i & 0x80000000) != 0)
1659 {
1660
1661
1662
1663
1664 Assert(f <= 0);
1665 u.i ^= 0xFFFFFFFF;
1666 }
1667 else
1668 {
1669
1670 u.i |= 0x80000000;
1671 }
1672
1673 return u.i;
1674 }
1675}
Referenced by point_zorder_internal().
◆ interval_cmp_lower()
static int interval_cmp_lower ( const void * i1, const void * i2 ) | static |
---|
◆ interval_cmp_upper()
static int interval_cmp_upper ( const void * i1, const void * i2 ) | static |
---|
◆ non_negative()
static float non_negative ( float val) | inlinestatic |
---|
◆ part_bits32_by2()
◆ point_zorder_internal()
◆ rt_box_union()
static void rt_box_union ( BOX * n, const BOX * a, const BOX * b ) | static |
---|
◆ rtree_internal_consistent()
Definition at line 957 of file gistproc.c.
958{
959 bool retval;
960
961 switch (strategy)
962 {
967 break;
972 break;
977 break;
982 break;
987 break;
993 break;
998 break;
1003 break;
1008 break;
1013 break;
1018 break;
1019 default:
1020 elog(ERROR, "unrecognized strategy number: %d", strategy);
1021 retval = false;
1022 break;
1023 }
1024 return retval;
1025}
References box_above(), box_below(), box_contain(), box_left(), box_overabove(), box_overbelow(), box_overlap(), box_overleft(), box_overright(), box_right(), DatumGetBool(), DirectFunctionCall2, elog, ERROR, sort-test::key, PointerGetDatum(), RTAboveStrategyNumber, RTBelowStrategyNumber, RTContainedByStrategyNumber, RTContainsStrategyNumber, RTLeftStrategyNumber, RTOverAboveStrategyNumber, RTOverBelowStrategyNumber, RTOverlapStrategyNumber, RTOverLeftStrategyNumber, RTOverRightStrategyNumber, RTRightStrategyNumber, and RTSameStrategyNumber.
Referenced by gist_box_consistent(), gist_circle_consistent(), and gist_poly_consistent().
◆ size_box()
static float8 size_box ( const BOX * box) | static |
---|