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-existant 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 #if POSTGIS_PGSQL_VERSION >= 96 159 PreparedCacheStats(MemoryContext context,
int level,
bool print, MemoryContextCounters *totals)
161 PreparedCacheStats(MemoryContext context,
int level)
171 #ifdef MEMORY_CONTEXT_CHECKING 173 PreparedCacheCheck(MemoryContext context)
184 static MemoryContextMethods PreparedCacheContextMethods =
193 PreparedCacheIsEmpty,
195 #ifdef MEMORY_CONTEXT_CHECKING 212 hashval = DatumGetUInt32(hash_any(key, keysize));
222 ctl.keysize =
sizeof(MemoryContext);
249 elog(ERROR,
"AddPrepGeomHashEntry: This memory context is already in use! (%p)", (
void *)pghe.
context);
283 elog(ERROR,
"DeletePrepGeomHashEntry: There was an error removing the geometry object from this MemoryContext (%p)", (
void *)mcxt);
320 #if POSTGIS_PGSQL_VERSION < 96 322 &PreparedCacheContextMethods,
324 "PostGIS Prepared Geometry Context");
328 "PostGIS Prepared Geometry Context",
329 ALLOCSET_SMALL_SIZES);
334 MemoryContextCallback *callback = MemoryContextAlloc(prepcache->
context_callback,
sizeof(MemoryContextCallback));
353 lwpgerror(
"PrepGeomCacheBuilder asked to build new prepcache where one already exists.");
371 prepcache->
argnum = cache->argnum;
380 lwpgerror(
"PrepGeomCacheBuilder failed to find hash entry for context %p", prepcache->
context_callback);
416 lwpgerror(
"PrepGeomCacheCleaner failed to find hash entry for context %p", prepcache->
context_callback);
425 POSTGIS_DEBUGF(3,
"PrepGeomCacheFreeer: freeing %p argnum %d", prepcache, prepcache->
argnum);
427 GEOSGeom_destroy( (GEOSGeometry *)prepcache->
geom );
441 prepcache->
type = PREP_CACHE_ENTRY;
442 return (GeomCache*)prepcache;
468 return (
PrepGeomCache*)GetGeomCache(fcinfo, &PrepGeomCacheMethods, g1, g2);
PrepGeomCache * GetPrepGeomCache(FunctionCallInfo fcinfo, GSERIALIZED *g1, GSERIALIZED *g2)
Given a couple potential geometries and a function call context, return a prepared structure for one ...
const GEOSPreparedGeometry * prepared_geom
#define PREPARED_BACKEND_HASH_SIZE
uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.
static void DeletePrepGeomHashEntry(MemoryContext mcxt)
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
#define HASH_FIND(hh, head, keyptr, keylen, out)
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 PreparedCacheDelete(void *ptr)
static void CreatePrepGeomHash(void)
static GeomCache * PrepGeomCacheAllocator()
static PrepGeomHashEntry * GetPrepGeomHashEntry(MemoryContext mcxt)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
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