PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ gserialized_gist_compress()

Datum gserialized_gist_compress ( PG_FUNCTION_ARGS  )

Definition at line 912 of file gserialized_gist_nd.c.

913{
914 GISTENTRY *entry_in = (GISTENTRY *)PG_GETARG_POINTER(0);
915 GISTENTRY *entry_out = NULL;
916 char gidxmem[GIDX_MAX_SIZE];
917 GIDX *bbox_out = (GIDX *)gidxmem;
918 int result = LW_SUCCESS;
919 uint32_t i;
920
921 POSTGIS_DEBUG(4, "[GIST] 'compress' function called");
922
923 /*
924 ** Not a leaf key? There's nothing to do.
925 ** Return the input unchanged.
926 */
927 if (!entry_in->leafkey)
928 {
929 POSTGIS_DEBUG(4, "[GIST] non-leafkey entry, returning input unaltered");
930 PG_RETURN_POINTER(entry_in);
931 }
932
933 POSTGIS_DEBUG(4, "[GIST] processing leafkey input");
934 entry_out = palloc(sizeof(GISTENTRY));
935
936 /*
937 ** Null key? Make a copy of the input entry and
938 ** return.
939 */
940 if (!DatumGetPointer(entry_in->key))
941 {
942 POSTGIS_DEBUG(4, "[GIST] leafkey is null");
943 gistentryinit(*entry_out, (Datum)0, entry_in->rel, entry_in->page, entry_in->offset, false);
944 POSTGIS_DEBUG(4, "[GIST] returning copy of input");
945 PG_RETURN_POINTER(entry_out);
946 }
947
948 /* Extract our index key from the GiST entry. */
949 result = gserialized_datum_get_gidx_p(entry_in->key, bbox_out);
950
951 /* Is the bounding box valid (non-empty, non-infinite) ?
952 * If not, use the "unknown" GIDX. */
953 if (result == LW_FAILURE)
954 {
955 POSTGIS_DEBUG(4, "[GIST] empty geometry!");
956 gidx_set_unknown(bbox_out);
957 gistentryinit(*entry_out,
958 PointerGetDatum(gidx_copy(bbox_out)),
959 entry_in->rel,
960 entry_in->page,
961 entry_in->offset,
962 false);
963 PG_RETURN_POINTER(entry_out);
964 }
965
966 POSTGIS_DEBUGF(4, "[GIST] got entry_in->key: %s", gidx_to_string(bbox_out));
967
968 /* ORIGINAL VERSION */
969 /* Check all the dimensions for finite values.
970 * If not, use the "unknown" GIDX as a key */
971 for (i = 0; i < GIDX_NDIMS(bbox_out); i++)
972 {
973 if (!isfinite(GIDX_GET_MAX(bbox_out, i)) || !isfinite(GIDX_GET_MIN(bbox_out, i)))
974 {
975 gidx_set_unknown(bbox_out);
976 gistentryinit(*entry_out,
977 PointerGetDatum(gidx_copy(bbox_out)),
978 entry_in->rel,
979 entry_in->page,
980 entry_in->offset,
981 false);
982 PG_RETURN_POINTER(entry_out);
983 }
984 }
985
986 /* Ensure bounding box has minimums below maximums. */
987 gidx_validate(bbox_out);
988
989 /* Prepare GISTENTRY for return. */
990 gistentryinit(
991 *entry_out, PointerGetDatum(gidx_copy(bbox_out)), entry_in->rel, entry_in->page, entry_in->offset, false);
992
993 /* Return GISTENTRY. */
994 POSTGIS_DEBUG(4, "[GIST] 'compress' function complete");
995 PG_RETURN_POINTER(entry_out);
996}
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition cu_print.c:267
void gidx_set_unknown(GIDX *a)
GIDX * gidx_copy(GIDX *b)
void gidx_validate(GIDX *b)
#define LW_FAILURE
Definition liblwgeom.h:96
#define LW_SUCCESS
Definition liblwgeom.h:97

References gidx_copy(), gidx_set_unknown(), gidx_validate(), LW_FAILURE, LW_SUCCESS, and result.

Here is the call graph for this function: