25#include "utils/fmgrprotos.h"
44#define LIMIT_RATIO 0.3
150 b->high.x =
addon->high.x;
154 b->high.y =
addon->high.y;
415 (overlap == context->
overlap && ratio > context->
ratio))
446 context->
first =
false;
447 context->
ratio = ratio;
537 context.
first =
true;
538 for (dim = 0; dim < 2; dim++)
615 while (i1 < nentries &&
630 while (i2 < nentries &&
674 rightLower, i1 + 1, leftUpper, i2 + 1);
713#define PLACE_LEFT(box, off) \
715 if (v->spl_nleft > 0) \
716 adjustBox(leftBox, box); \
719 v->spl_left[v->spl_nleft++] = off; \
722#define PLACE_RIGHT(box, off) \
724 if (v->spl_nright > 0) \
725 adjustBox(rightBox, box); \
727 *rightBox = *(box); \
728 v->spl_right[v->spl_nright++] = off; \
744 if (context.
dim == 0)
940 elog(
ERROR,
"unrecognized strategy number: %d", strategy);
1021 elog(
ERROR,
"unrecognized strategy number: %d", strategy);
1219#define point_point_distance(p1,p2) \
1220 DatumGetFloat8(DirectFunctionCall2(point_distance, \
1221 PointPGetDatum(p1), PointPGetDatum(p2)))
1248 elog(
ERROR,
"inconsistent point values");
1259 elog(
ERROR,
"inconsistent point values");
1291 bool isLeaf,
BOX *key,
Point *query)
1293 bool result =
false;
1298 result =
FPlt(key->low.x, query->
x);
1301 result =
FPgt(key->high.x, query->
x);
1304 result =
FPgt(key->high.y, query->
y);
1307 result =
FPlt(key->low.y, query->
y);
1313 result = (
FPeq(key->low.x, query->
x) &&
1314 FPeq(key->low.y, query->
y));
1318 result = (
FPle(query->
x, key->high.x) &&
1319 FPge(query->
x, key->low.x) &&
1320 FPle(query->
y, key->high.y) &&
1321 FPge(query->
y, key->low.y));
1325 elog(
ERROR,
"unrecognized strategy number: %d", strategy);
1333#define GeoStrategyNumberOffset 20
1334#define PointStrategyNumberGroup 0
1335#define BoxStrategyNumberGroup 1
1336#define PolygonStrategyNumberGroup 2
1337#define CircleStrategyNumberGroup 3
1387 result = (key->high.x >= query->
low.
x &&
1388 key->low.x <= query->
high.
x &&
1389 key->high.y >= query->
low.
y &&
1390 key->low.y <= query->
high.
y);
1413 &&
box->high.y ==
box->low.y);
1440 &&
box->high.y ==
box->low.y);
1449 elog(
ERROR,
"unrecognized strategy number: %d", strategy);
1473 elog(
ERROR,
"unrecognized strategy number: %d", strategy);
1495 elog(
ERROR,
"unrecognized strategy number: %d", strategy);
1596 n = (n | (n << 16)) &
UINT64CONST(0x0000FFFF0000FFFF);
1597 n = (n | (n << 8)) &
UINT64CONST(0x00FF00FF00FF00FF);
1598 n = (n | (n << 4)) &
UINT64CONST(0x0F0F0F0F0F0F0F0F);
1599 n = (n | (n << 2)) &
UINT64CONST(0x3333333333333333);
1600 n = (n | (n << 1)) &
UINT64CONST(0x5555555555555555);
1664 if ((u.i & 0x80000000) != 0)
1699 if (
p1->x ==
p2->x &&
p1->y ==
p2->y)
#define Assert(condition)
#define palloc_object(type)
#define palloc0_object(type)
int float8_cmp_internal(float8 a, float8 b)
static float8 float8_min(const float8 val1, const float8 val2)
static float8 float8_mul(const float8 val1, const float8 val2)
static float4 float4_div(const float4 val1, const float4 val2)
static float8 float8_pl(const float8 val1, const float8 val2)
static float8 float8_mi(const float8 val1, const float8 val2)
static float8 get_float8_infinity(void)
static bool float8_ge(const float8 val1, const float8 val2)
static float8 float8_max(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 float8 float8_div(const float8 val1, const float8 val2)
static bool float8_lt(const float8 val1, const float8 val2)
static bool float8_gt(const float8 val1, const float8 val2)
#define PG_FREE_IF_COPY(ptr, n)
#define DirectFunctionCall2(func, arg1, arg2)
#define PG_RETURN_FLOAT8(x)
#define PG_GETARG_POINTER(n)
#define PG_GETARG_DATUM(n)
#define PG_GETARG_UINT16(n)
#define DirectFunctionCall5(func, arg1, arg2, arg3, arg4, arg5)
#define PG_RETURN_POINTER(x)
#define PG_RETURN_BOOL(x)
static bool FPlt(double A, double B)
#define PG_GETARG_POINT_P(n)
static bool FPge(double A, double B)
static Datum PolygonPGetDatum(const POLYGON *X)
static Point * DatumGetPointP(Datum X)
static Datum PointPGetDatum(const Point *X)
static POLYGON * DatumGetPolygonP(Datum X)
static BOX * DatumGetBoxP(Datum X)
#define PG_GETARG_BOX_P(n)
#define PG_GETARG_POLYGON_P(n)
static CIRCLE * DatumGetCircleP(Datum X)
static Datum CirclePGetDatum(const CIRCLE *X)
#define PG_GETARG_CIRCLE_P(n)
static bool FPgt(double A, double B)
static bool FPle(double A, double B)
static Datum BoxPGetDatum(const BOX *X)
static bool FPeq(double A, double B)
Datum box_left(PG_FUNCTION_ARGS)
Datum box_right(PG_FUNCTION_ARGS)
Datum box_same(PG_FUNCTION_ARGS)
Datum poly_contain_pt(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 circle_contain_pt(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)
#define gistentryinit(e, k, r, pg, o, l)
static void adjustBox(BOX *b, const BOX *addon)
static void fallbackSplit(GistEntryVector *entryvec, GIST_SPLITVEC *v)
Datum gist_box_penalty(PG_FUNCTION_ARGS)
#define BoxStrategyNumberGroup
Datum gist_box_picksplit(PG_FUNCTION_ARGS)
Datum gist_circle_compress(PG_FUNCTION_ARGS)
static bool rtree_internal_consistent(BOX *key, BOX *query, StrategyNumber strategy)
Datum gist_box_consistent(PG_FUNCTION_ARGS)
static int interval_cmp_upper(const void *i1, const void *i2)
static int gist_bbox_zorder_cmp(Datum a, Datum b, SortSupport ssup)
Datum gist_box_distance(PG_FUNCTION_ARGS)
#define point_point_distance(p1, p2)
static float8 gist_bbox_distance(GISTENTRY *entry, Datum query, StrategyNumber strategy)
Datum gist_poly_compress(PG_FUNCTION_ARGS)
static void rt_box_union(BOX *n, const BOX *a, const BOX *b)
#define GeoStrategyNumberOffset
#define PLACE_RIGHT(box, off)
Datum gist_poly_distance(PG_FUNCTION_ARGS)
static void g_box_consider_split(ConsiderSplitContext *context, int dimNum, float8 rightLower, int minLeftCount, float8 leftUpper, int maxLeftCount)
Datum gist_point_distance(PG_FUNCTION_ARGS)
static float8 box_penalty(const BOX *original, const BOX *new)
Datum gist_circle_distance(PG_FUNCTION_ARGS)
static Datum gist_bbox_zorder_abbrev_convert(Datum original, SortSupport ssup)
#define CircleStrategyNumberGroup
static uint64 part_bits32_by2(uint32 x)
Datum gist_point_sortsupport(PG_FUNCTION_ARGS)
#define PointStrategyNumberGroup
Datum gist_box_union(PG_FUNCTION_ARGS)
static int interval_cmp_lower(const void *i1, const void *i2)
static float8 size_box(const BOX *box)
static uint32 ieee_float32_to_uint32(float f)
Datum gist_circle_consistent(PG_FUNCTION_ARGS)
static bool gist_box_leaf_consistent(BOX *key, BOX *query, StrategyNumber strategy)
static int common_entry_cmp(const void *i1, const void *i2)
#define PolygonStrategyNumberGroup
Datum gist_poly_consistent(PG_FUNCTION_ARGS)
Datum gist_point_compress(PG_FUNCTION_ARGS)
static uint64 point_zorder_internal(float4 x, float4 y)
Datum gist_point_consistent(PG_FUNCTION_ARGS)
static bool gist_point_consistent_internal(StrategyNumber strategy, bool isLeaf, BOX *key, Point *query)
Datum gist_box_same(PG_FUNCTION_ARGS)
#define PLACE_LEFT(box, off)
static bool gist_bbox_zorder_abbrev_abort(int memtupcount, SortSupport ssup)
static float8 computeDistance(bool isLeaf, BOX *box, Point *point)
Datum gist_point_fetch(PG_FUNCTION_ARGS)
static float non_negative(float val)
#define OffsetNumberNext(offsetNumber)
#define FirstOffsetNumber
Datum lower(PG_FUNCTION_ARGS)
Datum upper(PG_FUNCTION_ARGS)
#define qsort(a, b, c, d)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
static Datum UInt64GetDatum(uint64 X)
static Datum Int16GetDatum(int16 X)
static struct cvec * range(struct vars *v, chr a, chr b, int cases)
struct SortSupportData * SortSupport
#define RTOverlapStrategyNumber
#define RTLeftStrategyNumber
#define RTOverRightStrategyNumber
#define RTRightStrategyNumber
#define RTSameStrategyNumber
#define RTOverAboveStrategyNumber
#define RTOldBelowStrategyNumber
#define RTContainsStrategyNumber
#define RTOverBelowStrategyNumber
#define RTBelowStrategyNumber
#define RTOldAboveStrategyNumber
#define RTAboveStrategyNumber
#define RTOverLeftStrategyNumber
#define RTContainedByStrategyNumber
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)