]> granicus.if.org Git - postgis/commitdiff
Implement ST_MemSize(raster)
authorSandro Santilli <strk@keybit.net>
Fri, 20 Jun 2014 10:37:22 +0000 (10:37 +0000)
committerSandro Santilli <strk@keybit.net>
Fri, 20 Jun 2014 10:37:22 +0000 (10:37 +0000)
Closes #2770
Includes testcases, but no documentation

git-svn-id: http://svn.osgeo.org/postgis/trunk@12630 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
raster/rt_pg/rtpg_utility.c
raster/rt_pg/rtpostgis.sql.in
raster/test/regress/rt_utility.sql
raster/test/regress/rt_utility_expected

diff --git a/NEWS b/NEWS
index 302a27428c77d9f57b3d958f1883b2fec9dd8e8f..15732178ae5492b743a87c2223e3f89f36cd8da5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,7 @@ PostGIS 2.2.0
 
  * New Features *
 
+  - #2770, ST_MemSize(raster)
   - Add postgis_noop(raster)
   - Added missing variants of ST_TPI(), ST_TRI() and ST_Roughness()
   - Added GUC postgis.gdal_enabled_drivers to specify GDAL config
index 7b3ae06b5a675580c2e7ed88fdca43f2ef5184cf..31e05a606ebdaa6045aeada0c8015a5b60ffe3c2 100644 (file)
@@ -133,3 +133,15 @@ Datum RASTER_minPossibleValue(PG_FUNCTION_ARGS)
        PG_RETURN_FLOAT8(pixsize);
 }
 
+/** find the detoasted size of a value */
+Datum RASTER_memsize(PG_FUNCTION_ARGS);
+PG_FUNCTION_INFO_V1(RASTER_memsize);
+Datum RASTER_memsize(PG_FUNCTION_ARGS)
+{
+  void *detoasted = PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+  size_t size = VARSIZE(detoasted);
+  PG_FREE_IF_COPY(detoasted,0);
+  PG_RETURN_INT32(size);
+}
+
+
index a0fa29f8fa74f8c515436308fc23f6a852adbac7..a805150df5570f42790aad504342411f63b3c7ff 100644 (file)
@@ -279,6 +279,12 @@ CREATE OR REPLACE FUNCTION st_summary(rast raster)
        END;
        $$ LANGUAGE 'plpgsql' STABLE STRICT;
 
+-- Availability: 2.2.0
+CREATE OR REPLACE FUNCTION ST_MemSize(raster)
+       RETURNS int4
+       AS 'MODULE_PATHNAME', 'RASTER_memsize'
+       LANGUAGE 'c' IMMUTABLE STRICT;
+
 -----------------------------------------------------------------------
 -- Constructor ST_MakeEmptyRaster
 -----------------------------------------------------------------------
index aa31b20c083b56657c1851f81e46d94bcc395f99..61b1a2dc82baf7d7fc6991a290292fd556f7e6b8 100644 (file)
@@ -433,3 +433,6 @@ SELECT
        ST_Summary(rast)
 FROM raster_outdb_template
 ORDER BY rid;
+
+SELECT 'ms1', ST_MemSize(ST_MakeEmptyRaster(10, 10, 0, 0, 1, -1, 0, 0, 0));
+SELECT 'ms2', ST_MemSize(rast) from raster_outdb_template order by rid;
index ec528479ba81e8c64d9a436748b09dc3735f417f..fc714cafd5d3d0af20de078111ad362f8239ea11 100644 (file)
@@ -51,3 +51,8 @@ Skewed raster of 10x10 pixels has 1 band and extent of BOX(0 -10,10 0.0001)
 4|Raster of 90x90 pixels has 2 bands and extent of BOX(0 -90,90 0)
     band 1 of pixtype 8BUI is out-db with NODATA value of 255
     band 2 of pixtype 8BUI is in-db with NODATA value of 0
+ms1|64
+ms2|280
+ms2|280
+ms2|8240
+ms2|8240