Changeset: 8953f25af073 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/8953f25af073
Modified Files:
geom/documentation/functions.tex
geom/monetdb5/geom.c
geom/monetdb5/geom.h
geom/monetdb5/geomBulk.c
geom/monetdb5/geom_atoms.c
geom/monetdb5/geom_atoms.h
Branch: resource_management
Log Message:
in geom use MalBlk allocator explicitly where needed
diffs (truncated from 1185 to 300 lines):
diff --git a/geom/documentation/functions.tex b/geom/documentation/functions.tex
--- a/geom/documentation/functions.tex
+++ b/geom/documentation/functions.tex
@@ -21,7 +21,7 @@ GEOSGeometry. In case {\tt geomWKB} is {
\subsection{geos2wkb}
-{\tt wkb* geos2wkb(const GEOSGeometry* geosGeometry)}
+{\tt wkb* geos2wkb(allocator *, const GEOSGeometry* geosGeometry)}
\vspace{10pt}
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -16,6 +16,7 @@
*/
#include "geom.h"
+#include "gdk_system.h"
#include "geod.h"
#include "geom_atoms.h"
#include "mal_exception.h"
@@ -53,7 +54,7 @@ GEOSGeom_getCollectionType (int GEOSGeom
str
wkbCollectAggrSubGroupedCand(Client ctx, bat *outid, const bat *bid, const bat
*gid, const bat *eid, const bat *sid, const bit *skip_nils)
{
- allocator *ma = ctx->ma;
+ allocator *ma = ctx->curprg->def->ma;
assert(ma);
BAT *b = NULL, *g = NULL, *s = NULL, *out = NULL;
BAT *sortedgroups, *sortedorder;
@@ -157,7 +158,7 @@ wkbCollectAggrSubGroupedCand(Client ctx,
collection =
GEOSGeom_createCollection_r(geoshandle, geomCollectionType, unionGroup,
(unsigned int) geomCount);
GEOSSetSRID_r(geoshandle,
collection,srid);
//Save collection to unions array as wkb
- unions[lastGrp] = geos2wkb(collection);
+ unions[lastGrp] = geos2wkb(ma,
collection);
GEOSGeom_destroy_r(geoshandle,
collection);
//GDKfree(unionGroup);
@@ -187,7 +188,7 @@ wkbCollectAggrSubGroupedCand(Client ctx,
//Last collection
collection = GEOSGeom_createCollection_r(geoshandle,
geomCollectionType, unionGroup, (unsigned int) geomCount);
GEOSSetSRID_r(geoshandle, collection,srid);
- unions[lastGrp] = geos2wkb(collection);
+ unions[lastGrp] = geos2wkb(ma, collection);
GEOSGeom_destroy_r(geoshandle, collection);
//GDKfree(unionGroup);
@@ -236,8 +237,7 @@ wkbCollectAggrSubGrouped(Client ctx, bat
str
wkbCollectAggr(Client ctx, wkb **out, const bat *bid) {
- allocator *ma = ctx->ma;
- assert(ma);
+ allocator *ma = ctx->curprg->def->ma;
str msg = MAL_SUCCEED;
BAT *b = NULL;
GEOSGeom *unionGroup = NULL, collection;
@@ -275,7 +275,7 @@ wkbCollectAggr(Client ctx, wkb **out, co
collection = GEOSGeom_createCollection_r(geoshandle,
geomCollectionType, unionGroup, (unsigned int) count);
GEOSSetSRID_r(geoshandle, collection,srid);
//Result
- (*out) = geos2wkb(collection);
+ (*out) = geos2wkb(ma, collection);
if (*out == NULL)
msg = createException(MAL, "geom.ConvexHull", SQLSTATE(38000)
"Geos operation geos2wkb failed");
@@ -293,7 +293,7 @@ wkbCollectAggr(Client ctx, wkb **out, co
static str
wkbCollect(Client ctx, wkb **out, wkb * const *a, wkb * const *b) {
- (void) ctx;
+ allocator *ma = ctx->curprg->def->ma;
str err = MAL_SUCCEED;
GEOSGeom collection;
/* geom_a and geom_b */
@@ -313,7 +313,7 @@ wkbCollect(Client ctx, wkb **out, wkb *
else
collection = GEOSGeom_createCollection_r(geoshandle,
GEOS_GEOMETRYCOLLECTION, geoms, (unsigned int) 2);
- if ((*out = geos2wkb(collection)) == NULL)
+ if ((*out = geos2wkb(ma, collection)) == NULL)
err = createException(MAL, "geom.Collect", SQLSTATE(38000)
"Geos operation geos2wkb failed");
GEOSGeom_destroy_r(geoshandle, collection);
@@ -594,9 +594,8 @@ transformPolygon(GEOSGeometry **transfor
}
str
-transformMultiGeometry(GEOSGeometry **transformedGeometry, const GEOSGeometry
*geosGeometry, PJ *P, int srid, int geometryType)
-{
- allocator *ma = MT_thread_getallocator();
+transformMultiGeometry(allocator *ma, GEOSGeometry **transformedGeometry,
const GEOSGeometry *geosGeometry, PJ *P, int srid, int geometryType)
+{
assert(ma);
int geometriesNum, subGeometryType, i;
GEOSGeometry **transformedMultiGeometries = NULL;
@@ -662,7 +661,8 @@ transformMultiGeometry(GEOSGeometry **tr
str
wkbTransform(Client ctx, wkb **transformedWKB, wkb **geomWKB, int *srid_src,
int *srid_dst, char **proj4_src_str, char **proj4_dst_str)
{
- (void) ctx;
+ allocator *ma = ctx->curprg->def->ma;
+ (void) ma;
#ifndef HAVE_PROJ
*transformedWKB = NULL;
(void) geomWKB;
@@ -686,7 +686,7 @@ wkbTransform(Client ctx, wkb **transform
is_int_nil(*srid_dst) ||
strNil(*proj4_src_str) ||
strNil(*proj4_dst_str)) {
- if ((*transformedWKB = wkbNULLcopy(ctx->ma)) == NULL)
+ if ((*transformedWKB = wkbNULLcopy(ma)) == NULL)
throw(MAL, "geom.Transform", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
return MAL_SUCCEED;
}
@@ -696,7 +696,7 @@ wkbTransform(Client ctx, wkb **transform
if (strcmp(*proj4_dst_str, "null") == 0)
throw(MAL, "geom.Transform", SQLSTATE(38000) "Cannot find in
spatial_ref_sys srid %d\n", *srid_dst);
if (strcmp(*proj4_src_str, *proj4_dst_str) == 0) {
- if ((*transformedWKB = wkbCopy(ctx->ma, *geomWKB)) == NULL)
+ if ((*transformedWKB = wkbCopy(ma, *geomWKB)) == NULL)
throw(MAL, "geom.Transform", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
return MAL_SUCCEED;
}
@@ -730,7 +730,7 @@ wkbTransform(Client ctx, wkb **transform
case wkbMultiPoint_mdb:
case wkbMultiLineString_mdb:
case wkbMultiPolygon_mdb:
- ret = transformMultiGeometry(&transformedGeosGeometry,
geosGeometry, P, *srid_dst, geometryType);
+ ret = transformMultiGeometry(ma, &transformedGeosGeometry,
geosGeometry, P, *srid_dst, geometryType);
break;
default:
transformedGeosGeometry = NULL;
@@ -741,7 +741,7 @@ wkbTransform(Client ctx, wkb **transform
/* set the new srid */
GEOSSetSRID_r(geoshandle, transformedGeosGeometry, *srid_dst);
/* get the wkb */
- if ((*transformedWKB = geos2wkb(transformedGeosGeometry)) ==
NULL)
+ if ((*transformedWKB = geos2wkb(ma, transformedGeosGeometry))
== NULL)
ret = createException(MAL, "geom.Transform",
SQLSTATE(38000) "Geos operation geos2wkb failed");
/* destroy the geos geometries */
GEOSGeom_destroy_r(geoshandle, transformedGeosGeometry);
@@ -973,11 +973,10 @@ forceDimPolygon(GEOSGeometry **outGeomet
return ret;
}
-static str forceDimGeometry(GEOSGeometry **outGeometry, const GEOSGeometry
*geosGeometry, int dim);
+static str forceDimGeometry(allocator *, GEOSGeometry **outGeometry, const
GEOSGeometry *geosGeometry, int dim);
static str
-forceDimMultiGeometry(GEOSGeometry **outGeometry, const GEOSGeometry
*geosGeometry, int dim)
-{
- allocator *ma = MT_thread_getallocator();
+forceDimMultiGeometry(allocator *ma, GEOSGeometry **outGeometry, const
GEOSGeometry *geosGeometry, int dim)
+{
assert(ma);
int geometriesNum, i;
GEOSGeometry **transformedMultiGeometries = NULL;
@@ -993,7 +992,7 @@ forceDimMultiGeometry(GEOSGeometry **out
for (i = geometriesNum - 1; i >= 0; i--) {
const GEOSGeometry *multiGeometry =
GEOSGetGeometryN_r(geoshandle, geosGeometry, i);
- if ((err = forceDimGeometry(&transformedMultiGeometries[i],
multiGeometry, dim)) != MAL_SUCCEED) {
+ if ((err = forceDimGeometry(ma, &transformedMultiGeometries[i],
multiGeometry, dim)) != MAL_SUCCEED) {
while (++i < geometriesNum)
GEOSGeom_destroy_r(geoshandle,
transformedMultiGeometries[i]);
//GDKfree(transformedMultiGeometries);
@@ -1014,7 +1013,7 @@ forceDimMultiGeometry(GEOSGeometry **out
}
static str
-forceDimGeometry(GEOSGeometry **outGeometry, const GEOSGeometry *geosGeometry,
int dim)
+forceDimGeometry(allocator *ma, GEOSGeometry **outGeometry, const GEOSGeometry
*geosGeometry, int dim)
{
int geometryType = GEOSGeomTypeId_r(geoshandle, geosGeometry) + 1;
@@ -1031,7 +1030,7 @@ forceDimGeometry(GEOSGeometry **outGeome
case wkbMultiLineString_mdb:
case wkbMultiPolygon_mdb:
case wkbGeometryCollection_mdb:
- return forceDimMultiGeometry(outGeometry, geosGeometry, dim);
+ return forceDimMultiGeometry(ma, outGeometry, geosGeometry,
dim);
default:
throw(MAL, "geom.ForceDim", SQLSTATE(38000) "Geos operation %s
unknown geometry type", geom_type2str(geometryType, 0));
}
@@ -1040,13 +1039,13 @@ forceDimGeometry(GEOSGeometry **outGeome
str
wkbForceDim(Client ctx, wkb **outWKB, wkb **geomWKB, int *dim)
{
- (void) ctx;
+ allocator *ma = ctx->curprg->def->ma;
GEOSGeometry *outGeometry;
GEOSGeom geosGeometry;
str err;
if (is_wkb_nil(*geomWKB) || is_int_nil(*dim)) {
- if ((*outWKB = wkbNULLcopy(ctx->ma)) == NULL)
+ if ((*outWKB = wkbNULLcopy(ma)) == NULL)
throw(MAL, "geom.ForceDim", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
return MAL_SUCCEED;
}
@@ -1057,7 +1056,7 @@ wkbForceDim(Client ctx, wkb **outWKB, wk
throw(MAL, "geom.ForceDim", SQLSTATE(38000) "Geos operation
wkb2geos failed");
}
- if ((err = forceDimGeometry(&outGeometry, geosGeometry, *dim)) !=
MAL_SUCCEED) {
+ if ((err = forceDimGeometry(ma, &outGeometry, geosGeometry, *dim)) !=
MAL_SUCCEED) {
GEOSGeom_destroy_r(geoshandle, geosGeometry);
*outWKB = NULL;
return err;
@@ -1065,7 +1064,7 @@ wkbForceDim(Client ctx, wkb **outWKB, wk
GEOSSetSRID_r(geoshandle, outGeometry, GEOSGetSRID_r(geoshandle,
geosGeometry));
- *outWKB = geos2wkb(outGeometry);
+ *outWKB = geos2wkb(ma, outGeometry);
GEOSGeom_destroy_r(geoshandle, geosGeometry);
GEOSGeom_destroy_r(geoshandle, outGeometry);
@@ -1427,13 +1426,13 @@ segmentizeGeometry(GEOSGeometry **outGeo
str
wkbSegmentize(Client ctx, wkb **outWKB, wkb **geomWKB, dbl *sz)
{
- (void) ctx;
+ allocator *ma = ctx->curprg->def->ma;
GEOSGeometry *outGeometry;
GEOSGeom geosGeometry;
str err;
if (is_wkb_nil(*geomWKB) || is_dbl_nil(*sz)) {
- if ((*outWKB = wkbNULLcopy(ctx->ma)) == NULL)
+ if ((*outWKB = wkbNULLcopy(ma)) == NULL)
throw(MAL, "geom.Segmentize", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
return MAL_SUCCEED;
}
@@ -1452,7 +1451,7 @@ wkbSegmentize(Client ctx, wkb **outWKB,
GEOSSetSRID_r(geoshandle, outGeometry, GEOSGetSRID_r(geoshandle,
geosGeometry));
- *outWKB = geos2wkb(outGeometry);
+ *outWKB = geos2wkb(ma, outGeometry);
GEOSGeom_destroy_r(geoshandle, geosGeometry);
GEOSGeom_destroy_r(geoshandle, outGeometry);
@@ -1750,13 +1749,13 @@ translateGeometry(GEOSGeometry **outGeom
str
wkbTranslate(Client ctx, wkb **outWKB, wkb **geomWKB, dbl *dx, dbl *dy, dbl
*dz)
{
- (void) ctx;
+ allocator *ma = ctx->curprg->def->ma;
GEOSGeometry *outGeometry;
GEOSGeom geosGeometry;
str err;
if (is_wkb_nil(*geomWKB) || is_dbl_nil(*dx) || is_dbl_nil(*dy) ||
is_dbl_nil(*dz)) {
- if ((*outWKB = wkbNULLcopy(ctx->ma)) == NULL)
+ if ((*outWKB = wkbNULLcopy(ma)) == NULL)
throw(MAL, "geom.Translate", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
return MAL_SUCCEED;
}
@@ -1775,7 +1774,7 @@ wkbTranslate(Client ctx, wkb **outWKB, w
GEOSSetSRID_r(geoshandle, outGeometry, GEOSGetSRID_r(geoshandle,
geosGeometry));
- *outWKB = geos2wkb(outGeometry);
+ *outWKB = geos2wkb(ma, outGeometry);
GEOSGeom_destroy_r(geoshandle, geosGeometry);
GEOSGeom_destroy_r(geoshandle, outGeometry);
@@ -1792,12 +1791,12 @@ wkbTranslate(Client ctx, wkb **outWKB, w
str
wkbDelaunayTriangles(Client ctx, wkb **outWKB, wkb **geomWKB, dbl *tolerance,
int *flag)
{
- (void) ctx;
+ allocator *ma = ctx->curprg->def->ma;
GEOSGeom outGeometry;
GEOSGeom geosGeometry;
if (is_wkb_nil(*geomWKB) || is_dbl_nil(*tolerance) ||
is_int_nil(*flag)) {
- if ((*outWKB = wkbNULLcopy(ctx->ma)) == NULL)
+ if ((*outWKB = wkbNULLcopy(ma)) == NULL)
throw(MAL, "geom.DelaunayTriangles", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
return MAL_SUCCEED;
}
@@ -1810,7 +1809,7 @@ wkbDelaunayTriangles(Client ctx, wkb **o
throw(MAL, "geom.DelaunayTriangles", SQLSTATE(38000) "Geos
operation GEOSDelaunayTriangulation failed");
}
- *outWKB = geos2wkb(outGeometry);
+ *outWKB = geos2wkb(ma, outGeometry);
GEOSGeom_destroy_r(geoshandle, outGeometry);
if (*outWKB == NULL)
@@ -1822,11 +1821,11 @@ wkbDelaunayTriangles(Client ctx, wkb **o
str
wkbPointOnSurface(Client ctx, wkb **resWKB, wkb **geomWKB)
{
- (void) ctx;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]