[geos-devel] fastunion aggregate

strk strk at keybit.net
Tue Oct 28 10:21:27 EST 2003


I moved unite_sfunc() to postgis_fn.c and renamed it to
geom_accum(). I think that will be a generic function.

again, drop old defs:

> DROP AGGREGATE fastunion(geometry);
> DROP FUNCTION unite_sfunc(geometry[], geometry);
> DROP FUNCTION unite_finalfunc(geometry[]);

and use newer:

> CREATE FUNCTION geom_accum (geometry[],geometry)
>         RETURNS geometry[]
>         AS '@INSTALLDIR@/libpostgis.so.0.8'
>         LANGUAGE 'C'; 
>
> CREATE FUNCTION unite_finalfunc (geometry[])
>         RETURNS geometry
>         AS '@INSTALLDIR@/libpostgis.so.0.8'
>         LANGUAGE 'C'; -- WITH (isstrict); -- can also be strict I think
>
> CREATE AGGREGATE fastunion (
>         sfunc = geom_accum,
>         basetype = geometry,
>         stype = geometry[],
>         finalfunc = unite_finalfunc
> );


--strk;

strk wrote:
> Having problems with memory instability I changed
> unite_sfunc to always allocate memory for the sate array
> in higher memory context. Since I do not know about initcond
> lifetime interface is changed to having NULl state array as
> initial condition and ! strict state and final functions:
> 
> --8<------------------------------------------------------------------
> 
> DROP AGGREGATE fastunion(geometry);
> DROP FUNCTION unite_sfunc(geometry[], geometry);
> DROP FUNCTION unite_finalfunc(geometry[]);
> 
> CREATE FUNCTION unite_sfunc (geometry[],geometry)
>         RETURNS geometry[]
>         AS '/usr/src/postgis/postgis/libpostgis.so.0.8'
>         LANGUAGE 'C'; -- WITH (isstrict);
> 
> CREATE FUNCTION unite_finalfunc (geometry[])
>         RETURNS geometry
>         AS '/usr/src/postgis/postgis/libpostgis.so.0.8'
>         LANGUAGE 'C'; --  WITH (isstrict);
> 
> CREATE AGGREGATE fastunion (
>         -- initcond = '{}', -- needed for basetype != style && sfunc isstrict
>         sfunc = unite_sfunc,
>         basetype = geometry,
>         stype = geometry[],
>         finalfunc = unite_finalfunc
> );
> 
> --8<------------------------------------------------------------------
> 
> Please report any segfault...
> 
> PS: remember to cvs update 
> 
> --strk;
> 
> _______________________________________________
> geos-devel mailing list
> geos-devel at geos.refractions.net
> http://geos.refractions.net/mailman/listinfo/geos-devel



More information about the geos-devel mailing list