Changeset: cd8e36af839a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=cd8e36af839a
Added Files:
        geom/sql/Tests/functions/Tests/ST_Contains.sql
        geom/sql/Tests/functions/Tests/ST_Contains.stable.err
        geom/sql/Tests/functions/Tests/ST_Contains.stable.out
Removed Files:
        geom/sql/Tests/functions/Tests/contains.sql
        geom/sql/Tests/functions/Tests/contains.stable.err
        geom/sql/Tests/functions/Tests/contains.stable.out
Modified Files:
        geom/monetdb5/geom.c
        geom/monetdb5/geomBulk.c
Branch: geo
Log Message:

ST_Contains bulk + mtest + wrote in detail the version bat_geom because 
exchanging the arguments does not give the same results


diffs (truncated from 326 to 300 lines):

diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -3882,6 +3882,7 @@ static int wkbspatial(wkb **geomWKB_a, w
 
 str wkbContains(bit *out, wkb **geomWKB_a, wkb **geomWKB_b) {
        int res =  wkbspatial(geomWKB_a, geomWKB_b, GEOSContains);
+
        *out = bit_nil;
 
        if(res == 4)
diff --git a/geom/monetdb5/geomBulk.c b/geom/monetdb5/geomBulk.c
--- a/geom/monetdb5/geomBulk.c
+++ b/geom/monetdb5/geomBulk.c
@@ -569,7 +569,7 @@ str wkbContains_bat(int* outBAT_id, bat 
                wkb *aWKB = (wkb*) BUNtail(aBAT_iter, i + BUNfirst(aBAT));
                wkb *bWKB = (wkb*) BUNtail(bBAT_iter, i + BUNfirst(bBAT));
 
-               if ((err = wkbContains(&outBIT, &aWKB, &bWKB)) != MAL_SUCCEED) 
{ //check
+               if ((err = wkbContains(&outBIT, &aWKB, &bWKB)) != MAL_SUCCEED) {
                        BBPreleaseref(outBAT->batCacheid);      
 
                        ret = createException(MAL, "batgeom.Contains", "%s", 
err);
@@ -642,7 +642,52 @@ str wkbContains_geom_bat(int* outBAT_id,
 }
 
 str wkbContains_bat_geom(int* outBAT_id, int* inBAT_id, wkb** geomWKB) {
-       return wkbContains_geom_bat(outBAT_id, geomWKB, inBAT_id);
+       BAT *outBAT = NULL, *inBAT = NULL;
+       BATiter inBAT_iter;
+       BUN p=0, q=0;
+
+       //get the descriptor of the BAT
+       if ((inBAT = BATdescriptor(*inBAT_id)) == NULL) {
+               return createException(MAL, "batgeom.Contains", "Problem 
retrieving BAT");
+       }
+       
+       if ( !BAThdense(inBAT) ) {
+               BBPreleaseref(inBAT->batCacheid);
+               return createException(MAL, "batgeom.Contains", "The BAT must 
have dense head");
+       }
+
+       //create a new BAT for the output
+       if ((outBAT = BATnew(TYPE_void, ATOMindex("bit"), BATcount(inBAT), 
TRANSIENT)) == NULL) {
+               BBPreleaseref(inBAT->batCacheid);
+               return createException(MAL, "batgeom.Contains", "Error creating 
new BAT");
+       }
+       
+       //set the first idx of the output BAT equal to that of the aBAT
+       BATseqbase(outBAT, inBAT->hseqbase);
+
+       //iterator over the BATs        
+       inBAT_iter = bat_iterator(inBAT);
+       BATloop(inBAT, p, q) { 
+               str err = NULL;
+               bit outBIT;
+
+               wkb *inWKB = (wkb*) BUNtail(inBAT_iter, p);
+
+               if ((err = wkbContains(&outBIT, &inWKB, geomWKB)) != 
MAL_SUCCEED) {
+                       str msg;
+                       BBPreleaseref(inBAT->batCacheid);
+                       BBPreleaseref(outBAT->batCacheid);
+                       msg = createException(MAL, "batgeom.Contains", "%s", 
err);
+                       GDKfree(err);
+                       return msg;
+               }
+               BUNappend(outBAT,&outBIT,TRUE); //add the result to the outBAT
+       }
+
+       BBPreleaseref(inBAT->batCacheid);
+       BBPkeepref(*outBAT_id = outBAT->batCacheid);
+       
+       return MAL_SUCCEED;
 }
 
 
diff --git a/geom/sql/Tests/functions/Tests/ST_Contains.sql 
b/geom/sql/Tests/functions/Tests/ST_Contains.sql
new file mode 100644
--- /dev/null
+++ b/geom/sql/Tests/functions/Tests/ST_Contains.sql
@@ -0,0 +1,13 @@
+SELECT ST_Contains(smallc, bigc) As smallcontainsbig 
+FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc, 
ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
+
+SELECT ST_Contains(bigc,smallc) As bigcontainssmall 
+FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc, 
ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
+
+SELECT ST_Contains(bigc, ST_Union(smallc, bigc)) as bigcontainsunion 
+FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc, 
ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
+
+SELECT ST_Contains(bigc, ST_ExteriorRing(bigc)) As bigcontainsexterior 
+FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc, 
ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
+
+SELECT geom AS "GEOMETRY", ST_Contains(geom, 'POINT (15 15)') AS "CONTAINS" 
FROM geometries;
diff --git a/geom/sql/Tests/functions/Tests/ST_Contains.stable.err 
b/geom/sql/Tests/functions/Tests/ST_Contains.stable.err
new file mode 100644
--- /dev/null
+++ b/geom/sql/Tests/functions/Tests/ST_Contains.stable.err
@@ -0,0 +1,36 @@
+stderr of test 'ST_Contains` in directory 'geom/sql/Tests/functions` itself:
+
+
+# 17:07:03 >  
+# 17:07:03 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=31811" "--set" 
"mapi_usock=/var/tmp/mtest-21284/.s.monetdb.31811" "--set" "monet_prompt=" 
"--forcemito" "--set" "mal_listing=2" 
"--dbpath=/export/scratch1/alvanaki/INSTALL/MonetDB-public/var/MonetDB/mTests_geom_sql_Tests_functions"
 "--set" "mal_listing=0"
+# 17:07:03 >  
+
+# builtin opt  gdk_dbpath = 
/export/scratch1/alvanaki/INSTALL/MonetDB-public/var/monetdb5/dbfarm/demo
+# builtin opt  gdk_debug = 0
+# builtin opt  gdk_vmtrim = no
+# builtin opt  monet_prompt = >
+# builtin opt  monet_daemon = no
+# builtin opt  mapi_port = 50000
+# builtin opt  mapi_open = false
+# builtin opt  mapi_autosense = false
+# builtin opt  sql_optimizer = default_pipe
+# builtin opt  sql_debug = 0
+# cmdline opt  gdk_nr_threads = 0
+# cmdline opt  mapi_open = true
+# cmdline opt  mapi_port = 31811
+# cmdline opt  mapi_usock = /var/tmp/mtest-21284/.s.monetdb.31811
+# cmdline opt  monet_prompt = 
+# cmdline opt  mal_listing = 2
+# cmdline opt  gdk_dbpath = 
/export/scratch1/alvanaki/INSTALL/MonetDB-public/var/MonetDB/mTests_geom_sql_Tests_functions
+# cmdline opt  mal_listing = 0
+# cmdline opt  gdk_debug = 536870922
+
+# 17:07:03 >  
+# 17:07:03 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-21284" "--port=31811"
+# 17:07:03 >  
+
+
+# 17:07:03 >  
+# 17:07:03 >  "Done."
+# 17:07:03 >  
+
diff --git a/geom/sql/Tests/functions/Tests/ST_Contains.stable.out 
b/geom/sql/Tests/functions/Tests/ST_Contains.stable.out
new file mode 100644
--- /dev/null
+++ b/geom/sql/Tests/functions/Tests/ST_Contains.stable.out
@@ -0,0 +1,71 @@
+stdout of test 'ST_Contains` in directory 'geom/sql/Tests/functions` itself:
+
+
+# 17:07:03 >  
+# 17:07:03 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=31811" "--set" 
"mapi_usock=/var/tmp/mtest-21284/.s.monetdb.31811" "--set" "monet_prompt=" 
"--forcemito" "--set" "mal_listing=2" 
"--dbpath=/export/scratch1/alvanaki/INSTALL/MonetDB-public/var/MonetDB/mTests_geom_sql_Tests_functions"
 "--set" "mal_listing=0"
+# 17:07:03 >  
+
+# MonetDB 5 server v11.20.0
+# This is an unreleased version
+# Serving database 'mTests_geom_sql_Tests_functions', using 8 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs and 128bit 
integers dynamically linked
+# Found 15.356 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2014 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://sibuyan.da.cwi.nl:31811/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-21284/.s.monetdb.31811
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 17:07:03 >  
+# 17:07:03 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-21284" "--port=31811"
+# 17:07:03 >  
+
+#SELECT ST_Contains(smallc, bigc) As smallcontainsbig 
+#FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc, 
ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
+% .L # table_name
+% smallcontainsbig # name
+% boolean # type
+% 5 # length
+[ false        ]
+#SELECT ST_Contains(bigc,smallc) As bigcontainssmall 
+#FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc, 
ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
+% .L # table_name
+% bigcontainssmall # name
+% boolean # type
+% 5 # length
+[ true ]
+#SELECT ST_Contains(bigc, ST_Union(smallc, bigc)) as bigcontainsunion 
+#FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc, 
ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
+% .L # table_name
+% bigcontainsunion # name
+% boolean # type
+% 5 # length
+[ true ]
+#SELECT ST_Contains(bigc, ST_ExteriorRing(bigc)) As bigcontainsexterior 
+#FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc, 
ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
+% .L # table_name
+% bigcontainsexterior # name
+% boolean # type
+% 5 # length
+[ false        ]
+#SELECT geom AS "GEOMETRY", ST_Contains(geom, 'POINT (15 15)') AS "CONTAINS" 
FROM geometries;
+% sys.L,       sys.L # table_name
+% GEOMETRY,    CONTAINS # name
+% geometry,    boolean # type
+% 0,   5 # length
+[ "POINT (10 20)",     false   ]
+[ "LINESTRING (10 20, 30 40, 50 60)",  false   ]
+[ "POLYGON ((10 10, 10 20, 20 20, 20 10, 10 10))",     true    ]
+[ "MULTIPOINT (10 20, 30 40)", false   ]
+[ "MULTILINESTRING ((10 20, 30 40), (40 50, 60 70))",  false   ]
+[ "MULTIPOLYGON (((10 10, 10 20, 20 20, 20 10, 10 10), (30 30, 30 40, 40 40, 
40 30, 30 30)))", true    ]
+[ "GEOMETRYCOLLECTION (POINT (10 20), LINESTRING (10 20, 30 40), POLYGON ((10 
10, 10 20, 20 20, 20 10, 10 10)))",      true    ]
+
+# 17:07:03 >  
+# 17:07:03 >  "Done."
+# 17:07:03 >  
+
diff --git a/geom/sql/Tests/functions/Tests/contains.sql 
b/geom/sql/Tests/functions/Tests/contains.sql
deleted file mode 100644
--- a/geom/sql/Tests/functions/Tests/contains.sql
+++ /dev/null
@@ -1,8 +0,0 @@
-SELECT ST_Contains(smallc, bigc) As smallcontainsbig FROM (SELECT 
ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc, 
ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
-
-SELECT ST_Contains(bigc,smallc) As bigcontainssmall FROM (SELECT 
ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc, 
ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
-
-SELECT ST_Contains(bigc, ST_Union(smallc, bigc)) as bigcontainsunion FROM 
(SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc, 
ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
-
-SELECT ST_Contains(bigc, ST_ExteriorRing(bigc)) As bigcontainsexterior FROM 
(SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc, 
ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
-
diff --git a/geom/sql/Tests/functions/Tests/contains.stable.err 
b/geom/sql/Tests/functions/Tests/contains.stable.err
deleted file mode 100644
--- a/geom/sql/Tests/functions/Tests/contains.stable.err
+++ /dev/null
@@ -1,36 +0,0 @@
-stderr of test 'contains` in directory 'geom/sql/Tests/functions` itself:
-
-
-# 10:52:12 >  
-# 10:52:12 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=39851" "--set" 
"mapi_usock=/var/tmp/mtest-4010/.s.monetdb.39851" "--set" "monet_prompt=" 
"--forcemito" "--set" "mal_listing=2" 
"--dbpath=/export/scratch1/alvanaki/INSTALL/MonetDB-public/var/MonetDB/mTests_geom_sql_Tests_functions"
 "--set" "mal_listing=0"
-# 10:52:12 >  
-
-# builtin opt  gdk_dbpath = 
/export/scratch1/alvanaki/INSTALL/MonetDB-public/var/monetdb5/dbfarm/demo
-# builtin opt  gdk_debug = 0
-# builtin opt  gdk_vmtrim = no
-# builtin opt  monet_prompt = >
-# builtin opt  monet_daemon = no
-# builtin opt  mapi_port = 50000
-# builtin opt  mapi_open = false
-# builtin opt  mapi_autosense = false
-# builtin opt  sql_optimizer = default_pipe
-# builtin opt  sql_debug = 0
-# cmdline opt  gdk_nr_threads = 0
-# cmdline opt  mapi_open = true
-# cmdline opt  mapi_port = 39851
-# cmdline opt  mapi_usock = /var/tmp/mtest-4010/.s.monetdb.39851
-# cmdline opt  monet_prompt = 
-# cmdline opt  mal_listing = 2
-# cmdline opt  gdk_dbpath = 
/export/scratch1/alvanaki/INSTALL/MonetDB-public/var/MonetDB/mTests_geom_sql_Tests_functions
-# cmdline opt  mal_listing = 0
-# cmdline opt  gdk_debug = 536870922
-
-# 10:52:12 >  
-# 10:52:12 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-4010" "--port=39851"
-# 10:52:12 >  
-
-
-# 10:52:12 >  
-# 10:52:12 >  "Done."
-# 10:52:12 >  
-
diff --git a/geom/sql/Tests/functions/Tests/contains.stable.out 
b/geom/sql/Tests/functions/Tests/contains.stable.out
deleted file mode 100644
--- a/geom/sql/Tests/functions/Tests/contains.stable.out
+++ /dev/null
@@ -1,55 +0,0 @@
-stdout of test 'contains` in directory 'geom/sql/Tests/functions` itself:
-
-
-# 10:52:12 >  
-# 10:52:12 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=39851" "--set" 
"mapi_usock=/var/tmp/mtest-4010/.s.monetdb.39851" "--set" "monet_prompt=" 
"--forcemito" "--set" "mal_listing=2" 
"--dbpath=/export/scratch1/alvanaki/INSTALL/MonetDB-public/var/MonetDB/mTests_geom_sql_Tests_functions"
 "--set" "mal_listing=0"
-# 10:52:12 >  
-
-# MonetDB 5 server v11.20.0
-# This is an unreleased version
-# Serving database 'mTests_geom_sql_Tests_functions', using 8 threads
-# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs and 128bit 
integers dynamically linked
-# Found 15.356 GiB available main-memory.
-# Copyright (c) 1993-July 2008 CWI.
-# Copyright (c) August 2008-2014 MonetDB B.V., all rights reserved
-# Visit http://www.monetdb.org/ for further information
-# Listening for connection requests on mapi:monetdb://sibuyan.da.cwi.nl:39851/
-# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-4010/.s.monetdb.39851
-# MonetDB/GIS module loaded
-# MonetDB/SQL module loaded
-
-Ready.
-
-# 10:52:12 >  
-# 10:52:12 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-4010" "--port=39851"
-# 10:52:12 >  
-
-#SELECT ST_Contains(smallc, bigc) As smallcontainsbig FROM (SELECT 
ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc, 
ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
-% .L # table_name
-% smallcontainsbig # name
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to