30 #include "../postgis_config.h"
32 #include "lwgeom_cache.h"
80 #define PREPARED_BACKEND_HASH_SIZE 32
101 MemoryContext context = (MemoryContext)ptr;
109 elog(ERROR,
"PreparedCacheDelete: Trying to delete non-existent hash entry object with MemoryContext key (%p)", (
void *)context);
111 POSTGIS_DEBUGF(3,
"deleting geom object (%p) and prepared geom object (%p) with MemoryContext key (%p)", pghe->
geom, pghe->
prepared_geom, context);
117 GEOSGeom_destroy( (GEOSGeometry *)pghe->
geom );
133 hashval = DatumGetUInt32(hash_any(key, keysize));
143 ctl.keysize =
sizeof(MemoryContext);
170 elog(ERROR,
"AddPrepGeomHashEntry: This memory context is already in use! (%p)", (
void *)pghe.
context);
204 elog(ERROR,
"DeletePrepGeomHashEntry: There was an error removing the geometry object from this MemoryContext (%p)", (
void *)mcxt);
241 MemoryContextCallback *callback;
243 "PostGIS Prepared Geometry Context",
244 ALLOCSET_SMALL_SIZES);
249 callback = MemoryContextAlloc(prepcache->
context_callback,
sizeof(MemoryContextCallback));
266 lwpgerror(
"PrepGeomCacheBuilder asked to build new prepcache where one already exists.");
274 prepcache->
gcache.argnum = cache->argnum;
283 lwpgerror(
"PrepGeomCacheBuilder failed to find hash entry for context %p", prepcache->
context_callback);
319 lwpgerror(
"PrepGeomCacheCleaner failed to find hash entry for context %p", prepcache->
context_callback);
328 POSTGIS_DEBUGF(3,
"PrepGeomCacheFreeer: freeing %p argnum %d", prepcache, prepcache->
gcache.argnum);
330 GEOSGeom_destroy( (GEOSGeometry *)prepcache->
geom );
331 prepcache->
gcache.argnum = 0;
344 prepcache->
gcache.type = PREP_CACHE_ENTRY;
345 return (GeomCache*)prepcache;
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, uint8_t autofix)
static GeomCache * PrepGeomCacheAllocator()
static void CreatePrepGeomHash(void)
static HTAB * PrepGeomHash
static void AddPrepGeomHashEntry(PrepGeomHashEntry pghe)
uint32 mcxt_ptr_hasha(const void *key, Size keysize)
static GeomCacheMethods PrepGeomCacheMethods
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 int PrepGeomCacheCleaner(GeomCache *cache)
This function is passed into the generic GetGeomCache function in the case of a cache miss,...
static void PreparedCacheDelete(void *ptr)
static void DeletePrepGeomHashEntry(MemoryContext mcxt)
#define PREPARED_BACKEND_HASH_SIZE
static PrepGeomHashEntry * GetPrepGeomHashEntry(MemoryContext mcxt)
PrepGeomCache * GetPrepGeomCache(FunctionCallInfo fcinfo, SHARED_GSERIALIZED *g1, SHARED_GSERIALIZED *g2)
Given a couple potential geometries and a function call context, return a prepared structure for one ...
const GEOSPreparedGeometry * prepared_geom
MemoryContext context_statement
const GEOSGeometry * geom
MemoryContext context_callback
const GEOSGeometry * geom
const GEOSPreparedGeometry * prepared_geom