17 #include "../postgis_config.h" 19 #include "lwgeom_cache.h" 67 #define PREPARED_BACKEND_HASH_SIZE 32 90 #ifdef MEMORY_CONTEXT_CHECKING 91 static void PreparedCacheCheck(MemoryContext context);
106 #ifdef MEMORY_CONTEXT_CHECKING 129 elog(ERROR,
"PreparedCacheDelete: Trying to delete non-existant hash entry object with MemoryContext key (%p)", (
void *)context);
131 POSTGIS_DEBUGF(3,
"deleting geom object (%p) and prepared geom object (%p) with MemoryContext key (%p)", pghe->
geom, pghe->
prepared_geom, context);
137 GEOSGeom_destroy( (GEOSGeometry *)pghe->
geom );
170 fprintf(stderr,
"%s: Prepared context\n", context->name);
173 #ifdef MEMORY_CONTEXT_CHECKING 175 PreparedCacheCheck(MemoryContext context)
193 hashval = DatumGetUInt32(hash_any(key, keysize));
203 ctl.keysize =
sizeof(MemoryContext);
230 elog(ERROR,
"AddPrepGeomHashEntry: This memory context is already in use! (%p)", (
void *)pghe.
context);
264 elog(ERROR,
"DeletePrepGeomHashEntry: There was an error removing the geometry object from this MemoryContext (%p)", (
void *)mcxt);
304 "PostGIS Prepared Geometry Context");
317 lwpgerror(
"PrepGeomCacheBuilder asked to build new prepcache where one already exists.");
335 prepcache->
argnum = cache->argnum;
344 lwpgerror(
"PrepGeomCacheBuilder failed to find hash entry for context %p", prepcache->
context_callback);
380 lwpgerror(
"PrepGeomCacheCleaner failed to find hash entry for context %p", prepcache->
context_callback);
389 POSTGIS_DEBUGF(3,
"PrepGeomCacheFreeer: freeing %p argnum %d", prepcache, prepcache->
argnum);
391 GEOSGeom_destroy( (GEOSGeometry *)prepcache->
geom );
405 prepcache->
type = PREP_CACHE_ENTRY;
406 return (GeomCache*)prepcache;
static bool PreparedCacheIsEmpty(MemoryContext context)
const GEOSPreparedGeometry * prepared_geom
#define PREPARED_BACKEND_HASH_SIZE
static void PreparedCacheInit(MemoryContext context)
uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.
static void DeletePrepGeomHashEntry(MemoryContext mcxt)
static void PreparedCacheReset(MemoryContext context)
static void PreparedCacheDelete(MemoryContext context)
static int PrepGeomCacheCleaner(GeomCache *cache)
This function is passed into the generic GetGeomCache function in the case of a cache miss...
const GEOSPreparedGeometry * prepared_geom
MemoryContext context_statement
static GeomCacheMethods PrepGeomCacheMethods
const GEOSGeometry * geom
static void AddPrepGeomHashEntry(PrepGeomHashEntry pghe)
const GEOSGeometry * geom
uint32 mcxt_ptr_hasha(const void *key, Size keysize)
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, int autofix)
static void CreatePrepGeomHash(void)
static GeomCache * PrepGeomCacheAllocator()
static MemoryContextMethods PreparedCacheContextMethods
static PrepGeomHashEntry * GetPrepGeomHashEntry(MemoryContext mcxt)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
PrepGeomCache * GetPrepGeomCache(FunctionCallInfoData *fcinfo, GSERIALIZED *g1, GSERIALIZED *g2)
Given a couple potential geometries and a function call context, return a prepared structure for one ...
MemoryContext context_callback
static int PrepGeomCacheBuilder(const LWGEOM *lwgeom, GeomCache *cache)
Given a generic GeomCache, and a geometry to prepare, prepare a PrepGeomCache and stick it into the G...
static HTAB * PrepGeomHash
static void PreparedCacheStats(MemoryContext context, int level)