Changeset: 20bc37c2ea29 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=20bc37c2ea29
Added Files:
monetdb5/extras/jaql/Tests/group02.mal
monetdb5/extras/jaql/Tests/group02.stable.err
monetdb5/extras/jaql/Tests/group02.stable.out
monetdb5/extras/jaql/Tests/join03.mal
monetdb5/extras/jaql/Tests/join03.stable.err
monetdb5/extras/jaql/Tests/join03.stable.out
Modified Files:
monetdb5/extras/jaql/Tests/All
monetdb5/extras/jaql/Tests/json05.stable.out
monetdb5/extras/jaql/jaqlfunc.mal
monetdb5/extras/jaql/jaqlgencode.c
monetdb5/extras/jaql/json.c
monetdb5/extras/jaql/json.mal
sql/server/rel_select.c
sql/storage/bat/bat_utils.c
sql/storage/bat/bat_utils.h
sql/storage/store.c
Branch: default
Log Message:
Merge with Jul2012 branch.
diffs (truncated from 1251 to 300 lines):
diff --git a/monetdb5/extras/jaql/Tests/All b/monetdb5/extras/jaql/Tests/All
--- a/monetdb5/extras/jaql/Tests/All
+++ b/monetdb5/extras/jaql/Tests/All
@@ -11,7 +11,9 @@ HAVE_JAQL?transform00
HAVE_JAQL?transform02
HAVE_JAQL?join00
HAVE_JAQL?join02
+HAVE_JAQL?join03
HAVE_JAQL?group00
+HAVE_JAQL?group02
HAVE_JAQL?sort00
HAVE_JAQL?top00
HAVE_JAQL?variable00
diff --git a/monetdb5/extras/jaql/Tests/group02.mal
b/monetdb5/extras/jaql/Tests/group02.mal
new file mode 100644
--- /dev/null
+++ b/monetdb5/extras/jaql/Tests/group02.mal
@@ -0,0 +1,17 @@
+# various bugs in the group(functions) code
+
+#disabled: works in progress
+
+# should return 0
+jaql.x("[]->group into count($);");
+# only works when the groupkey exists for all elements
+jaql.x("[{\"a\": 1}, {\"a\": 2}]->group by d = $.a into count($);");
+#jaql.x("explain [{\"a\": 1}, {\"a\": 2}, {\"b\": 1}]->group by d = $.a into
count($);");
+# should return 0 for groups with no matching values
+#jaql.x("[{\"a\": 1, \"b\": 5}, {\"a\": 2}]->group by d = $.a into {d,
\"s\":sum($[*].b)};");
+#jaql.x("[{\"a\": 1}, {\"a\": 2}, {\"b\": 1}]->group by d = $.a into {d,
\"c\":count($[*].a)};");
+#jaql.x("[{\"a\": 1}, {\"a\": 2}, {\"b\": 1}]->group by d = $.a into {d,
\"c\":count($[*].b)};");
+
+jaql.x("[[],[1,2]] -> transform {\"cnt\": count($)};");
+jaql.x("[[],[1,2]] -> transform {\"sum\": sum($)};");
+jaql.x("[[],[1,2]] -> transform {\"avg\": avg($)};");
diff --git a/monetdb5/extras/jaql/Tests/group02.stable.err
b/monetdb5/extras/jaql/Tests/group02.stable.err
new file mode 100644
--- /dev/null
+++ b/monetdb5/extras/jaql/Tests/group02.stable.err
@@ -0,0 +1,31 @@
+stderr of test 'group02` in directory 'extras/jaql` itself:
+
+
+# 21:11:05 >
+# 21:11:05 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"gdk_dbfarm=/net/sofia.ins.cwi.nl/export/scratch1/fabian/tmp/mtest-Jul2012-sofia.ins.cwi.nl/five/dbfarm"
"--set" "mapi_open=true" "--set" "mapi_port=33103" "--set" "monet_prompt="
"--trace" "--forcemito" "--set" "mal_listing=2" "--dbname=mTests_extras_jaql"
"group02.mal"
+# 21:11:05 >
+
+# builtin opt gdk_dbname = demo
+# builtin opt gdk_dbfarm =
/ufs/fabian/scratch/ssd/monetdb/Jul2012/program-x86_64/var/lib/monetdb5/dbfarm
+# builtin opt gdk_debug = 0
+# builtin opt gdk_alloc_map = no
+# builtin opt gdk_vmtrim = yes
+# 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 gdk_dbfarm =
/net/sofia.ins.cwi.nl/export/scratch1/fabian/tmp/mtest-Jul2012-sofia.ins.cwi.nl/five/dbfarm
+# cmdline opt mapi_open = true
+# cmdline opt mapi_port = 33103
+# cmdline opt monet_prompt =
+# cmdline opt mal_listing = 2
+# cmdline opt gdk_dbname = mTests_extras_jaql
+
+# 21:11:06 >
+# 21:11:06 > "Done."
+# 21:11:06 >
+
diff --git a/monetdb5/extras/jaql/Tests/group02.stable.out
b/monetdb5/extras/jaql/Tests/group02.stable.out
new file mode 100644
--- /dev/null
+++ b/monetdb5/extras/jaql/Tests/group02.stable.out
@@ -0,0 +1,45 @@
+stdout of test 'group02` in directory 'extras/jaql` itself:
+
+
+# 21:11:05 >
+# 21:11:05 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"gdk_dbfarm=/net/sofia.ins.cwi.nl/export/scratch1/fabian/tmp/mtest-Jul2012-sofia.ins.cwi.nl/five/dbfarm"
"--set" "mapi_open=true" "--set" "mapi_port=33103" "--set" "monet_prompt="
"--trace" "--forcemito" "--set" "mal_listing=2" "--dbname=mTests_extras_jaql"
"group02.mal"
+# 21:11:05 >
+
+# MonetDB 5 server v11.11.6 "Jul2012-a04c99a2b437"
+# Serving database 'mTests_extras_jaql', using 8 threads
+# Compiled for x86_64-pc-linux-gnu/64bit with 64bit OIDs dynamically linked
+# Found 15.629 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2012 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://sofia.ins.cwi.nl:33103/
+# MonetDB/GIS module loaded
+# MonetDB/JAQL module loaded
+# MonetDB/SQL module loaded
+# MonetDB/DataCell loaded
+function user.main():void;
+# various bugs in the group(functions) code
+#disabled: works in progress
+# should return 0
+ jaql.x("[]->group into count($);");
+# only works when the groupkey exists for all elements
+ jaql.x("[{\"a\": 1}, {\"a\": 2}]->group by d = $.a into count($);");
+#jaql.x("explain [{\"a\": 1}, {\"a\": 2}, {\"b\": 1}]->group by d = $.a into
count($);");
+# should return 0 for groups with no matching values
+#jaql.x("[{\"a\": 1, \"b\": 5}, {\"a\": 2}]->group by d = $.a into {d,
\"s\":sum($[*].b)};");
+#jaql.x("[{\"a\": 1}, {\"a\": 2}, {\"b\": 1}]->group by d = $.a into {d,
\"c\":count($[*].a)};");
+#jaql.x("[{\"a\": 1}, {\"a\": 2}, {\"b\": 1}]->group by d = $.a into {d,
\"c\":count($[*].b)};");
+ jaql.x("[[],[1,2]] -> transform {\"cnt\": count($)};");
+ jaql.x("[[],[1,2]] -> transform {\"sum\": sum($)};");
+ jaql.x("[[],[1,2]] -> transform {\"avg\": avg($)};");
+end main;
+[ 0 ]
+[ 1, 1 ]
+[ { "cnt": 0 }, { "cnt": 2 } ]
+[ { "sum": null }, { "sum": 3 } ]
+[ { "avg": null }, { "avg": 1.500000 } ]
+
+# 21:11:06 >
+# 21:11:06 > "Done."
+# 21:11:06 >
+
diff --git a/monetdb5/extras/jaql/Tests/join03.mal
b/monetdb5/extras/jaql/Tests/join03.mal
new file mode 100644
--- /dev/null
+++ b/monetdb5/extras/jaql/Tests/join03.mal
@@ -0,0 +1,10 @@
+# identified a bug in preserve, preserving all inputs lead to no
+# preservation at all, which in turn yielded in unexpected results for
+# the co-group function
+
+jaql.x("A=[1,2];");
+jaql.x("B=[{\"a\":1,\"b\":4},{\"a\":1,\"b\":5}];");
+jaql.x("join preserve A, B where A == B.a into {B.*, A};");
+jaql.x("join preserve A, preserve B where A == B.a into {B.*, A};");
+jaql.x("join A, preserve B where A == B.a into {B.*, A};");
+jaql.x("group A by g = $ as ga, B by g = $.a as gb into { \"grp\" : g,
\"cnt\": count(gb) };");
diff --git a/monetdb5/extras/jaql/Tests/join03.stable.err
b/monetdb5/extras/jaql/Tests/join03.stable.err
new file mode 100644
--- /dev/null
+++ b/monetdb5/extras/jaql/Tests/join03.stable.err
@@ -0,0 +1,31 @@
+stderr of test 'join03` in directory 'extras/jaql` itself:
+
+
+# 09:27:06 >
+# 09:27:06 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"gdk_dbfarm=/net/sofia.ins.cwi.nl/export/scratch1/fabian/tmp/mtest-Jul2012-sofia.ins.cwi.nl/five/dbfarm"
"--set" "mapi_open=true" "--set" "mapi_port=39104" "--set" "monet_prompt="
"--trace" "--forcemito" "--set" "mal_listing=2" "--dbname=mTests_extras_jaql"
"join03.mal"
+# 09:27:06 >
+
+# builtin opt gdk_dbname = demo
+# builtin opt gdk_dbfarm =
/ufs/fabian/scratch/ssd/monetdb/Jul2012/program-x86_64/var/lib/monetdb5/dbfarm
+# builtin opt gdk_debug = 0
+# builtin opt gdk_alloc_map = no
+# builtin opt gdk_vmtrim = yes
+# 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 gdk_dbfarm =
/net/sofia.ins.cwi.nl/export/scratch1/fabian/tmp/mtest-Jul2012-sofia.ins.cwi.nl/five/dbfarm
+# cmdline opt mapi_open = true
+# cmdline opt mapi_port = 39104
+# cmdline opt monet_prompt =
+# cmdline opt mal_listing = 2
+# cmdline opt gdk_dbname = mTests_extras_jaql
+
+# 09:27:06 >
+# 09:27:06 > "Done."
+# 09:27:06 >
+
diff --git a/monetdb5/extras/jaql/Tests/join03.stable.out
b/monetdb5/extras/jaql/Tests/join03.stable.out
new file mode 100644
--- /dev/null
+++ b/monetdb5/extras/jaql/Tests/join03.stable.out
@@ -0,0 +1,34 @@
+stdout of test 'join03` in directory 'extras/jaql` itself:
+
+
+# 09:27:06 >
+# 09:27:06 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"gdk_dbfarm=/net/sofia.ins.cwi.nl/export/scratch1/fabian/tmp/mtest-Jul2012-sofia.ins.cwi.nl/five/dbfarm"
"--set" "mapi_open=true" "--set" "mapi_port=39104" "--set" "monet_prompt="
"--trace" "--forcemito" "--set" "mal_listing=2" "--dbname=mTests_extras_jaql"
"join03.mal"
+# 09:27:06 >
+
+# MonetDB 5 server v11.11.6 "Jul2012-a04c99a2b437"
+# Serving database 'mTests_extras_jaql', using 8 threads
+# Compiled for x86_64-pc-linux-gnu/64bit with 64bit OIDs dynamically linked
+# Found 15.629 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2012 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://sofia.ins.cwi.nl:39104/
+# MonetDB/GIS module loaded
+# MonetDB/JAQL module loaded
+# MonetDB/SQL module loaded
+# MonetDB/DataCell loaded
+function user.main():void;
+ jaql.x("A=[1,2];");
+ jaql.x("B=[{\"a\":1,\"b\":4},{\"a\":1,\"b\":5}];");
+ jaql.x("join preserve A, B where A == B.a into {B.*, A};");
+ jaql.x("join preserve A, preserve B where A == B.a into {B.*, A};");
+ jaql.x("join A, preserve B where A == B.a into {B.*, A};");
+end main;
+[ { "a": 1, "b": 4, "A": 1 }, { "a": 1, "b": 5, "A": 1 }, { "A": 2 } ]
+[ { "a": 1, "b": 4, "A": 1 }, { "a": 1, "b": 5, "A": 1 }, { "A": 2 } ]
+[ { "a": 1, "b": 4, "A": 1 }, { "a": 1, "b": 5, "A": 1 } ]
+
+# 09:27:06 >
+# 09:27:06 > "Done."
+# 09:27:06 >
+
diff --git a/monetdb5/extras/jaql/Tests/json05.stable.out
b/monetdb5/extras/jaql/Tests/json05.stable.out
--- a/monetdb5/extras/jaql/Tests/json05.stable.out
+++ b/monetdb5/extras/jaql/Tests/json05.stable.out
@@ -51,7 +51,7 @@ end main;
[ 0@0, 0 ]
[ 0@0, 1 ]
[ 0@0, 2 ]
-[ 0@0, nil ]
+[ 0@0, 0 ]
[ 0@0, 4 ]
[ "dbl" ]
#---------------------------------#
@@ -61,7 +61,7 @@ end main;
[ 0@0, 1 ]
[ 0@0, 1 ]
[ 0@0, 2.2999999999999998 ]
-[ 0@0, nil ]
+[ 0@0, inf ]
[ 0@0, 4 ]
[ "str" ]
#---------------------------------#
@@ -70,7 +70,7 @@ end main;
#---------------------------------#
[ 0@0, "long('1')" ]
[ 0@0, "double('2.300000')" ]
-[ 0@0, nil ]
+[ 0@0, "(null)" ]
[ 0@0, "long('4')" ]
[ 0@0, "4" ]
[ 0@0, "bool('true')" ]
diff --git a/monetdb5/extras/jaql/jaqlfunc.mal
b/monetdb5/extras/jaql/jaqlfunc.mal
--- a/monetdb5/extras/jaql/jaqlfunc.mal
+++ b/monetdb5/extras/jaql/jaqlfunc.mal
@@ -92,11 +92,15 @@ end shred
# perform sum over the input array
function sum(v:bat[:oid,:lng]):bat[:oid,:lng];
k := algebra.kunique(v);
+ p := algebra.uselect(v, nil:lng);
+ v := algebra.kdifference(v, p);
r:bat[:oid,:lng] := aggr.sum(v, k);
return r;
end sum;
function sum(v:bat[:oid,:dbl]):bat[:oid,:dbl];
k := algebra.kunique(v);
+ p := algebra.uselect(v, nil:dbl);
+ v := algebra.kdifference(v, p);
r:bat[:oid,:dbl] := aggr.sum(v, k);
return r;
end sum;
@@ -104,11 +108,15 @@ end sum;
# perform average over the input array
function avg(v:bat[:oid,:lng]):bat[:oid,:dbl];
k := algebra.kunique(v);
+ p := algebra.uselect(v, nil:lng);
+ v := algebra.kdifference(v, p);
r := aggr.avg(v, k);
return r;
end avg;
function avg(v:bat[:oid,:dbl]):bat[:oid,:dbl];
k := algebra.kunique(v);
+ p := algebra.uselect(v, nil:dbl);
+ v := algebra.kdifference(v, p);
r := aggr.avg(v, k);
return r;
end avg;
@@ -116,6 +124,7 @@ end avg;
# perform count over the input array
function count(v:bat[:oid,:any]):bat[:oid,:lng];
k := algebra.kunique(v);
+ v := algebra.antiuselect(v, nil);
x := aggr.count(v, k, false);
r := batcalc.lng(x);
return r;
diff --git a/monetdb5/extras/jaql/jaqlgencode.c
b/monetdb5/extras/jaql/jaqlgencode.c
--- a/monetdb5/extras/jaql/jaqlgencode.c
+++ b/monetdb5/extras/jaql/jaqlgencode.c
@@ -51,6 +51,16 @@ typedef struct _jgvar {
#define MAXJAQLARG 23
+#ifdef JAQL_ANNOTATE_MALPLANS
+#define MALCOMMENT(mb, X, ...) { \
+ char _comment_buf[1024]; \
+ snprintf(_comment_buf, sizeof(_comment_buf), X, ##__VA_ARGS__); \
+ (void)newComment(mb, _comment_buf); \
+}
+#else
+#define MALCOMMENT(mb, X, ...)
+#endif
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list