MonetDB: Oct2014 - dump & testdb-dump: propagated changeset 882e...

2014-08-26 Thread Stefan Manegold
Changeset: c8fe5fc5e484 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c8fe5fc5e484
Modified Files:
sql/test/Dump/Tests/dump.stable.out.Windows
sql/test/testdb/Tests/testdb-dump.stable.out.Windows
Branch: Oct2014
Log Message:

dump & testdb-dump: propagated changeset 882e12ddac9d to Windows output


diffs (42 lines):

diff --git a/sql/test/Dump/Tests/dump.stable.out.Windows 
b/sql/test/Dump/Tests/dump.stable.out.Windows
--- a/sql/test/Dump/Tests/dump.stable.out.Windows
+++ b/sql/test/Dump/Tests/dump.stable.out.Windows
@@ -46,7 +46,7 @@ CREATE TABLE "sys"."typestest" (
"bigint" BIGINT,
"double" DOUBLE,
"real"   REAL,
-   "decimal"DECIMAL,
+   "decimal"DECIMAL(18,3),
"decimal9"   DECIMAL(9),
"decimal83"  DECIMAL(8,3),
"float"  DOUBLE,
@@ -83,7 +83,7 @@ CREATE TABLE "sys"."typestest" (
"character10"CHAR(10)
 );
 COPY 1 RECORDS INTO "sys"."typestest" FROM stdin USING DELIMITERS 
'\t','\n','"';
-true   10  1   100 100 100 1e+030  1.0002e+020 
1   123456789   12345.678   3.14150002  3.1415  3.1415  
2009-04-15  24  18  3   1728000.000 108000.000  
12.000  10.000  36000.000   6000.0002000.000
600.000 100.000 10.000  1995-07-15 07:30:00.00  1995-07-15 
07:30:00.0   1995-07-15 07:30:00.00+00:001995-07-15 
07:30:00.0+00:00 07:30:0007:30:00.0  07:30:00+00:00  
07:30:00.0+00:00123456  123456  "123456""123456""x" 
"varchar"   "0123456789"
+true   10  1   100 100 100 1e+030  1.0002e+020 
1.000   123456789   12345.678   3.14150002  3.1415  3.1415  
2009-04-15  24  18  3   1728000.000 108000.000  
12.000  10.000  36000.000   6000.0002000.000
600.000 100.000 10.000  1995-07-15 07:30:00.00  1995-07-15 
07:30:00.0   1995-07-15 07:30:00.00+00:001995-07-15 
07:30:00.0+00:00 07:30:0007:30:00.0  07:30:00+00:00  
07:30:00.0+00:00123456  123456  "123456""123456""x" 
"varchar"   "0123456789"
 CREATE TABLE "sys"."keytest1" (
"key1" INTEGER   NOT NULL,
"key2" INTEGER   NOT NULL,
diff --git a/sql/test/testdb/Tests/testdb-dump.stable.out.Windows 
b/sql/test/testdb/Tests/testdb-dump.stable.out.Windows
--- a/sql/test/testdb/Tests/testdb-dump.stable.out.Windows
+++ b/sql/test/testdb/Tests/testdb-dump.stable.out.Windows
@@ -101135,7 +101135,7 @@ CREATE TABLE "testschema"."typestest" (
"bigint" BIGINT,
"double" DOUBLE,
"real"   REAL,
-   "decimal"DECIMAL,
+   "decimal"DECIMAL(18,3),
"decimal9"   DECIMAL(9),
"decimal83"  DECIMAL(8,3),
"float"  DOUBLE,
@@ -101173,7 +101173,7 @@ CREATE TABLE "testschema"."typestest" (
"uuid"   UUID
 );
 COPY 2 RECORDS INTO "testschema"."typestest" FROM stdin USING DELIMITERS 
'\t','\n','"';
-true   10  1   100 100 100 1e+030  1.0002e+020 
1   123456789   12345.678   3.14150002  3.1415  3.1415  
2009-04-15  24  18  3   1728000.000 108000.000  
12.000  10.000  36000.000   6000.0002000.000
600.000 100.000 10.000  1995-07-15 07:30:00.00  1995-07-15 
07:30:00.0   1995-07-15 07:30:00.00+00:001995-07-15 
07:30:00.0+00:00 07:30:0007:30:00.0  07:30:00+00:00  
07:30:00.0+00:00123456  123456  "123456""123456""x" 
"varchar"   "0123456789"7d95a9ce-aeb8-4881-9cf7-60b4d55f9e45
+true   10  1   100 100 100 1e+030  1.0002e+020 
1.000   123456789   12345.678   3.14150002  3.1415  3.1415  
2009-04-15  24  18  3   1728000.000 108000.000  
12.000  10.000  36000.000   6000.0002000.000
600.000 100.000 10.000  1995-07-15 07:30:00.00  1995-07-15 
07:30:00.0   1995-07-15 07:30:00.00+00:001995-07-15 
07:30:00.0+00:00 07:30:0007:30:00.0  07:30:00+00:00  
07:30:00.0+00:00123456  123456  "123456""123456""x" 
"varchar"   "0123456789"7d95a9ce-aeb8-4881-9cf7-60b4d55f9e45
 NULL   NULLNULLNULLNULLNULLNULLNULLNULLNULL
NULLNULLNULLNULLNULLNULLNULLNULLNULLNULL
NULLNULLNULLNULLNULLNULLNULLNULLNULLNULL
NULLNULLNULLNULLNULLNULLNULLNULLNULLNULL
NULLNULLNULLNULL
 CREATE TABLE "testschema"."keytest1" (
"key1" INTEGER   

MonetDB: Oct2014 - Cleanup of pcre module.

2014-08-26 Thread Sjoerd Mullender
Changeset: 4a7dd9f5f847 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4a7dd9f5f847
Modified Files:
clients/Tests/MAL-signatures_all.stable.out
clients/Tests/MAL-signatures_fits_geom.stable.out
clients/Tests/MAL-signatures_geom.stable.out
clients/Tests/MAL-signatures_none.stable.out
clients/Tests/exports.stable.out
monetdb5/modules/mal/pcre.c
monetdb5/modules/mal/pcre.mal
Branch: Oct2014
Log Message:

Cleanup of pcre module.
pcre.{i,}likesubselect is not generated, so can be removed.
algebra.{i,}likesubselect is used, so the implementation cannot be
removed.
Internally, these functions use a form of uselect, so the select
variant was removed.


diffs (truncated from 394 to 300 lines):

diff --git a/clients/Tests/MAL-signatures_all.stable.out 
b/clients/Tests/MAL-signatures_all.stable.out
--- a/clients/Tests/MAL-signatures_all.stable.out
+++ b/clients/Tests/MAL-signatures_all.stable.out
@@ -40993,14 +40993,10 @@ command pcre.imatch(s:str,pat:str):bit
 address PCREimatch;
 comment Caseless Perl Compatible Regular Expression pattern matching against a 
string
 
-command pcre.ilikesubselect(s:bat[:oid,:str],pat:bat[:oid,:str],esc:str) 
(l:bat[:oid,:oid],r:bat[:oid,:oid]) 
-address PCREilike_join_pcre;
 command pcre.index(pat:pcre,s:str):int 
 address PCREindex;
 comment match a pattern, return matched position (or 0 when not found)
 
-command pcre.likesubselect(s:bat[:oid,:str],pat:bat[:oid,:str],esc:str) 
(l:bat[:oid,:oid],r:bat[:oid,:oid]) 
-address PCRElike_join_pcre;
 command pcre.match(s:str,pat:str):bit 
 address PCREmatch;
 comment Perl Compatible Regular Expression pattern matching against a string
@@ -41027,10 +41023,6 @@ command pcre.sql2pcre(pat:str,esc:str):s
 address PCREsql2pcre;
 comment Convert a SQL like pattern with the given escape character into a PCRE 
pattern.
 
-command pcre.select(pat:str,strs:bat[:oid,:str]):bat[:oid,:str] 
-address PCREselectDef;
-comment Select tuples based on the pattern
-
 pattern profiler.activate(name:str...):void 
 address CMDactivateProfiler;
 comment A list of counters to be activated.
diff --git a/clients/Tests/MAL-signatures_fits_geom.stable.out 
b/clients/Tests/MAL-signatures_fits_geom.stable.out
--- a/clients/Tests/MAL-signatures_fits_geom.stable.out
+++ b/clients/Tests/MAL-signatures_fits_geom.stable.out
@@ -40910,14 +40910,10 @@ command pcre.imatch(s:str,pat:str):bit
 address PCREimatch;
 comment Caseless Perl Compatible Regular Expression pattern matching against a 
string
 
-command pcre.ilikesubselect(s:bat[:oid,:str],pat:bat[:oid,:str],esc:str) 
(l:bat[:oid,:oid],r:bat[:oid,:oid]) 
-address PCREilike_join_pcre;
 command pcre.index(pat:pcre,s:str):int 
 address PCREindex;
 comment match a pattern, return matched position (or 0 when not found)
 
-command pcre.likesubselect(s:bat[:oid,:str],pat:bat[:oid,:str],esc:str) 
(l:bat[:oid,:oid],r:bat[:oid,:oid]) 
-address PCRElike_join_pcre;
 command pcre.match(s:str,pat:str):bit 
 address PCREmatch;
 comment Perl Compatible Regular Expression pattern matching against a string
@@ -40944,10 +40940,6 @@ command pcre.sql2pcre(pat:str,esc:str):s
 address PCREsql2pcre;
 comment Convert a SQL like pattern with the given escape character into a PCRE 
pattern.
 
-command pcre.select(pat:str,strs:bat[:oid,:str]):bat[:oid,:str] 
-address PCREselectDef;
-comment Select tuples based on the pattern
-
 pattern profiler.activate(name:str...):void 
 address CMDactivateProfiler;
 comment A list of counters to be activated.
diff --git a/clients/Tests/MAL-signatures_geom.stable.out 
b/clients/Tests/MAL-signatures_geom.stable.out
--- a/clients/Tests/MAL-signatures_geom.stable.out
+++ b/clients/Tests/MAL-signatures_geom.stable.out
@@ -40886,14 +40886,10 @@ command pcre.imatch(s:str,pat:str):bit
 address PCREimatch;
 comment Caseless Perl Compatible Regular Expression pattern matching against a 
string
 
-command pcre.ilikesubselect(s:bat[:oid,:str],pat:bat[:oid,:str],esc:str) 
(l:bat[:oid,:oid],r:bat[:oid,:oid]) 
-address PCREilike_join_pcre;
 command pcre.index(pat:pcre,s:str):int 
 address PCREindex;
 comment match a pattern, return matched position (or 0 when not found)
 
-command pcre.likesubselect(s:bat[:oid,:str],pat:bat[:oid,:str],esc:str) 
(l:bat[:oid,:oid],r:bat[:oid,:oid]) 
-address PCRElike_join_pcre;
 command pcre.match(s:str,pat:str):bit 
 address PCREmatch;
 comment Perl Compatible Regular Expression pattern matching against a string
@@ -40920,10 +40916,6 @@ command pcre.sql2pcre(pat:str,esc:str):s
 address PCREsql2pcre;
 comment Convert a SQL like pattern with the given escape character into a PCRE 
pattern.
 
-command pcre.select(pat:str,strs:bat[:oid,:str]):bat[:oid,:str] 
-address PCREselectDef;
-comment Select tuples based on the pattern
-
 pattern profiler.activate(name:str...):void 
 address CMDactivateProfiler;
 comment A list of counters to be activated.
diff --git a/clients/Tests/MAL-signatures_none.stable.out 
b/clients/Tests/MAL

MonetDB: Oct2014 - Typo.

2014-08-26 Thread Sjoerd Mullender
Changeset: 7dbe2487b544 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7dbe2487b544
Modified Files:
clients/Tests/MAL-signatures_all.stable.out
clients/Tests/MAL-signatures_fits_geom.stable.out
clients/Tests/MAL-signatures_geom.stable.out
clients/Tests/MAL-signatures_none.stable.out
monetdb5/modules/mal/pcre.mal
Branch: Oct2014
Log Message:

Typo.


diffs (59 lines):

diff --git a/clients/Tests/MAL-signatures_all.stable.out 
b/clients/Tests/MAL-signatures_all.stable.out
--- a/clients/Tests/MAL-signatures_all.stable.out
+++ b/clients/Tests/MAL-signatures_all.stable.out
@@ -2459,7 +2459,7 @@ address ALGgroupby;
 comment Produces a new BAT with groups identified by the head column. The 
result contains tail times the head value, ie the tail contains the result 
group sizes.
 
 command algebra.ilikesubselect(s:bat[:oid,:str],pat:bat[:oid,:str],esc:str) 
(l:bat[:oid,:oid],r:bat[:oid,:oid]) 
-address PCREilike_join_pcr5;
+address PCREilike_join_pcre;
 function 
algebra.ilikesubselect(b:bat[:oid,:str],cand:bat[:oid,:oid],pat:str,esc:str,anti:bit):bat[:oid,:oid];
 function 
algebra.ilikesubselect(b:bat[:oid,:str],pat:str,esc:str,anti:bit):bat[:oid,:oid];
 command 
algebra.indexjoin(left:bat[:any_1,:any_2],right:bat[:any_2,:any_3]):bat[:any_1,:any_3]
 
diff --git a/clients/Tests/MAL-signatures_fits_geom.stable.out 
b/clients/Tests/MAL-signatures_fits_geom.stable.out
--- a/clients/Tests/MAL-signatures_fits_geom.stable.out
+++ b/clients/Tests/MAL-signatures_fits_geom.stable.out
@@ -2460,7 +2460,7 @@ address ALGgroupby;
 comment Produces a new BAT with groups identified by the head column. The 
result contains tail times the head value, ie the tail contains the result 
group sizes.
 
 command algebra.ilikesubselect(s:bat[:oid,:str],pat:bat[:oid,:str],esc:str) 
(l:bat[:oid,:oid],r:bat[:oid,:oid]) 
-address PCREilike_join_pcr5;
+address PCREilike_join_pcre;
 function 
algebra.ilikesubselect(b:bat[:oid,:str],cand:bat[:oid,:oid],pat:str,esc:str,anti:bit):bat[:oid,:oid];
 function 
algebra.ilikesubselect(b:bat[:oid,:str],pat:str,esc:str,anti:bit):bat[:oid,:oid];
 command 
algebra.indexjoin(left:bat[:any_1,:any_2],right:bat[:any_2,:any_3]):bat[:any_1,:any_3]
 
diff --git a/clients/Tests/MAL-signatures_geom.stable.out 
b/clients/Tests/MAL-signatures_geom.stable.out
--- a/clients/Tests/MAL-signatures_geom.stable.out
+++ b/clients/Tests/MAL-signatures_geom.stable.out
@@ -2460,7 +2460,7 @@ address ALGgroupby;
 comment Produces a new BAT with groups identified by the head column. The 
result contains tail times the head value, ie the tail contains the result 
group sizes.
 
 command algebra.ilikesubselect(s:bat[:oid,:str],pat:bat[:oid,:str],esc:str) 
(l:bat[:oid,:oid],r:bat[:oid,:oid]) 
-address PCREilike_join_pcr5;
+address PCREilike_join_pcre;
 function 
algebra.ilikesubselect(b:bat[:oid,:str],cand:bat[:oid,:oid],pat:str,esc:str,anti:bit):bat[:oid,:oid];
 function 
algebra.ilikesubselect(b:bat[:oid,:str],pat:str,esc:str,anti:bit):bat[:oid,:oid];
 command 
algebra.indexjoin(left:bat[:any_1,:any_2],right:bat[:any_2,:any_3]):bat[:any_1,:any_3]
 
diff --git a/clients/Tests/MAL-signatures_none.stable.out 
b/clients/Tests/MAL-signatures_none.stable.out
--- a/clients/Tests/MAL-signatures_none.stable.out
+++ b/clients/Tests/MAL-signatures_none.stable.out
@@ -2459,7 +2459,7 @@ address ALGgroupby;
 comment Produces a new BAT with groups identified by the head column. The 
result contains tail times the head value, ie the tail contains the result 
group sizes.
 
 command algebra.ilikesubselect(s:bat[:oid,:str],pat:bat[:oid,:str],esc:str) 
(l:bat[:oid,:oid],r:bat[:oid,:oid]) 
-address PCREilike_join_pcr5;
+address PCREilike_join_pcre;
 function 
algebra.ilikesubselect(b:bat[:oid,:str],cand:bat[:oid,:oid],pat:str,esc:str,anti:bit):bat[:oid,:oid];
 function 
algebra.ilikesubselect(b:bat[:oid,:str],pat:str,esc:str,anti:bit):bat[:oid,:oid];
 command 
algebra.indexjoin(left:bat[:any_1,:any_2],right:bat[:any_2,:any_3]):bat[:any_1,:any_3]
 
diff --git a/monetdb5/modules/mal/pcre.mal b/monetdb5/modules/mal/pcre.mal
--- a/monetdb5/modules/mal/pcre.mal
+++ b/monetdb5/modules/mal/pcre.mal
@@ -173,5 +173,5 @@ end ilikesubselect;
 command likesubselect(s:bat[:oid,:str], pat:bat[:oid,:str], esc:str) 
(l:bat[:oid,:oid],r:bat[:oid,:oid])
 address PCRElike_join_pcre;
 
-command ilikesubselect(s:bat[:oid,:str], pat:bat[:oid,:str], esc:str) 
(l:bat[:oid,:oid],r:bat[:oid,:oid])
-address PCREilike_join_pcr5;
+command algebra.ilikesubselect(s:bat[:oid,:str], pat:bat[:oid,:str], esc:str) 
(l:bat[:oid,:oid],r:bat[:oid,:oid])
+address PCREilike_join_pcre;
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Oct2014 - Cleanup: removed algebra.{anti,theta}uselect,...

2014-08-26 Thread Sjoerd Mullender
Changeset: 02c167e4ff80 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=02c167e4ff80
Modified Files:
clients/Tests/MAL-signatures_all.stable.out
clients/Tests/MAL-signatures_fits_geom.stable.out
clients/Tests/MAL-signatures_geom.stable.out
clients/Tests/MAL-signatures_none.stable.out
clients/Tests/exports.stable.out
gdk/gdk.h
gdk/gdk_select_legacy.c
monetdb5/ChangeLog.Oct2014
monetdb5/modules/kernel/algebra.c
monetdb5/modules/kernel/algebra.h
monetdb5/modules/kernel/algebra.mal
monetdb5/optimizer/opt_centipede.c
monetdb5/optimizer/opt_costModel.c
monetdb5/optimizer/opt_emptySet.c
monetdb5/optimizer/opt_prelude.c
monetdb5/optimizer/opt_prelude.h
monetdb5/optimizer/opt_pushranges.c
monetdb5/optimizer/opt_support.c
Branch: Oct2014
Log Message:

Cleanup: removed algebra.{anti,theta}uselect, and the {,u}selectRef variables.
None of the algebra.*select functions apart from algebra.*subselect is
generated by the SQL frontend, so their implementations can be
removed.  The implementations of algebra.select and algebra.uselect
are left since they are still used internally and by MAL tests.  The
pushrange optimizer now works on subselect without candidate list, so
the optimizer tests that try it on algebra.select fail.


diffs (truncated from 710 to 300 lines):

diff --git a/clients/Tests/MAL-signatures_all.stable.out 
b/clients/Tests/MAL-signatures_all.stable.out
--- a/clients/Tests/MAL-signatures_all.stable.out
+++ b/clients/Tests/MAL-signatures_all.stable.out
@@ -2382,14 +2382,6 @@ command algebra.antijoin(left:bat[:oid,:
 address ALGantijoin2;
 comment Returns 2 columns with all BUNs, consisting of the head-oids from 
'left' and 'right' for which there are BUNs in 'left'  and 'right' with 
equal tails
 
-command 
algebra.antiuselect(b:bat[:any_1,:any_2],low:any_2,high:any_2,li:bit,hi:bit):bat[:any_1,:void]
 
-address ALGantiuselectInclusive;
-comment See select() but limited to head values
-
-command 
algebra.antiuselect(b:bat[:any_1,:any_2],value:any_2):bat[:any_1,:void] 
-address ALGantiuselect1;
-comment Value select, but returning only the   head values. SEE 
ALSO:select(bat,val)
-
 command 
algebra.bandjoin(outer:bat[:any_1,:any_2],inner:bat[:any_2,:any_3],minus:any_2,plus:any_2,li:bit,hi:bit):bat[:any_1,:any_3]
 
 address ALGbandjoin;
 comment This is a join() for which the predicate is that two BUNs match
if the left-tail value is within the range [right-head - minus, 
right-head + plus], depending on (l_in/h_in), the boundsare 
included. Works only for the builtin numerical types,   and their 
derivates.
@@ -2783,10 +2775,6 @@ command algebra.tunique(b:bat[:any_1,:an
 address ALGtunique;
 comment Select unique tuples from the input BAT. Double elimination is 
done over the BUNs tail. The result is a BAT with property  
tkeyd()== true
 
-command 
algebra.thetauselect(b:bat[:any_1,:any_2],val:any_2,op:str):bat[:any_1,:void] 
-address ALGthetauselect;
-comment The theta (<=,<,=,>,>=) select() limited to head values
-
 command 
algebra.thetasubselect(b:bat[:oid,:any_1],s:bat[:oid,:oid],val:any_1,op:str):bat[:oid,:oid]
 
 address ALGthetasubselect2;
 comment Select all head values of the first input BAT for which the tail value 
obeys the relation value OP VAL and for which the head value occurs in  the 
tail of the second input BAT.   Input is a dense-headed BAT, output is a 
dense-headed BAT with in   the tail the head value of the input BAT for 
which the  relationship holds.  The output BAT is sorted on the tail value.
diff --git a/clients/Tests/MAL-signatures_fits_geom.stable.out 
b/clients/Tests/MAL-signatures_fits_geom.stable.out
--- a/clients/Tests/MAL-signatures_fits_geom.stable.out
+++ b/clients/Tests/MAL-signatures_fits_geom.stable.out
@@ -2383,14 +2383,6 @@ command algebra.antijoin(left:bat[:oid,:
 address ALGantijoin2;
 comment Returns 2 columns with all BUNs, consisting of the head-oids from 
'left' and 'right' for which there are BUNs in 'left'  and 'right' with 
equal tails
 
-command 
algebra.antiuselect(b:bat[:any_1,:any_2],low:any_2,high:any_2,li:bit,hi:bit):bat[:any_1,:void]
 
-address ALGantiuselectInclusive;
-comment See select() but limited to head values
-
-command 
algebra.antiuselect(b:bat[:any_1,:any_2],value:any_2):bat[:any_1,:void] 
-address ALGantiuselect1;
-comment Value select, but returning only the   head values. SEE 
ALSO:select(bat,val)
-
 command 
algebra.bandjoin(outer:bat[:any_1,:any_2],inner:bat[:any_2,:any_3],minus:any_2,plus:any_2,li:bit,hi:bit):bat[:any_1,:any_3]
 
 address ALGbandjoin;
 comment This is a join() for which the predicate is that two BUNs match
if the left-tail value is within the range [right-head - minus, 
right-head + plus], depending on (l_in/h_in), the bounds  

MonetDB: geo - BdPolyFromText + small changes here and there

2014-08-26 Thread Foteini Alvanaki
Changeset: 17e0c58c6652 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=17e0c58c6652
Modified Files:
geom/monetdb5/geom.c
geom/monetdb5/geom.mal
geom/sql/40_geom.sql
Branch: geo
Log Message:

BdPolyFromText + small changes here and there


diffs (truncated from 355 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
@@ -130,6 +130,8 @@ geom_export mbr* mbrFromGeos(const GEOSG
 
 
 geom_export str wkbFromText(wkb **geomWKB, str *geomWKT, int* srid, int *tpe);
+geom_export str wkbMLineStringToPolygon(wkb** geomWKB, str* geomWKT, int* 
srid, int* flag);
+
 
 /* Basic Methods on Geometric objects (OGC) */
 geom_export str wkbDimension(int*, wkb**);
@@ -1114,7 +1116,7 @@ str wkbFromText(wkb **geomWKB, str *geom
*geomWKB = wkb_nil;
}
if (*tpe > 0 && te != *tpe)
-   throw(MAL, "wkb.FromText", "Trying to read Geometry type '%s' 
with function for Geometry type '%s'", geom_type2str(te,0), 
geom_type2str(*tpe,0));
+   throw(MAL, "wkb.FromText", "Geometry not type '%s'", 
geom_type2str(*tpe,0));
errbuf = GDKerrbuf;
if (errbuf) {
if (strncmp(errbuf, "!ERROR: ", 8) == 0)
@@ -1187,6 +1189,169 @@ str wkbAsText(char **txt, wkb **geomWKB,
throw(MAL, "geom.AsText", "Failed to create Text from Well Known 
Format");
 }
 
+str wkbMLineStringToPolygon(wkb** geomWKB, str* geomWKT, int* srid, int* flag) 
{
+   int itemsNum =0, i, type=wkbMultiLineString;
+   str ret = MAL_SUCCEED;
+   wkb* inputWKB = NULL;   
+
+   wkb **linestringsWKB;
+   double *linestringsArea;
+
+   bit ordered = 0;
+
+   //make wkb from wkt
+   ret = wkbFromText(&inputWKB, geomWKT, srid, &type);
+   if(ret != MAL_SUCCEED) {
+   *geomWKB = wkb_nil;
+
+   if(inputWKB)
+   GDKfree(inputWKB);
+   return ret;
+   }
+   
+   //read the number of linestrings in the input
+   ret = wkbNumGeometries(&itemsNum, &inputWKB);
+   if(ret != MAL_SUCCEED) {
+   *geomWKB = wkb_nil;
+   return ret;
+   }
+
+   linestringsWKB = (wkb**)GDKmalloc(itemsNum*sizeof(wkb*));
+   linestringsArea = (double*)GDKmalloc(itemsNum*sizeof(double));
+   //create oen polygon for each lineString and compute the are of each of 
them
+   for(i=1; i<=itemsNum; i++) { 
+   wkb* polygonWKB;
+   int batId=0;
+
+   ret = wkbGeometryN(&linestringsWKB[i-1], &inputWKB, &i);
+   if(ret != MAL_SUCCEED || !linestringsWKB[i-1]) {
+   *geomWKB = wkb_nil;
+
+   GDKfree(inputWKB);
+   for(;i>0; i--)
+   if(linestringsWKB[i-1])
+   GDKfree(linestringsWKB[i-1]);
+   GDKfree(linestringsWKB);
+   
+   return ret;
+   }
+
+   ret = wkbMakePolygon(&polygonWKB, &linestringsWKB[i-1], &batId, 
srid);
+   if(ret != MAL_SUCCEED) {
+   *geomWKB = wkb_nil;
+   
+   GDKfree(inputWKB);
+   for(;i>0; i--)
+   if(linestringsWKB[i-1])
+   GDKfree(linestringsWKB[i-1]);
+   GDKfree(linestringsWKB);
+   
+   throw(MAL, "geom.MLineStringToPolygon", "All linestring 
should be closed");
+   }
+
+   ret = wkbArea(&linestringsArea[i-1], &polygonWKB);
+   if(ret != MAL_SUCCEED) {
+   *geomWKB = wkb_nil;
+   
+   GDKfree(inputWKB);
+   for(;i>0; i--)
+   if(linestringsWKB[i-1])
+   GDKfree(linestringsWKB[i-1]);
+   GDKfree(linestringsWKB);
+   
+   return ret;
+   }
+
+   GDKfree(polygonWKB);
+   }
+
+   GDKfree(inputWKB);
+
+   //order the linestrings with decreasing (polygons) area
+   while(!ordered) {
+   ordered = 1;
+   
+   for(i=0; i linestringsArea[i]) {
+   //switch
+   wkb* linestringWKB = linestringsWKB[i];
+   double linestringArea = linestringsArea[i];
+
+   linestringsWKB[i] = linestringsWKB[i+1];
+   linestringsArea[i] = linestringsArea[i+1];
+
+   linestringsWKB[i+1] = linestringWKB;
+   linestringsArea[i+1] = linestringArea;
+   
+   

MonetDB: Oct2014 - Fix sql.analyze.

2014-08-26 Thread Sjoerd Mullender
Changeset: c8bc1bd7c354 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c8bc1bd7c354
Modified Files:
sql/backends/monet5/sql_statistics.c
Branch: Oct2014
Log Message:

Fix sql.analyze.


diffs (36 lines):

diff --git a/sql/backends/monet5/sql_statistics.c 
b/sql/backends/monet5/sql_statistics.c
--- a/sql/backends/monet5/sql_statistics.c
+++ b/sql/backends/monet5/sql_statistics.c
@@ -109,15 +109,27 @@ sql_analyze(Client cntxt, MalBlkPtr mb, 
bsample = BATsample(bn, 
(BUN) 25000);
} else
bsample = NULL;
-   br = BATsubselect(bn, bsample, 
ATOMnilptr(bn->ttype), ATOMnilptr(bn->ttype), 0, 0, 0);
+   br = BATsubselect(bn, bsample, 
ATOMnilptr(bn->ttype), NULL, 0, 0, 0);
nils = BATcount(br);
-   if (br->tkey)
+   BBPunfix(br->batCacheid);
+   if (bn->tkey)
uniq = sz;
else {
-   br = 
BATkunique(BATmirror(br));
-   uniq = br? 
BATcount(br):0;
+   BAT *gn, *en;
+   if (bsample)
+   br = 
BATproject(bsample, bn);
+   else
+   br = bn;
+   /* BATgroup checks 
BATproject result */
+   if (BATgroup(&gn, &en, 
NULL, br, NULL, NULL, NULL) == GDK_SUCCEED) {
+   uniq = 
BATcount(en);
+   
BBPunfix(gn->batCacheid);
+   
BBPunfix(en->batCacheid);
+   } else
+   uniq = 0;
+   if (bsample && br)
+   
BBPunfix(br->batCacheid);
}
-   BBPunfix(br->batCacheid);
if( bsample)

BBPunfix(bsample->batCacheid);
sorted = BATtordered(bn);
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Oct2014 - Simplify stmt_unique.

2014-08-26 Thread Sjoerd Mullender
Changeset: 3a6594ecbb94 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3a6594ecbb94
Modified Files:
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_statement.c
sql/backends/monet5/sql_statement.h
Branch: Oct2014
Log Message:

Simplify stmt_unique.
It is called in one place with three NULL params, so we change it to
not include those params.


diffs (46 lines):

diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -509,7 +509,7 @@ exp_bin(mvc *sql, sql_exp *e, stmt *left
grp = stmt_project(sql->sa, 
next, grp);
stmt_group_done(g);
} else
-   as = stmt_unique(sql->sa, as, 
NULL, NULL, NULL);
+   as = stmt_unique(sql->sa, as);
}
append(l, as);
}
diff --git a/sql/backends/monet5/sql_statement.c 
b/sql/backends/monet5/sql_statement.c
--- a/sql/backends/monet5/sql_statement.c
+++ b/sql/backends/monet5/sql_statement.c
@@ -826,14 +826,14 @@ stmt_reorder(sql_allocator *sa, stmt *s,
 }
 
 stmt *
-stmt_unique(sql_allocator *sa, stmt *s, stmt *g, stmt *e, stmt *c)
+stmt_unique(sql_allocator *sa, stmt *s)
 {
stmt *ns = stmt_create(sa, st_unique);
 
ns->op1 = s;
-   ns->op2 = g;
-   ns->op3 = e;
-   ns->op4.stval = c;
+   ns->op2 = NULL;
+   ns->op3 = NULL;
+   ns->op4.stval = NULL;
ns->nrcols = s->nrcols;
ns->key = 1;
ns->aggr = s->aggr;
diff --git a/sql/backends/monet5/sql_statement.h 
b/sql/backends/monet5/sql_statement.h
--- a/sql/backends/monet5/sql_statement.h
+++ b/sql/backends/monet5/sql_statement.h
@@ -245,7 +245,7 @@ extern stmt *stmt_binop(sql_allocator *s
 extern stmt *stmt_Nop(sql_allocator *sa, stmt *ops, sql_subfunc *op);
 extern stmt *stmt_func(sql_allocator *sa, stmt *ops, char *name, sql_rel *imp);
 extern stmt *stmt_aggr(sql_allocator *sa, stmt *op1, stmt *grp, stmt *ext, 
sql_subaggr *op, int reduce, int no_nil);
-extern stmt *stmt_unique(sql_allocator *sa, stmt *s, stmt *grp, stmt *ext, 
stmt *cnt);
+extern stmt *stmt_unique(sql_allocator *sa, stmt *s);
 
 extern stmt *stmt_alias(sql_allocator *sa, stmt *op1, char *tname, char *name);
 
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Oct2014 - Count groups instead of result of BATkunique ...

2014-08-26 Thread Sjoerd Mullender
Changeset: 22b783ba2620 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=22b783ba2620
Modified Files:
monetdb5/modules/kernel/algebra.c
monetdb5/modules/mal/tokenizer.c
Branch: Oct2014
Log Message:

Count groups instead of result of BATkunique to find count of distinct values.


diffs (55 lines):

diff --git a/monetdb5/modules/kernel/algebra.c 
b/monetdb5/modules/kernel/algebra.c
--- a/monetdb5/modules/kernel/algebra.c
+++ b/monetdb5/modules/kernel/algebra.c
@@ -350,17 +350,17 @@ ALGgroupby(int *res, int *gids, int *cnt
 str
 ALGcard(lng *result, int *bid)
 {
-   BAT *b, *bn;
+   BAT *b, *gn, *en;
 
if ((b = BATdescriptor(*bid)) == NULL) {
throw(MAL, "algebra.card", RUNTIME_OBJECT_MISSING);
}
-   bn = (BAT *) BATkunique(BATmirror(b));
-   if (bn == NULL) {
+   if (BATgroup(&gn, &en, NULL, b, NULL, NULL, NULL) != GDK_SUCCEED) {
throw(MAL, "algebra.card", GDK_EXCEPTION);
}
-   *result = BATcount(bn);
-   BBPunfix(bn->batCacheid);
+   *result = BATcount(en);
+   BBPunfix(gn->batCacheid);
+   BBPunfix(en->batCacheid);
BBPreleaseref(b->batCacheid);
return MAL_SUCCEED;
 }
diff --git a/monetdb5/modules/mal/tokenizer.c b/monetdb5/modules/mal/tokenizer.c
--- a/monetdb5/modules/mal/tokenizer.c
+++ b/monetdb5/modules/mal/tokenizer.c
@@ -629,7 +629,7 @@ TKNZRgetCount(int *r)
 str
 TKNZRgetCardinality(int *r)
 {
-   BAT *b, *bn;
+   BAT *b, *gn, *en;
int i;
wrd cnt;
 
@@ -640,9 +640,13 @@ TKNZRgetCardinality(int *r)
throw(MAL, "tokenizer.getCardinality", MAL_MALLOC_FAIL);
BATseqbase(b, 0);
for (i = 0; i < tokenDepth; i++) {
-   bn = (BAT *) BATkunique(BATmirror(tokenBAT[i].val));
-   cnt = (wrd) BATcount(bn);
-   BBPunfix(bn->batCacheid);
+   if (BATgroup(&gn, &en, NULL, tokenBAT[i].val, NULL, NULL, NULL) 
!= GDK_SUCCEED) {
+   BBPreclaim(b);
+   throw(MAL, "tokenizer.getCardinality", GDK_EXCEPTION);
+   }
+   cnt = (wrd) BATcount(en);
+   BBPunfix(gn->batCacheid);
+   BBPunfix(en->batCacheid);
BUNappend(b, &cnt, FALSE);
}
 
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Protobuf - Resurrected some files... one to go.

2014-08-26 Thread Hannes Muehleisen
Changeset: 671c618dfd2b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=671c618dfd2b
Added Files:
common/stream/mapi_pb-c.c
common/stream/mapi_pb-c.h
common/stream/mapi_pb.proto
common/stream/pbstream.c
common/stream/pbstream.h
Modified Files:
clients/mapilib/mapi.c
Branch: Protobuf
Log Message:

Resurrected some files... one to go.


Unterschiede (gekürzt von 1072 auf 300 Zeilen):

diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -4426,7 +4426,7 @@ mapi_fetch_field(MapiHdl hdl, int fnr)
break;
case MAPI_REPLY__QUERY_RESULT__COLUMN__TYPE__INTEGER:
intbuf = malloc(15);
-   sprintf(intbuf, "%ld", 
col->intvalues[result->tuple_count]);
+   sprintf(intbuf, "%lld", 
col->intvalues[result->tuple_count]);
return intbuf;
break;
case MAPI_REPLY__QUERY_RESULT__COLUMN__TYPE__FLOAT:
diff --git a/common/stream/mapi_pb-c.c b/common/stream/mapi_pb-c.c
new file mode 100644
--- /dev/null
+++ b/common/stream/mapi_pb-c.c
@@ -0,0 +1,701 @@
+/* Generated by the protocol buffer compiler.  DO NOT EDIT! */
+
+/* Do not generate deprecated warnings for self */
+#ifndef PROTOBUF_C_NO_DEPRECATED
+#define PROTOBUF_C_NO_DEPRECATED
+#endif
+
+#include "mapi_pb-c.h"
+void   mapi_command__init
+ (MapiCommand *message)
+{
+  static MapiCommand init_value = MAPI_COMMAND__INIT;
+  *message = init_value;
+}
+size_t mapi_command__get_packed_size
+ (const MapiCommand *message)
+{
+  PROTOBUF_C_ASSERT (message->base.descriptor == &mapi_command__descriptor);
+  return protobuf_c_message_get_packed_size ((const 
ProtobufCMessage*)(message));
+}
+size_t mapi_command__pack
+ (const MapiCommand *message,
+  uint8_t   *out)
+{
+  PROTOBUF_C_ASSERT (message->base.descriptor == &mapi_command__descriptor);
+  return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
+}
+size_t mapi_command__pack_to_buffer
+ (const MapiCommand *message,
+  ProtobufCBuffer *buffer)
+{
+  PROTOBUF_C_ASSERT (message->base.descriptor == &mapi_command__descriptor);
+  return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, 
buffer);
+}
+MapiCommand *
+   mapi_command__unpack
+ (ProtobufCAllocator  *allocator,
+  size_t   len,
+  const uint8_t   *data)
+{
+  return (MapiCommand *)
+ protobuf_c_message_unpack (&mapi_command__descriptor,
+allocator, len, data);
+}
+void   mapi_command__free_unpacked
+ (MapiCommand *message,
+  ProtobufCAllocator *allocator)
+{
+  PROTOBUF_C_ASSERT (message->base.descriptor == &mapi_command__descriptor);
+  protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
+}
+void   mapi_reply__query_result__column__init
+ (MapiReply__QueryResult__Column *message)
+{
+  static MapiReply__QueryResult__Column init_value = 
MAPI_REPLY__QUERY_RESULT__COLUMN__INIT;
+  *message = init_value;
+}
+void   mapi_reply__query_result__init
+ (MapiReply__QueryResult *message)
+{
+  static MapiReply__QueryResult init_value = MAPI_REPLY__QUERY_RESULT__INIT;
+  *message = init_value;
+}
+void   mapi_reply__init
+ (MapiReply *message)
+{
+  static MapiReply init_value = MAPI_REPLY__INIT;
+  *message = init_value;
+}
+size_t mapi_reply__get_packed_size
+ (const MapiReply *message)
+{
+  PROTOBUF_C_ASSERT (message->base.descriptor == &mapi_reply__descriptor);
+  return protobuf_c_message_get_packed_size ((const 
ProtobufCMessage*)(message));
+}
+size_t mapi_reply__pack
+ (const MapiReply *message,
+  uint8_t   *out)
+{
+  PROTOBUF_C_ASSERT (message->base.descriptor == &mapi_reply__descriptor);
+  return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
+}
+size_t mapi_reply__pack_to_buffer
+ (const MapiReply *message,
+  ProtobufCBuffer *buffer)
+{
+  PROTOBUF_C_ASSERT (message->base.descriptor == &mapi_reply__descriptor);
+  return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, 
buffer);
+}
+MapiReply *
+   mapi_reply__unpack
+ (ProtobufCAllocator  *allocator,
+  size_t   len,
+  const uint8_t   *data)
+{
+  return (MapiReply *)
+ protobuf_c_message_unpack (&mapi_reply__descriptor,
+allocator, len, data);
+}
+void   mapi_reply__free_unpacked
+ (MapiReply *message,
+ 

MonetDB: geo - ST_NumPatches + ST_PatchN

2014-08-26 Thread Foteini Alvanaki
Changeset: 943c7da68f9c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=943c7da68f9c
Modified Files:
geom/monetdb5/geom.c
geom/monetdb5/geom.mal
geom/sql/40_geom.sql
Branch: geo
Log Message:

ST_NumPatches + ST_PatchN


diffs (57 lines):

diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -217,7 +217,6 @@ geom_export str wkbNumGeometries(int* ou
 geom_export str wkbTransform(wkb**, wkb**, int*, int*, char**, char**);
 geom_export str wkbPointOnSurface(wkb**, wkb**);
 
-
 geom_export str geom_2_geom(wkb** resWKB, wkb **valueWKB, int* columnType, 
int* columnSRID); 
 geom_export str geom_2_geom_bat(int* outBAT_id, int* inBAT_id, int* 
columnType, int* columnSRID);
 
@@ -3115,8 +3114,6 @@ str wkbNumGeometries(int* out, wkb** geo
return MAL_SUCCEED;
 }
 
-
-
 /* MBR */
 
 /* Creates the mbr for the given geom_geometry. */
diff --git a/geom/monetdb5/geom.mal b/geom/monetdb5/geom.mal
--- a/geom/monetdb5/geom.mal
+++ b/geom/monetdb5/geom.mal
@@ -335,7 +335,6 @@ end MakePolygon;
 command PointOnSurface(w:wkb) :wkb address wkbPointOnSurface
 comment "Returns a point guaranteed to lie on the surface. Similar to postGIS 
it works for points and lines in addition to surfaces and for 3d geometries.";
 
-
 command mbr(:wkb) :mbr address wkbMBR
 comment "Creates the mbr for the given wkb.";
 command MakeBox2D(:wkb,:wkb) :mbr address wkbBox2D
diff --git a/geom/sql/40_geom.sql b/geom/sql/40_geom.sql
--- a/geom/sql/40_geom.sql
+++ b/geom/sql/40_geom.sql
@@ -4095,13 +4095,19 @@ CREATE FUNCTION ST_InteriorRings(geom Ge
 --END;
 --CREATE FUNCTION ST_SetInteriorRings(geom Geometry[]) RETURNS Geometry 
EXTERNAL NAME geom."InteriorRings";
 
---Functions on Polyhedral Surfaces
+--Functions on Polyhedral Surfaces (a simple surface, consisting of a number 
of Polygon pathes or facets)
 --CREATE FUNCTION ST_Geometries(geom Geometry) RETURNS TABLE(geom Geometries) 
EXTERNAL NAME geom."Geometries";
 --CREATE FUNCTION NumSurfaces(geom Geometry) RETURNS integer EXTERNAL NAME 
geom."NumSurfaces";
 --CREATE FUNCTION Surface(positionNum integer) RETURNS Geometry EXTERNAL NAME 
geom."SurfaceN";
 --from Part 1
---CREATE FUNCTION ST_NumPatches(geom Geometry) RETURNS integer EXTERNAL NAME 
--works only with polyhedral surface
---CREATE FUNCTION ST_PatchN(geom Geometry, patchNum integer) RETURNS Geometry 
EXTERNAL NAME --works with polyhedral surface
+CREATE FUNCTION ST_NumPatches(geom Geometry) RETURNS integer --EXTERNAL NAME 
geom."NumPatches"; --same with NumSurfaces
+BEGIN
+   RETURN SELECT ST_NumGeometries(geom);
+END;
+CREATE FUNCTION ST_PatchN(geom Geometry, patchNum integer) RETURNS Geometry 
--EXTERNAL NAME geom."PatchN" --same with Surface
+BEGIN
+   RETURN SELECT ST_GeometryN(geom, patchNum);
+END; 
 --BoundingPolygons
 --IsClosed
 
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: geo - FromText identifies polyhedralsurface and changes...

2014-08-26 Thread Foteini Alvanaki
Changeset: 06fd26fbeca2 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=06fd26fbeca2
Modified Files:
geom/monetdb5/geom.c
Branch: geo
Log Message:

FromText identifies polyhedralsurface and changes it to multipolugon


diffs (69 lines):

diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -3881,11 +3881,36 @@ int wkbTOSTR(char **geomWKT, int* len, w
 int wkbFROMSTR(char* geomWKT, int* len, wkb **geomWKB, int srid) {
GEOSGeom geosGeometry = NULL;   /* The geometry object that is parsed 
from the src string. */
GEOSWKTReader *WKT_reader;
+   char *polyhedralSurface = "POLYHEDRALSURFACE";
+   char *multiPolygon = "MULTIPOLYGON";
+   char *geoType;
+   int typeSize = 0;
+   char *geomWKT_original = NULL;
 
if (strcmp(geomWKT, str_nil) == 0) {
*geomWKB = wkb_nil;
return 0;
}
+   
+   //check whether the geometry type is polyhedral surface
+   //geos cannot handle this type of geometry but since it is 
+   //a special type of multipolygon I jsu change the type before 
+   //continuing. Of course this means that isValid for example does
+   //not work correctly.
+   typeSize = strlen(polyhedralSurface);
+   geoType = (char*)GDKmalloc((typeSize+1)*sizeof(char));
+   memcpy(geoType, geomWKT, typeSize);
+   geoType[typeSize] = '\0';
+   if(strcasecmp(geoType, polyhedralSurface) == 0) {
+   int sizeOfInfo = strlen(geomWKT)-strlen(polyhedralSurface);
+   geomWKT_original = geomWKT;
+   geomWKT = 
(char*)GDKmalloc((sizeOfInfo+strlen(multiPolygon)+1)*sizeof(char));
+   strcpy(geomWKT, multiPolygon);
+   memcpy(geomWKT+strlen(multiPolygon), 
&geomWKT_original[strlen(polyhedralSurface)], sizeOfInfo);
+   geomWKT[sizeOfInfo+strlen(multiPolygon)] = '\0';
+   }
+   GDKfree(geoType);
+   // UP TO HERE ///
 
WKT_reader = GEOSWKTReader_create();
geosGeometry = GEOSWKTReader_read(WKT_reader, geomWKT); 
@@ -3913,6 +3938,10 @@ int wkbFROMSTR(char* geomWKT, int* len, 
 
*len = (int) wkb_size((*geomWKB)->len);
 
+   if(geomWKT_original) {
+   GDKfree(geomWKT);
+   geomWKT = geomWKT_original; 
+   }
return (int)strlen(geomWKT);
 }
 
@@ -4374,17 +4403,3 @@ void wkbaHEAP(Heap *heap, size_t capacit
fprintf(stderr, "wkbaNULL\n");
 HEAP_initialize(heap, capacity, 0, (int) sizeof(var_t));
 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Merge with Oct2014 branch.

2014-08-26 Thread Sjoerd Mullender
Changeset: 781dfc8f4295 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=781dfc8f4295
Added Files:
sql/test/BugTracker-2014/Tests/orderby_on_constant.Bug-3554.sql
sql/test/BugTracker-2014/Tests/orderby_on_constant.Bug-3554.stable.err
sql/test/BugTracker-2014/Tests/orderby_on_constant.Bug-3554.stable.out
Modified Files:
monetdb5/mal/Tests/tst866.stable.out
monetdb5/modules/kernel/bat5.c
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_statement.c
sql/test/BugTracker-2014/Tests/All
Branch: default
Log Message:

Merge with Oct2014 branch.


diffs (300 lines):

diff --git a/monetdb5/mal/Tests/tst866.stable.out 
b/monetdb5/mal/Tests/tst866.stable.out
--- a/monetdb5/mal/Tests/tst866.stable.out
+++ b/monetdb5/mal/Tests/tst866.stable.out
@@ -74,7 +74,7 @@ end main;
 #-#
 [ 0@0,   0@0 ]
 [ 1@0,   8@0 ]
-[ 2@0,   7@0 ]
+[ 2@0, 6@0  ]
 [ 3@0,   3@0 ]
 [ 4@0,   4@0 ]
 [ 5@0,   5@0 ]
diff --git a/monetdb5/modules/kernel/bat5.c b/monetdb5/modules/kernel/bat5.c
--- a/monetdb5/modules/kernel/bat5.c
+++ b/monetdb5/modules/kernel/bat5.c
@@ -2204,9 +2204,10 @@ BKCshrinkBATmap(int *ret, int *bid, int 
Type *r = (Type*)Tloc(bn, BUNfirst(bn));\
for (;po) {  \
+   while ( ol>o && ol[-1] == bidx) {   \
bidx--; 
\
-   ol--;q--;   
\
+   q--;
\
+   ol--;   
\
}   
\
*r++ = *(--q);  
\
o += (o < ol);  
\
@@ -2233,7 +2234,7 @@ BKCreuseBAT(int *ret, int *bid, int *did
BBPreleaseref(b->batCacheid);
throw(MAL, "bat.reuse", RUNTIME_OBJECT_MISSING);
}
-   bn= BATnew(b->htype, b->ttype, BATcount(b) - BATcount(d) , TRANSIENT);
+   bn= BATnew(b->htype, b->ttype, BATcount(b) - BATcount(d), TRANSIENT);
if (bn == NULL) {
BBPreleaseref(b->batCacheid);
BBPreleaseref(d->batCacheid);
@@ -2247,9 +2248,10 @@ BKCreuseBAT(int *ret, int *bid, int *did
throw(MAL, "bat.reuse", MAL_MALLOC_FAIL );
}
 
-   bidx= BUNlast(b)-1;
+   oidx = b->hseqbase;
+   bidx = oidx + BATcount(b)-1;
o = (oid*)Tloc(bs, BUNfirst(bs));
-   ol= (oid*)Tloc(bs, BUNlast(bs))-1;
+   ol= (oid*)Tloc(bs, BUNlast(bs));
 
switch(ATOMstorage(b->ttype) ){
case TYPE_bte: reuseloop(bte); break;
@@ -2271,15 +2273,17 @@ BKCreuseBAT(int *ret, int *bid, int *did
 
for (;po) {
+   while ( ol > o && ol[-1] == bidx) {
bidx--;
-   ol--;q--;
+   q--;
+   ol--;
}
BUNappend(bn, BUNtail(bi, --q), FALSE);
o += (o < ol);
bidx--;
-   } else
+   } else {
BUNappend(bn, BUNtail(bi, p), FALSE);
+   }
}
} else {
switch( b->T->width){
@@ -2310,6 +2314,7 @@ BKCreuseBAT(int *ret, int *bid, int *did
BBPkeepref(*ret= bn->batCacheid);
return MAL_SUCCEED;
 }
+
 str
 BKCreuseBATmap(int *ret, int *bid, int *did)
 {
@@ -2328,7 +2333,7 @@ BKCreuseBATmap(int *ret, int *bid, int *
BBPreleaseref(b->batCacheid);
throw(MAL, "bat.shrinkMap", RUNTIME_OBJECT_MISSING);
}
-   bn= BATnew(TYPE_void, TYPE_oid, BATcount(b) , TRANSIENT);
+   bn= BATnew(TYPE_void, TYPE_oid, BATcount(b) - BATcount(d), TRANSIENT);
if (bn == NULL) {
BBPreleaseref(b->batCacheid);
BBPreleaseref(d->batCacheid);
@@ -2342,21 +2347,24 @@ BKCreuseBATmap(int *ret, int *bid, int *
throw(MAL, "bat.shrinkMap", MAL_MALLOC_FAIL );
}
 
-   bidx= BUNlast(b)-1;
-o = (oid*)Tloc(bs, BUNfirst(bs));
-ol= (oid*)Tloc(bs, BUNlast(bs));
-r = (oid*)Tloc(bn, BUNfirst(bn));
+   oidx = b->hseqbase;
+   bidx = oidx + BATcount(b)-1;
+   o  = (oid*)Tloc(bs, BUNfirst(bs));
+   ol = (oid*)Tlo

MonetDB: Oct2014 - Fix bat.reusemap + approve corrected output.

2014-08-26 Thread Sjoerd Mullender
Changeset: ec293a39a4bf for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ec293a39a4bf
Modified Files:
monetdb5/mal/Tests/tst866.stable.out
monetdb5/modules/kernel/bat5.c
Branch: Oct2014
Log Message:

Fix bat.reusemap + approve corrected output.


diffs (48 lines):

diff --git a/monetdb5/mal/Tests/tst866.stable.out 
b/monetdb5/mal/Tests/tst866.stable.out
--- a/monetdb5/mal/Tests/tst866.stable.out
+++ b/monetdb5/mal/Tests/tst866.stable.out
@@ -74,7 +74,7 @@ end main;
 #-#
 [ 0@0,   0@0 ]
 [ 1@0,   8@0 ]
-[ 2@0,   7@0 ]
+[ 2@0, 6@0  ]
 [ 3@0,   3@0 ]
 [ 4@0,   4@0 ]
 [ 5@0,   5@0 ]
diff --git a/monetdb5/modules/kernel/bat5.c b/monetdb5/modules/kernel/bat5.c
--- a/monetdb5/modules/kernel/bat5.c
+++ b/monetdb5/modules/kernel/bat5.c
@@ -2228,7 +2228,7 @@ BKCreuseBAT(int *ret, int *bid, int *did
BBPreleaseref(b->batCacheid);
throw(MAL, "bat.reuse", RUNTIME_OBJECT_MISSING);
}
-   bn= BATnew(b->htype, b->ttype, BATcount(b) - BATcount(d) , TRANSIENT);
+   bn= BATnew(b->htype, b->ttype, BATcount(b) - BATcount(d), TRANSIENT);
if (bn == NULL) {
BBPreleaseref(b->batCacheid);
BBPreleaseref(d->batCacheid);
@@ -2321,7 +2321,7 @@ BKCreuseBATmap(int *ret, int *bid, int *
BBPreleaseref(b->batCacheid);
throw(MAL, "bat.shrinkMap", RUNTIME_OBJECT_MISSING);
}
-   bn= BATnew(TYPE_void, TYPE_oid, BATcount(b) , TRANSIENT);
+   bn= BATnew(TYPE_void, TYPE_oid, BATcount(b) - BATcount(d), TRANSIENT);
if (bn == NULL) {
BBPreleaseref(b->batCacheid);
BBPreleaseref(d->batCacheid);
@@ -2336,12 +2336,12 @@ BKCreuseBATmap(int *ret, int *bid, int *
}
 
oidx = b->hseqbase;
-   bidx = oidx + BUNlast(b)-1;
+   bidx = oidx + BATcount(b)-1;
o  = (oid*)Tloc(bs, BUNfirst(bs));
ol = (oid*)Tloc(bs, BUNlast(bs));
r  = (oid*)Tloc(bn, BUNfirst(bn));
 
-   for (;oidx o && ol[-1] == bidx) {
bidx--;
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Oct2014 - Fix changeset 6c4080d30b3e: only decrement ol...

2014-08-26 Thread Sjoerd Mullender
Changeset: e36b651f4a83 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e36b651f4a83
Modified Files:
monetdb5/modules/kernel/bat5.c
Branch: Oct2014
Log Message:

Fix changeset 6c4080d30b3e: only decrement ol if we "use" the value.
The unfixed version caused monetdb5/mal/tst866 to fail.


diffs (57 lines):

diff --git a/monetdb5/modules/kernel/bat5.c b/monetdb5/modules/kernel/bat5.c
--- a/monetdb5/modules/kernel/bat5.c
+++ b/monetdb5/modules/kernel/bat5.c
@@ -2198,9 +2198,10 @@ BKCshrinkBATmap(int *ret, int *bid, int 
Type *r = (Type*)Tloc(bn, BUNfirst(bn));\
for (;po && *--ol == bidx) {
\
+   while ( ol>o && ol[-1] == bidx) {   \
bidx--; 
\
-   q--;
\
+   q--;
\
+   ol--;   
\
}   
\
*r++ = *(--q);  
\
o += (o < ol);  
\
@@ -2242,7 +2243,7 @@ BKCreuseBAT(int *ret, int *bid, int *did
}
 
oidx = b->hseqbase;
-   bidx = oidx + BUNlast(b)-1;
+   bidx = oidx + BATcount(b)-1;
o = (oid*)Tloc(bs, BUNfirst(bs));
ol= (oid*)Tloc(bs, BUNlast(bs));
 
@@ -2263,9 +2264,10 @@ BKCreuseBAT(int *ret, int *bid, int *did
 
for (;p o && *--ol == bidx) {
+   while ( ol > o && ol[-1] == bidx) {
bidx--;
q--;
+   ol--;
}
BUNappend(bn, BUNtail(bi, --q), FALSE);
o += (o < ol);
@@ -2335,14 +2337,15 @@ BKCreuseBATmap(int *ret, int *bid, int *
 
oidx = b->hseqbase;
bidx = oidx + BUNlast(b)-1;
-   o  = (oid*)Tloc(bs, BUNfirst(bs));
-   ol = (oid*)Tloc(bs, BUNlast(bs));
-   r  = (oid*)Tloc(bn, BUNfirst(bn));
+   o  = (oid*)Tloc(bs, BUNfirst(bs));
+   ol = (oid*)Tloc(bs, BUNlast(bs));
+   r  = (oid*)Tloc(bn, BUNfirst(bn));
 
for (;oidx o && *--ol == bidx) {
+   while ( ol > o && ol[-1] == bidx) {
bidx--;
+   ol--;
}
*r++ = bidx;
o += (o < ol);
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Oct2014 - Merged with Jan2014 branch.

2014-08-26 Thread Stefan Manegold
Changeset: 972d327c8d5f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=972d327c8d5f
Modified Files:
sql/test/BugTracker-2014/Tests/All
Branch: Oct2014
Log Message:

Merged with Jan2014 branch.


diffs (12 lines):

diff --git a/sql/test/BugTracker-2014/Tests/All 
b/sql/test/BugTracker-2014/Tests/All
--- a/sql/test/BugTracker-2014/Tests/All
+++ b/sql/test/BugTracker-2014/Tests/All
@@ -22,7 +22,7 @@ local-temp-2.Bug-3468
 select_in_crash.Bug-3491
 boolean_not.Bug-3505
 varchar_conversion_crash.Bug-3506
-bug_in_cse.Bug-3511
+HAVE_GEOM?bug_in_cse.Bug-3511
 stringfloatshtcompare.Bug-3512
 oid-table-assert.Bug-3514
 round-properties.Bug-3515
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jan2014 - test bug_in_cse.Bug-3511 requires GEOM

2014-08-26 Thread Stefan Manegold
Changeset: cefa75ee2806 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=cefa75ee2806
Modified Files:
sql/test/BugTracker-2014/Tests/All
Branch: Jan2014
Log Message:

test bug_in_cse.Bug-3511 requires GEOM


diffs (12 lines):

diff --git a/sql/test/BugTracker-2014/Tests/All 
b/sql/test/BugTracker-2014/Tests/All
--- a/sql/test/BugTracker-2014/Tests/All
+++ b/sql/test/BugTracker-2014/Tests/All
@@ -21,7 +21,7 @@ local-temp-2.Bug-3468
 select_in_crash.Bug-3491
 boolean_not.Bug-3505
 varchar_conversion_crash.Bug-3506
-bug_in_cse.Bug-3511
+HAVE_GEOM?bug_in_cse.Bug-3511
 stringfloatshtcompare.Bug-3512
 oid-table-assert.Bug-3514
 round-properties.Bug-3515
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: geo - removed commented lines

2014-08-26 Thread Foteini Alvanaki
Changeset: aa524126df1d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=aa524126df1d
Modified Files:
geom/monetdb5/geom.c
Branch: geo
Log Message:

removed commented lines


diffs (48 lines):

diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -2076,9 +2076,6 @@ str wkbInteriorRings(wkba** geomArray, w
int interiorRingsNum = 0, i=0;
GEOSGeom geosGeometry;
str ret = MAL_SUCCEED;
-// char* data= NULL;
-// int totalDataSize =0;
-fprintf(stderr, "In wkbInteriorRings\n");
 
if (wkb_isnil(*geomWKB)) {
throw(MAL, "geom.InteriorRings", "Null input geometry");
@@ -2109,7 +2106,6 @@ fprintf(stderr, "In wkbInteriorRings\n")
for (i = 0; i < interiorRingsNum; i++) { 
const GEOSGeometry* interiorRingGeometry;
wkb* interiorRingWKB;
-// char* dataCopy = NULL;

// get the interior ring of the geometry
interiorRingGeometry = GEOSGetInteriorRingN(geosGeometry, i);
@@ -2124,25 +2120,7 @@ fprintf(stderr, "In wkbInteriorRings\n")
}

(*geomArray)->data[i] = interiorRingWKB;
-
-// if(data)
-// dataCopy = data;
-// data = GDKmalloc(totalDataSize+interiorRingWKB->len+8);
-// if(dataCopy) { 
-// memcpy(data, dataCopy, totalDataSize);
-// GDKfree(dataCopy);
-// }
-//
-// memcpy(data+totalDataSize, &interiorRingWKB->len, 4);
-// memcpy(data+totalDataSize+4, &interiorRingWKB->srid, 4);
-// memcpy(data+totalDataSize+8, interiorRingWKB->data, 
interiorRingWKB->len);
-// totalDataSize += interiorRingWKB->len+8;
-   }
-
-// *geomArray = GDKmalloc(wkba_size(totalDataSize));
-// (*geomArray)->itemsNum = interiorRingsNum;
-// memcpy(&(*geomArray)->data, data, totalDataSize);
-// GDKfree(data);  
+   }
 
return MAL_SUCCEED;
 }
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: geo - wkba datatyoe finished + wkbInteriorRings impleme...

2014-08-26 Thread Foteini Alvanaki
Changeset: 7728b20d36fe for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7728b20d36fe
Modified Files:
geom/lib/libgeom.h
geom/monetdb5/geom.c
Branch: geo
Log Message:

wkba datatyoe finished + wkbInteriorRings implemented


diffs (179 lines):

diff --git a/geom/lib/libgeom.h b/geom/lib/libgeom.h
--- a/geom/lib/libgeom.h
+++ b/geom/lib/libgeom.h
@@ -126,7 +126,7 @@ typedef struct wkb {
 
 typedef struct wkba {
int itemsNum; //the number of wkbs
-   wkb** data; //the wkbs
+   wkb* data[]; //the wkbs
 } wkba;
 
 typedef struct {
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -799,7 +799,7 @@ static var_t wkba_size(int items) {
  
if (items == ~ 0)
items = 0;  
-   size = sizeof(wkba)+items*sizeof(wkba*);
+   size = sizeof(wkba)+items*sizeof(wkb*);
assert(size <= VAR_MAX);
 
return size;
@@ -2076,8 +2076,9 @@ str wkbInteriorRings(wkba** geomArray, w
int interiorRingsNum = 0, i=0;
GEOSGeom geosGeometry;
str ret = MAL_SUCCEED;
-   char* data= NULL;
-   int totalDataSize =0;
+// char* data= NULL;
+// int totalDataSize =0;
+fprintf(stderr, "In wkbInteriorRings\n");
 
if (wkb_isnil(*geomWKB)) {
throw(MAL, "geom.InteriorRings", "Null input geometry");
@@ -2102,10 +2103,13 @@ str wkbInteriorRings(wkba** geomArray, w
throw(MAL, "geom.InteriorRings", "Error in wkbNumRings");
}
 
+   *geomArray = (wkba*)GDKmalloc(wkba_size(interiorRingsNum));
+   (*geomArray)->itemsNum = interiorRingsNum;
+
for (i = 0; i < interiorRingsNum; i++) { 
const GEOSGeometry* interiorRingGeometry;
wkb* interiorRingWKB;
-   char* dataCopy = NULL;
+// char* dataCopy = NULL;

// get the interior ring of the geometry
interiorRingGeometry = GEOSGetInteriorRingN(geosGeometry, i);
@@ -2118,25 +2122,27 @@ str wkbInteriorRings(wkba** geomArray, w
if(!interiorRingWKB) {
throw(MAL, "geom.InteriorRings", "Error in wkb2geos");
}
-
-   if(data)
-   dataCopy = data;
-   data = GDKmalloc(totalDataSize+interiorRingWKB->len+8);
-   if(dataCopy) { 
-   memcpy(data, dataCopy, totalDataSize);
-   GDKfree(dataCopy);
-   }
-
-   memcpy(data+totalDataSize, &interiorRingWKB->len, 4);
-   memcpy(data+totalDataSize+4, &interiorRingWKB->srid, 4);
-   memcpy(data+totalDataSize+8, interiorRingWKB->data, 
interiorRingWKB->len);
-   totalDataSize += interiorRingWKB->len+8;
-   }
-
-   *geomArray = GDKmalloc(wkba_size(totalDataSize));
-   (*geomArray)->itemsNum = interiorRingsNum;
-   memcpy(&(*geomArray)->data, data, totalDataSize);
-   GDKfree(data);  
+   
+   (*geomArray)->data[i] = interiorRingWKB;
+
+// if(data)
+// dataCopy = data;
+// data = GDKmalloc(totalDataSize+interiorRingWKB->len+8);
+// if(dataCopy) { 
+// memcpy(data, dataCopy, totalDataSize);
+// GDKfree(dataCopy);
+// }
+//
+// memcpy(data+totalDataSize, &interiorRingWKB->len, 4);
+// memcpy(data+totalDataSize+4, &interiorRingWKB->srid, 4);
+// memcpy(data+totalDataSize+8, interiorRingWKB->data, 
interiorRingWKB->len);
+// totalDataSize += interiorRingWKB->len+8;
+   }
+
+// *geomArray = GDKmalloc(wkba_size(totalDataSize));
+// (*geomArray)->itemsNum = interiorRingsNum;
+// memcpy(&(*geomArray)->data, data, totalDataSize);
+// GDKfree(data);  
 
return MAL_SUCCEED;
 }
@@ -4194,18 +4200,23 @@ int mbrWRITE(mbr *c, stream *s, size_t c
 /* return length of resulting string. */
 size_t wkbaTOSTR(char **toStr, int* len, wkba *fromArray) {
int items = fromArray->itemsNum, i;
-   size_t dataSize=sizeof(int), skipBytes=0;
+   int itemsNumDigits = ceil(log10(items));
+   size_t dataSize;//, skipBytes=0;
char** partialStrs;
char* nilStr = "nil";
-
+   char* toStrPtr = NULL, 
*itemsNumStr=GDKmalloc((itemsNumDigits+1)*sizeof(char));
+   
 fprintf(stderr, "wkbaTOSTR\n");
-
+   sprintf(itemsNumStr, "%d", items);
+   dataSize = strlen(itemsNumStr);
+
+   
//reserve space for an array with pointers to the partial strings, i.e. 
for each wkbTOSTR
-   partialStrs = (char**)malloc(sizeof(char**));
-   *partialStrs = (char*) malloc(items*sizeof(char*));
+   partialStrs = (char**)GDKmalloc(sizeof(char**));
+   *partialStrs = (char*) GDKmalloc(items*sizeof(char*));
//create the string version of each wkb
for(i=0; idata[i]);
+

MonetDB: geo - wkba cont. : all necessary functions e.g. tostr, ...

2014-08-26 Thread Foteini Alvanaki
Changeset: 364312bb6bb6 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=364312bb6bb6
Modified Files:
geom/lib/libgeom.h
geom/monetdb5/geom.c
Branch: geo
Log Message:

wkba cont. : all necessary functions e.g. tostr, cmp, heap etc implemented


diffs (truncated from 361 to 300 lines):

diff --git a/geom/lib/libgeom.h b/geom/lib/libgeom.h
--- a/geom/lib/libgeom.h
+++ b/geom/lib/libgeom.h
@@ -125,8 +125,8 @@ typedef struct wkb {
 } wkb;
 
 typedef struct wkba {
-   int itemsNum; //the number of wkb
-   char wkb[]; //the wkb
+   int itemsNum; //the number of wkbs
+   wkb** data; //the wkbs
 } wkba;
 
 typedef struct {
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -70,11 +70,11 @@ geom_export void geom_epilogue(void);
 /* the len argument is needed for correct storage and retrieval */
 geom_export int wkbTOSTR(char **geomWKT, int *len, wkb *geomWKB);
 geom_export int mbrTOSTR(char **dst, int *len, mbr *atom);
-geom_export int wkbaTOSTR(char **toStr, int* len, wkba *fromArray);
+geom_export size_t wkbaTOSTR(char **toStr, int* len, wkba *fromArray);
 
 geom_export int wkbFROMSTR(char* geomWKT, int *len, wkb** geomWKB, int srid);
 geom_export int mbrFROMSTR(char *src, int *len, mbr **atom);
-geom_export int wkbaFROMSTR(char *fromStr, int* len, wkba **toArray);
+geom_export int wkbaFROMSTR(char *fromStr, int* len, wkba **toArray, int srid);
 
 geom_export wkb *wkbNULL(void);
 geom_export mbr *mbrNULL(void);
@@ -91,7 +91,7 @@ geom_export int wkbaCOMP(wkba *l, wkba *
 /* read/write to/from log */
 geom_export wkb *wkbREAD(wkb *a, stream *s, size_t cnt);
 geom_export mbr *mbrREAD(mbr *a, stream *s, size_t cnt);
-geom_export wkb *wkbaREAD(wkba *a, stream *s, size_t cnt);
+geom_export wkba* wkbaREAD(wkba *a, stream *s, size_t cnt);
 
 geom_export int wkbWRITE(wkb *a, stream *s, size_t cnt);
 geom_export int mbrWRITE(mbr *c, stream *s, size_t cnt);
@@ -794,12 +794,12 @@ static var_t wkb_size(size_t len) {
 }
 
 /* returns the size of variable-sized atom wkba */
-static var_t wkba_size(size_t len) {
+static var_t wkba_size(int items) {
var_t size;
  
-   if (len == ~(size_t) 0)
-   len = 0;
-   size = sizeof(wkba)+len;
+   if (items == ~ 0)
+   items = 0;  
+   size = sizeof(wkba)+items*sizeof(wkba*);
assert(size <= VAR_MAX);
 
return size;
@@ -4192,105 +4192,64 @@ int mbrWRITE(mbr *c, stream *s, size_t c
 
 /* Creates the string representation of a wkb_array */
 /* return length of resulting string. */
-int wkbaTOSTR(char **toStr, int* len, wkba *fromArray) {
-   int strLength = 0;  /* "nil" */
-   int i=0, totalReadBytes=0, totalWrittenBytes=0;
-fprintf(stderr, "wkb_arrayTOSTR\n");   
-
-   //iterate over the wkb in the array
-   for(i=0; iitemsNum; i++) {
-   int wkbLength, srid;
-   wkb* geomWKB;
-   
-   //the first four bytes have the number of bytes in the wkb
-   memcpy(&wkbLength, fromArray->data+totalReadBytes, 4);
-   totalReadBytes += 4;
-   //the next four bytes have the srid
-   memcpy(&srid, fromArray->data+totalReadBytes, 4);
-   totalReadBytes += 4;
-   //the remaining wkbLenth bytes have the wkb data
-   geomWKB = GDKmalloc(wkb_size(wkbLength));
-   if (geomWKB) {
-   char* wkt = NULL;
-   char* totalCopy = NULL;
-
-   geomWKB->len = wkbLength;
-   geomWKB->srid = srid;
-   memcpy(&geomWKB->data, fromArray->data+totalReadBytes, 
wkbLength);
-   totalReadBytes += wkbLength;
-
-   //create the str from the wkb
-   strLength += wkbTOSTR(&wkt, len, geomWKB);
-   GDKfree(geomWKB);
-
-   totalCopy = *toStr; //hold the position of the already 
created str
-   *toStr = GDKmalloc(strLength+1); //allocate new space 
to add the new string as well
-   strcpy(*toStr, totalCopy); //copy the already create 
str to the new space
-   GDKfree(totalCopy); //free the new space
-   strcpy(*toStr+totalWrittenBytes, wkt); //copy the new 
string at the end of the old
-   totalWrittenBytes = strLength; //the number of written 
bytes
-   
-
-   } else { 
+size_t wkbaTOSTR(char **toStr, int* len, wkba *fromArray) {
+   int items = fromArray->itemsNum, i;
+   size_t dataSize=sizeof(int), skipBytes=0;
+   char** partialStrs;
+   char* nilStr = "nil";
+
+fprintf(stderr, "wkbaTOSTR\n");
+
+   //reserve space for an array with pointers to the partial strings, i.e. 
for each wkbTOSTR
+   partialStrs =

MonetDB: geo - merge with default

2014-08-26 Thread Foteini Alvanaki
Changeset: 0b4b21fdecb4 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0b4b21fdecb4
Added Files:
NT/makelibdef.py
clients/R/Tests/All
clients/R/Tests/dbi.R
clients/R/Tests/dbi.stable.err
clients/R/Tests/dbi.stable.out
clients/R/Tests/dplyr.R
clients/R/Tests/dplyr.stable.err
clients/R/Tests/dplyr.stable.out
clients/R/Tests/install-dependencies.sh
clients/R/Tests/install.sh
clients/R/Tests/install.stable.err
clients/R/Tests/install.stable.out
clients/R/Tests/survey.R
clients/R/Tests/survey.stable.err
clients/R/Tests/survey.stable.out
sql/backends/monet5/bam/Tests/check_files.reqtests
sql/backends/monet5/bam/Tests/query1.1.reqtests
sql/backends/monet5/bam/Tests/query1.2.reqtests
sql/backends/monet5/bam/Tests/query1.3.reqtests
sql/backends/monet5/bam/Tests/query1.4.reqtests
sql/backends/monet5/bam/Tests/query1.5.reqtests
sql/backends/monet5/bam/Tests/query1.6.reqtests
sql/backends/monet5/bam/Tests/query2.1.reqtests
sql/backends/monet5/bam/Tests/query2.10.reqtests
sql/backends/monet5/bam/Tests/query2.11.reqtests
sql/backends/monet5/bam/Tests/query2.12.reqtests
sql/backends/monet5/bam/Tests/query2.2.reqtests
sql/backends/monet5/bam/Tests/query2.3.reqtests
sql/backends/monet5/bam/Tests/query2.4.reqtests
sql/backends/monet5/bam/Tests/query2.5.reqtests
sql/backends/monet5/bam/Tests/query2.6.reqtests
sql/backends/monet5/bam/Tests/query2.7.reqtests
sql/backends/monet5/bam/Tests/query2.8.reqtests
sql/backends/monet5/bam/Tests/query2.9.reqtests
sql/backends/monet5/bam/Tests/sam_export.reqtests
sql/test/BugTracker-2014/Tests/ifthenelse.Bug-3546.sql
sql/test/BugTracker-2014/Tests/ifthenelse.Bug-3546.stable.err
sql/test/BugTracker-2014/Tests/ifthenelse.Bug-3546.stable.out
sql/test/BugTracker-2014/Tests/number_4_4.Bug-3543.sql
sql/test/BugTracker-2014/Tests/number_4_4.Bug-3543.stable.err
sql/test/BugTracker-2014/Tests/number_4_4.Bug-3543.stable.out
sql/test/BugTracker-2014/Tests/round.Bug-3542.sql
sql/test/BugTracker-2014/Tests/round.Bug-3542.stable.err
sql/test/BugTracker-2014/Tests/round.Bug-3542.stable.out
Removed Files:
clients/R/db.tests/monetdb.test.R
clients/R/db.tests/monetframe.test.R
clients/R/db.tests/sqlsurvey.test.R
clients/R/monet.frame/DESCRIPTION
clients/R/monet.frame/NAMESPACE
clients/R/monet.frame/NEWS
clients/R/monet.frame/R/monetframe.R
clients/R/monet.frame/man/aggregatef.Rd
clients/R/monet.frame/man/as.data.frame.Rd
clients/R/monet.frame/man/as.list.Rd
clients/R/monet.frame/man/mf.Rd
clients/R/monet.frame/man/monet.frame.Rd
clients/R/monet.frame/man/sample.Rd
clients/R/monet.frame/man/sd.Rd
clients/R/monet.frame/man/set.debug.Rd
clients/R/monet.frame/man/tabulate.Rd
clients/R/monet.frame/man/tabulate.monet.frame.Rd
clients/R/monet.frame/man/var.Rd
Modified Files:
MonetDB.spec
NT/rules.msc
NT/wincompile.py
buildtools/autogen/autogen/am.py
buildtools/autogen/autogen/msc.py
clients/R/MonetDB.R/NEWS
clients/R/MonetDB.R/R/monetdb.R
clients/Tests/MAL-signatures_all.stable.out
clients/Tests/MAL-signatures_fits_geom.stable.out
clients/Tests/MAL-signatures_geom.stable.out
clients/Tests/MAL-signatures_none.stable.out
clients/Tests/SQL-dump_all.stable.out
clients/Tests/SQL-dump_all.stable.out.oid32
clients/Tests/SQL-dump_geom.stable.out
clients/Tests/SQL-dump_geom.stable.out.32bit
clients/Tests/SQL-dump_geom.stable.out.64bit.oid32
clients/Tests/SQL-dump_none.stable.out
clients/Tests/exports.stable.out
configure.ag
debian/control
gdk/gdk.h
gdk/gdk_atoms.c
gdk/gdk_atoms.h
gdk/gdk_bbp.c
gdk/gdk_calc.c
gdk/gdk_imprints.c
gdk/gdk_imprints.h
gdk/gdk_private.h
gdk/gdk_select.c
monetdb5/extras/rapi/Makefile.ag
monetdb5/extras/rapi/Tests/rapi08.malC
monetdb5/extras/rapi/rapi.c
monetdb5/mal/Makefile.ag
monetdb5/mal/mal_import.c
monetdb5/modules/mal/tokenizer.c
monetdb5/tools/Makefile.ag
sql/backends/monet5/rest/Makefile.ag
sql/backends/monet5/sql.c
sql/backends/monet5/sql.h
sql/backends/monet5/sql.mal
sql/backends/monet5/sql_gencode.c
sql/backends/monet5/sql_round.c
sql/backends/monet5/sql_round_impl.h
sql/backends/monet5/sql_scenario.c
sql/backends/monet5/vaults/fits.c
sql/benchmarks/tpch/Tests/20-explain.stable.out
sql/benchmarks/tpch/Tests/2

MonetDB: geo - creating new type (wkba)

2014-08-26 Thread Foteini Alvanaki
Changeset: 0de233c64b1b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0de233c64b1b
Modified Files:
geom/lib/libgeom.h
geom/monetdb5/geom.c
geom/monetdb5/geom.mal
geom/sql/40_geom.sql
sql/common/sql_types.c
sql/common/sql_types.h
sql/server/sql_parser.y
Branch: geo
Log Message:

creating new type (wkba)


diffs (truncated from 1349 to 300 lines):

diff --git a/geom/lib/libgeom.h b/geom/lib/libgeom.h
--- a/geom/lib/libgeom.h
+++ b/geom/lib/libgeom.h
@@ -124,6 +124,11 @@ typedef struct wkb {
char data[1];
 } wkb;
 
+typedef struct wkba {
+   int itemsNum; //the number of wkb
+   char wkb[]; //the wkb
+} wkba;
+
 typedef struct {
unsigned char type;
mbr bbox;
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -67,8 +67,51 @@ geom_export void geoGetType(char** res, 
 geom_export bat *geom_prelude(void);
 geom_export void geom_epilogue(void);
 
+/* the len argument is needed for correct storage and retrieval */
+geom_export int wkbTOSTR(char **geomWKT, int *len, wkb *geomWKB);
+geom_export int mbrTOSTR(char **dst, int *len, mbr *atom);
+geom_export int wkbaTOSTR(char **toStr, int* len, wkba *fromArray);
+
+geom_export int wkbFROMSTR(char* geomWKT, int *len, wkb** geomWKB, int srid);
+geom_export int mbrFROMSTR(char *src, int *len, mbr **atom);
+geom_export int wkbaFROMSTR(char *fromStr, int* len, wkba **toArray);
+
 geom_export wkb *wkbNULL(void);
 geom_export mbr *mbrNULL(void);
+geom_export wkba *wkbaNULL(void);
+
+geom_export BUN wkbHASH(wkb *w);
+geom_export BUN mbrHASH(mbr *atom);
+geom_export BUN wkbaHASH(wkba *w);
+
+geom_export int wkbCOMP(wkb *l, wkb *r);
+geom_export int mbrCOMP(mbr *l, mbr *r);
+geom_export int wkbaCOMP(wkba *l, wkba *r);
+
+/* read/write to/from log */
+geom_export wkb *wkbREAD(wkb *a, stream *s, size_t cnt);
+geom_export mbr *mbrREAD(mbr *a, stream *s, size_t cnt);
+geom_export wkb *wkbaREAD(wkba *a, stream *s, size_t cnt);
+
+geom_export int wkbWRITE(wkb *a, stream *s, size_t cnt);
+geom_export int mbrWRITE(mbr *c, stream *s, size_t cnt);
+geom_export int wkbaWRITE(wkba *c, stream *s, size_t cnt);
+
+geom_export var_t wkbPUT(Heap *h, var_t *bun, wkb *val);
+geom_export var_t wkbaPUT(Heap *h, var_t *bun, wkba *val);
+
+geom_export void wkbDEL(Heap *h, var_t *index);
+geom_export void wkbaDEL(Heap *h, var_t *index);
+
+geom_export int wkbLENGTH(wkb *p);
+geom_export int wkbaLENGTH(wkba *p);
+
+geom_export void wkbHEAP(Heap *heap, size_t capacity);
+geom_export void wkbaHEAP(Heap *heap, size_t capacity);
+
+//geom_export str mbrFromString(mbr **w, str *src);
+geom_export str wkbIsnil(bit *r, wkb **v);
+
 
 /* functions tha are used when a column is added to an existing table */
 geom_export str mbrFromMBR(mbr **w, mbr **src);
@@ -85,18 +128,6 @@ geom_export wkb* geos2wkb(const GEOSGeom
  * works only for 2D geometries */
 geom_export mbr* mbrFromGeos(const GEOSGeom geosGeometry);
 
-/* the len argument is needed for correct storage and retrieval */
-geom_export int mbrFROMSTR(char *src, int *len, mbr **atom);
-geom_export int mbrTOSTR(char **dst, int *len, mbr *atom);
-geom_export int wkbFROMSTR(char* geomWKT, int *len, wkb** geomWKB, int srid);
-geom_export int wkbTOSTR(char **geomWKT, int *len, wkb *geomWKB);
-
-/* read/write to/from disk */
-geom_export mbr *mbrREAD(mbr *a, stream *s, size_t cnt);
-geom_export int mbrWRITE(mbr *c, stream *s, size_t cnt);
-geom_export wkb *wkbREAD(wkb *a, stream *s, size_t cnt);
-geom_export int wkbWRITE(wkb *a, stream *s, size_t cnt);
-
 
 geom_export str wkbFromText(wkb **geomWKB, str *geomWKT, int* srid, int *tpe);
 
@@ -162,7 +193,7 @@ geom_export str wkbMakePolygon(wkb** out
 geom_export str wkbExteriorRing(wkb**, wkb**);
 geom_export str wkbInteriorRingN(wkb**, wkb**, short*);
 geom_export str wkbNumRings(int*, wkb**, int*);
-geom_export str wkbInteriorRings(int* outBAT_id, wkb** geomWKB);
+geom_export str wkbInteriorRings(wkba**, wkb**);
 geom_export str wkbIsClosed(bit *out, wkb **geom);
 geom_export str wkbIsRing(bit *out, wkb **geom);
 geom_export str wkbIsValid(bit *out, wkb **geom);
@@ -762,23 +793,16 @@ static var_t wkb_size(size_t len) {
return (var_t) (sizeof(wkb) - 1 + len);
 }
 
-/* NULL: generic nil mbr. */
-/* returns a pointer to a nil-mbr. */
-mbr *mbrNULL(void) {
-   static mbr mbrNIL;
-   mbrNIL.xmin = flt_nil;
-   mbrNIL.ymin = flt_nil;
-   mbrNIL.xmax = flt_nil;
-   mbrNIL.ymax = flt_nil;
-   return (&mbrNIL);
-}
-
-/* returns a pointer to a null wkb */
-wkb *wkbNULL(void) {
-   static wkb nullval;
-
-   nullval.len = ~(int) 0;
-   return (&nullval);
+/* returns the size of variable-sized atom wkba */
+static var_t wkba_size(size_t len) {
+   var_t size;
+ 
+   if (len == ~(size_t) 0)
+   len = 0;
+   size = sizeof(wkba)+len;
+   assert(size <= VAR_MAX);
+
+   return siz

MonetDB: geo - attempt to create ST_InteriorRings

2014-08-26 Thread Foteini Alvanaki
Changeset: af48dc29c457 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=af48dc29c457
Modified Files:
geom/monetdb5/geom.c
geom/monetdb5/geom.mal
geom/sql/40_geom.sql
Branch: geo
Log Message:

attempt to create ST_InteriorRings


diffs (144 lines):

diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -162,6 +162,7 @@ geom_export str wkbMakePolygon(wkb** out
 geom_export str wkbExteriorRing(wkb**, wkb**);
 geom_export str wkbInteriorRingN(wkb**, wkb**, short*);
 geom_export str wkbNumRings(int*, wkb**, int*);
+geom_export str wkbInteriorRings(int* outBAT_id, wkb** geomWKB);
 geom_export str wkbIsClosed(bit *out, wkb **geom);
 geom_export str wkbIsRing(bit *out, wkb **geom);
 geom_export str wkbIsValid(bit *out, wkb **geom);
@@ -2262,13 +2263,13 @@ str wkbInteriorRingN(wkb **interiorRingW
 
if (!geosGeometry) { 
*interiorRingWKB = wkb_nil;
-   throw(MAL, "geom.interiorRing", "wkb2geos failed");
+   throw(MAL, "geom.interiorRingN", "wkb2geos failed");
}
 
-   if (GEOSGeomTypeId(geosGeometry) != GEOS_POLYGON) {
+   if ((GEOSGeomTypeId(geosGeometry)+1) != wkbPolygon) {
*interiorRingWKB = wkb_nil;
GEOSGeom_destroy(geosGeometry);
-   throw(MAL, "geom.interiorRing", "Geometry not a Polygon");
+   throw(MAL, "geom.interiorRingN", "Geometry not a Polygon");
 
}
 
@@ -2285,13 +2286,82 @@ str wkbInteriorRingN(wkb **interiorRingW
throw(MAL, "geom.interiorRingN", "GEOSGetInteriorRingN failed. 
Not enough interior rings");
}
 
-   /* get the exterior ring of the geometry */ 
+   /* get the interior ring of the geometry */ 
interiorRingGeometry = GEOSGetInteriorRingN(geosGeometry, *ringNum);
+   if (!interiorRingGeometry) { 
+   *interiorRingWKB = wkb_nil;
+   throw(MAL, "geom.interiorRingN", "GEOSGetInteriorRingN failed");
+   }
/* get the wkb representation of it */
*interiorRingWKB = geos2wkb(interiorRingGeometry);
+
+   return MAL_SUCCEED;
+}
+
+str wkbInteriorRings(int* outBAT_id, wkb** geomWKB) {
+   BAT* outBAT;
+   int interiorRingsNum = 0, i=0;
+   GEOSGeom geosGeometry;
+   str ret = MAL_SUCCEED;
+fprintf(stderr, "in wkbInteriorRings");
+
+   if (wkb_isnil(*geomWKB)) {
+   throw(MAL, "geom.InteriorRings", "Null input geometry");
+   }
+
+   geosGeometry = wkb2geos(*geomWKB);
+
+   if(!geosGeometry) {
+   throw(MAL, "geom.InteriorRings", "Error in wkb2geos");
+   }

-   return MAL_SUCCEED;
-
+   if ((GEOSGeomTypeId(geosGeometry)+1) != wkbPolygon) {
+   GEOSGeom_destroy(geosGeometry);
+   throw(MAL, "geom.interiorRings", "Geometry not a Polygon");
+
+   }
+
+   ret = wkbNumRings(&interiorRingsNum, geomWKB, &i);
+
+   if(ret != MAL_SUCCEED) {
+   GEOSGeom_destroy(geosGeometry);
+   throw(MAL, "geom.InteriorRings", "Error in wkbNumRings");
+   }
+
+   //create a new BAT for the output
+   if ((outBAT = BATnew(TYPE_void, ATOMindex("wkb"), interiorRingsNum, 
TRANSIENT)) == NULL) {
+   GEOSGeom_destroy(geosGeometry);
+   throw(MAL, "batgeom.Contains", MAL_MALLOC_FAIL);
+   }
+   //set the first idx of the output BAT equal to that of the aBAT
+   BATseqbase(outBAT, 0);
+
+
+   for (i = 0; i < interiorRingsNum; i++) { 
+   const GEOSGeometry* interiorRingGeometry;
+   wkb* interiorRingWKB;
+
+   /* get the interior ring of the geometry */ 
+   interiorRingGeometry = GEOSGetInteriorRingN(geosGeometry, i);
+   if (!interiorRingGeometry) { 
+   interiorRingWKB = wkb_nil;
+   throw(MAL, "geom.InteriorRings", "GEOSGetInteriorRingN 
failed");
+   }
+   /* get the wkb representation of it */
+   interiorRingWKB = geos2wkb(interiorRingGeometry);
+   if(!interiorRingWKB) {
+   BBPreleaseref(outBAT->batCacheid);
+   throw(MAL, "geom.InteriorRings", "Error in wkb2geos");
+   }
+
+   BUNappend(outBAT,&interiorRingWKB,TRUE); //add the result to 
the outBAT
+   }
+
+   //set some properties of the new BAT
+   BATsettrivprop(outBAT);
+   BATderiveProps(outBAT,FALSE);
+   BBPkeepref(*outBAT_id = outBAT->batCacheid);
+   
return MAL_SUCCEED;
 }
 
diff --git a/geom/monetdb5/geom.mal b/geom/monetdb5/geom.mal
--- a/geom/monetdb5/geom.mal
+++ b/geom/monetdb5/geom.mal
@@ -429,6 +429,9 @@ geom.prelude();
 
 module batgeom;
 
+command InteriorRings(w:wkb) :bat[:oid,:wkb] address wkbInteriorRings
+comment "Returns a table with all the interior rings of the polygon";
+
 command ContainsFilt