48 static int bound_cmp(
const void *a,
const void *b,
void *
arg);
169 quadrant =
getQuadrant(typcache, centroid, inRange);
171 Assert(quadrant <= in->nNodes);
224 for (i = 0; i < in->
nTuples; i++)
227 &lowerBounds[j], &upperBounds[j], &empty);
238 if (nonEmptyCount == 0)
250 for (i = 0; i < in->
nTuples; i++)
268 &upperBounds[nonEmptyCount / 2],
false);
283 for (i = 0; i < in->
nTuples; i++)
313 bool needPrevious =
false;
320 for (i = 0; i < in->
nNodes; i++)
338 which = (1 << 1) | (1 << 2);
339 for (i = 0; i < in->
nkeys; i++)
401 elog(
ERROR,
"unrecognized range strategy: %d", strategy);
430 which = (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5);
432 for (i = 0; i < in->
nkeys; i++)
452 bool inclusive =
true;
453 bool strictEmpty =
true;
562 &prevLower, &prevUpper, &prevEmpty);
576 prevCentroid ? &prevUpper : NULL);
578 which1 = (1 << 1) | (1 << 4);
580 which1 = (1 << 2) | (1 << 3);
592 prevCentroid ? &prevLower : NULL);
594 which2 = (1 << 1) | (1 << 2);
596 which2 = (1 << 3) | (1 << 4);
601 which &= which1 | which2;
619 which &= (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4);
647 which &= (1 <<
getQuadrant(typcache, centroid, range));
651 elog(
ERROR,
"unrecognized range strategy: %d", strategy);
666 which &= (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4);
683 which &= (1 << 1) | (1 << 2) | (1 << 5);
699 if (cmp > 0 || (!inclusive && cmp == 0))
700 which &= (1 << 3) | (1 << 4) | (1 << 5);
711 which &= (1 << 1) | (1 << 4) | (1 << 5);
727 if (cmp > 0 || (!inclusive && cmp == 0))
728 which &= (1 << 2) | (1 << 3) | (1 << 5);
748 for (i = 1; i <= in->
nNodes; i++)
750 if (which & (1 << i))
755 Datum previousCentroid;
907 if ((prevcmp < 0 && cmp >= 0) || (prevcmp > 0 && cmp < 0))
938 for (i = 0; i < in->
nkeys; i++)
986 elog(
ERROR,
"unrecognized range strategy: %d",
static int bound_cmp(const void *a, const void *b, void *arg)
void range_deserialize(TypeCacheEntry *typcache, const RangeType *range, RangeBound *lower, RangeBound *upper, bool *empty)
bool range_overlaps_internal(TypeCacheEntry *typcache, const RangeType *r1, const RangeType *r2)
#define RANGESTRAT_OVERRIGHT
TypeCacheEntry * range_get_typcache(FunctionCallInfo fcinfo, Oid rngtypid)
#define RANGESTRAT_ADJACENT
#define RangeTypeGetOid(r)
Datum lower(PG_FUNCTION_ARGS)
#define PointerGetDatum(X)
Datum spg_range_quad_choose(PG_FUNCTION_ARGS)
bool range_after_internal(TypeCacheEntry *typcache, const RangeType *r1, const RangeType *r2)
static int adjacent_inner_consistent(TypeCacheEntry *typcache, const RangeBound *arg, const RangeBound *centroid, const RangeBound *prev)
bool range_contains_elem_internal(TypeCacheEntry *typcache, const RangeType *r, Datum val)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
#define PG_GETARG_POINTER(n)
bool bounds_adjacent(TypeCacheEntry *typcache, RangeBound boundA, RangeBound boundB)
Datum upper(PG_FUNCTION_ARGS)
union spgChooseOut::@45 result
#define RangeTypePGetDatum(X)
struct spgChooseOut::@45::@46 matchNode
Datum spg_range_quad_picksplit(PG_FUNCTION_ARGS)
MemoryContext traversalMemoryContext
#define RANGESTRAT_CONTAINS_ELEM
#define RANGESTRAT_BEFORE
StrategyNumber sk_strategy
static struct cvec * range(struct vars *v, chr a, chr b, int cases)
Datum spg_range_quad_inner_consistent(PG_FUNCTION_ARGS)
RangeType * range_serialize(TypeCacheEntry *typcache, RangeBound *lower, RangeBound *upper, bool empty)
Datum datumCopy(Datum value, bool typByVal, int typLen)
bool range_contains_internal(TypeCacheEntry *typcache, const RangeType *r1, const RangeType *r2)
void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg)
Datum spg_range_quad_leaf_consistent(PG_FUNCTION_ARGS)
#define RANGESTRAT_CONTAINS
#define PG_RETURN_BOOL(x)
spgChooseResultType resultType
bool range_overleft_internal(TypeCacheEntry *typcache, const RangeType *r1, const RangeType *r2)
#define Assert(condition)
bool range_before_internal(TypeCacheEntry *typcache, const RangeType *r1, const RangeType *r2)
bool range_contained_by_internal(TypeCacheEntry *typcache, const RangeType *r1, const RangeType *r2)
#define RANGESTRAT_CONTAINED_BY
#define RANGESTRAT_OVERLEFT
#define DatumGetRangeTypeP(X)
bool range_overright_internal(TypeCacheEntry *typcache, const RangeType *r1, const RangeType *r2)
#define RANGESTRAT_OVERLAPS
bool range_adjacent_internal(TypeCacheEntry *typcache, const RangeType *r1, const RangeType *r2)
static int adjacent_cmp_bounds(TypeCacheEntry *typcache, const RangeBound *arg, const RangeBound *centroid)
Datum spg_range_quad_config(PG_FUNCTION_ARGS)
static int16 getQuadrant(TypeCacheEntry *typcache, const RangeType *centroid, const RangeType *tst)
bool range_eq_internal(TypeCacheEntry *typcache, const RangeType *r1, const RangeType *r2)
int range_cmp_bounds(TypeCacheEntry *typcache, const RangeBound *b1, const RangeBound *b2)
static int cmp(const chr *x, const chr *y, size_t len)