398 spgInnerConsistentIn *in = (spgInnerConsistentIn *)PG_GETARG_POINTER(0);
399 spgInnerConsistentOut *out = (spgInnerConsistentOut *)PG_GETARG_POINTER(1);
400 MemoryContext old_ctx;
402 int *nodeNumbers, i, j;
403 void **traversalValues;
404 char gidxmem[GIDX_MAX_SIZE];
405 GIDX *
centroid, *query_gbox_index = (GIDX *)gidxmem;
407 POSTGIS_DEBUG(4,
"[SPGIST] 'inner consistent' function called");
412 out->nNodes = in->nNodes;
413 out->nodeNumbers = (
int *)palloc(
sizeof(
int) * in->nNodes);
414 for (i = 0; i < in->nNodes; i++)
415 out->nodeNumbers[i] = i;
425 old_ctx = MemoryContextSwitchTo(in->traversalMemoryContext);
427 centroid = (GIDX *)DatumGetPointer(in->prefixDatum);
433 if (in->traversalValue)
434 cube_box = in->traversalValue;
440 nodeNumbers = (
int *)palloc(
sizeof(
int) * in->nNodes);
441 traversalValues = (
void **)palloc(
sizeof(
void *) * in->nNodes);
443 for (i = 0; i < in->nNodes; i++)
448 for (j = 0; j < in->nkeys; j++)
450 StrategyNumber strategy = in->scankeys[j].sk_strategy;
451 Datum query = in->scankeys[j].sk_argument;
454 if (DatumGetPointer(query) == NULL)
456 POSTGIS_DEBUG(4,
"[SPGIST] null query pointer (!?!)");
462 if (gserialized_datum_get_gidx_p(query, query_gbox_index) ==
LW_FAILURE)
464 POSTGIS_DEBUG(4,
"[SPGIST] null query_gbox_index!");
473 flag =
overlapND(next_cube_box, query_gbox_index);
478 flag =
containND(next_cube_box, query_gbox_index);
482 elog(ERROR,
"unrecognized strategy: %d", strategy);
492 traversalValues[out->nNodes] = next_cube_box;
493 nodeNumbers[out->nNodes] = i;
502 pfree(next_cube_box);
507 out->nodeNumbers = (
int *)palloc(
sizeof(
int) * out->nNodes);
508 out->traversalValues = (
void **)palloc(
sizeof(
void *) * out->nNodes);
509 for (i = 0; i < out->nNodes; i++)
511 out->nodeNumbers[i] = nodeNumbers[i];
512 out->traversalValues[i] = traversalValues[i];
515 pfree(traversalValues);
518 MemoryContextSwitchTo(old_ctx);
#define SPGOverlapStrategyNumber
#define SPGSameStrategyNumber
#define SPGContainedByStrategyNumber
#define SPGContainsStrategyNumber
static bool overlapND(CubeGIDX *cube_box, GIDX *query)
static CubeGIDX * nextCubeBox(CubeGIDX *cube_box, GIDX *centroid, uint16_t octant)
static CubeGIDX * initCubeBox(int ndims)
static bool containND(CubeGIDX *cube_box, GIDX *query)
Datum centroid(PG_FUNCTION_ARGS)