30 #include "../postgis_config.h"
32 #include "lwgeom_cache.h"
80 #define PREPARED_BACKEND_HASH_SIZE 32
99 #if POSTGIS_PGSQL_VERSION < 96
105 MemoryContext context = (MemoryContext)ptr;
114 elog(ERROR,
"PreparedCacheDelete: Trying to delete non-existent hash entry object with MemoryContext key (%p)", (
void *)context);
116 POSTGIS_DEBUGF(3,
"deleting geom object (%p) and prepared geom object (%p) with MemoryContext key (%p)", pghe->
geom, pghe->
prepared_geom, context);
122 GEOSGeom_destroy( (GEOSGeometry *)pghe->
geom );
128 #if POSTGIS_PGSQL_VERSION < 96
130 PreparedCacheInit(MemoryContext context)
139 PreparedCacheReset(MemoryContext context)
148 PreparedCacheIsEmpty(MemoryContext context)
158 PreparedCacheStats(MemoryContext context,
int level)
167 #ifdef MEMORY_CONTEXT_CHECKING
169 PreparedCacheCheck(MemoryContext context)
179 static MemoryContextMethods PreparedCacheContextMethods =
188 PreparedCacheIsEmpty,
190 #ifdef MEMORY_CONTEXT_CHECKING
208 hashval = DatumGetUInt32(hash_any(key, keysize));
218 ctl.keysize =
sizeof(MemoryContext);
245 elog(ERROR,
"AddPrepGeomHashEntry: This memory context is already in use! (%p)", (
void *)pghe.
context);
279 elog(ERROR,
"DeletePrepGeomHashEntry: There was an error removing the geometry object from this MemoryContext (%p)", (
void *)mcxt);
316 #if POSTGIS_PGSQL_VERSION < 96
318 &PreparedCacheContextMethods,
320 "PostGIS Prepared Geometry Context");
323 MemoryContextCallback *callback;
325 "PostGIS Prepared Geometry Context",
326 ALLOCSET_SMALL_SIZES);
331 callback = MemoryContextAlloc(prepcache->
context_callback,
sizeof(MemoryContextCallback));
349 lwpgerror(
"PrepGeomCacheBuilder asked to build new prepcache where one already exists.");
367 prepcache->
gcache.argnum = cache->argnum;
376 lwpgerror(
"PrepGeomCacheBuilder failed to find hash entry for context %p", prepcache->
context_callback);
412 lwpgerror(
"PrepGeomCacheCleaner failed to find hash entry for context %p", prepcache->
context_callback);
421 POSTGIS_DEBUGF(3,
"PrepGeomCacheFreeer: freeing %p argnum %d", prepcache, prepcache->
gcache.argnum);
423 GEOSGeom_destroy( (GEOSGeometry *)prepcache->
geom );
424 prepcache->
gcache.argnum = 0;
437 prepcache->
gcache.type = PREP_CACHE_ENTRY;
438 return (GeomCache*)prepcache;
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, uint8_t autofix)
uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
static GeomCache * PrepGeomCacheAllocator()
static void CreatePrepGeomHash(void)
PrepGeomCache * GetPrepGeomCache(FunctionCallInfo fcinfo, GSERIALIZED *g1, GSERIALIZED *g2)
Given a couple potential geometries and a function call context, return a prepared structure for one ...
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)
const GEOSPreparedGeometry * prepared_geom
MemoryContext context_statement
const GEOSGeometry * geom
MemoryContext context_callback
const GEOSGeometry * geom
const GEOSPreparedGeometry * prepared_geom
#define HASH_FIND(hh, head, keyptr, keylen, out)