Changeset: a2caff28f0c3 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a2caff28f0c3
Added Files:
        monetdb5/extras/jaql/jaqltests/Tests/calculations.jaql
        monetdb5/extras/jaql/jaqltests/Tests/calculations.stable.err
        monetdb5/extras/jaql/jaqltests/Tests/calculations.stable.out
Modified Files:
        HowToStart.rst
        monetdb5/extras/jaql/Tests/func00.mal
        monetdb5/extras/jaql/Tests/func00.stable.out
        monetdb5/extras/jaql/jaqlfunc.mal
        monetdb5/extras/jaql/jaqlgencode.c
        monetdb5/modules/mal/tablet.c
Branch: default
Log Message:

Merge with Oct2012 branch.


diffs (truncated from 352 to 300 lines):

diff --git a/HowToStart.rst b/HowToStart.rst
--- a/HowToStart.rst
+++ b/HowToStart.rst
@@ -164,8 +164,7 @@ development sources on your computer.
  hg clone http://dev.monetdb.org/hg/MonetDB
 
 This will create the directory MonetDB in your current working directory
-with underneath all subcomponents.  Then first follow the instructions
-in ``buildtools/README`` before continuing with the others.
+with underneath all subcomponents.  
 
 
 Bootstrap, Configure and Make
diff --git a/monetdb5/extras/jaql/Tests/func00.mal 
b/monetdb5/extras/jaql/Tests/func00.mal
--- a/monetdb5/extras/jaql/Tests/func00.mal
+++ b/monetdb5/extras/jaql/Tests/func00.mal
@@ -1,3 +1,6 @@
 # test of "native" functions (all inputs/outputs are json arrays)
 jaql.x("arrayToRecord([\"DEF\", \"ABC\"], [123, 456]);");
 jaql.x("arrayToRecord([\"DEF\", \"ABC\"], [456]);");
+
+jaql.x("pairwise([\"DEF\", \"ABC\"], [123, 456]);");
+jaql.x("pairwise([\"DEF\", \"ABC\"], [456]);");
diff --git a/monetdb5/extras/jaql/Tests/func00.stable.out 
b/monetdb5/extras/jaql/Tests/func00.stable.out
--- a/monetdb5/extras/jaql/Tests/func00.stable.out
+++ b/monetdb5/extras/jaql/Tests/func00.stable.out
@@ -20,9 +20,13 @@ function user.main():void;
 # test of "native" functions (all inputs/outputs are json arrays) 
     jaql.x("arrayToRecord([\"DEF\", \"ABC\"], [123, 456]);");
     jaql.x("arrayToRecord([\"DEF\", \"ABC\"], [456]);");
+    jaql.x("pairwise([\"DEF\", \"ABC\"], [123, 456]);");
+    jaql.x("pairwise([\"DEF\", \"ABC\"], [456]);");
 end main;
 { "DEF": 123, "ABC": 456 }
 { "DEF": 456, "ABC": null }
+[ [ "DEF", 123 ], [ "ABC", 456 ] ]
+[ [ "DEF", 456 ], [ "ABC", null ] ]
 
 # 21:34:47 >  
 # 21:34:47 >  "Done."
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
@@ -20,6 +20,7 @@ module jaqlfunc;
 
 
 # generate a JSON record by merging two JSON arrays
+# http://code.google.com/p/jaql/wiki/Builtin_functions#arrayToRecord()
 function 
arrayToRecord(kindn:bat[:oid,:bte],stringn:bat[:oid,:str],integern:bat[:oid,:lng],doublen:bat[:oid,:dbl],arrayn:bat[:oid,:oid],objectn:bat[:oid,:oid],namen:bat[:oid,:str],kindv:bat[:oid,:bte],stringv:bat[:oid,:str],integerv:bat[:oid,:lng],doublev:bat[:oid,:dbl],arrayv:bat[:oid,:oid],objectv:bat[:oid,:oid],namev:bat[:oid,:str])(kind:bat[:oid,:bte],string:bat[:oid,:str],integer:bat[:oid,:lng],double:bat[:oid,:dbl],array:bat[:oid,:oid],object:bat[:oid,:oid],name:bat[:oid,:str]);
        r1 := bat.new(:oid,:bte);
        r2 := bat.new(:oid,:str);
@@ -78,6 +79,56 @@ function arrayToRecord(kindn:bat[:oid,:b
        return (r1,r2,r3,r4,r5,r6,r7);
 end arrayToRecord;
 
+# combine two arrays (A,B) into one array C
+# http://code.google.com/p/jaql/wiki/Builtin_functions#pairwise()
+function 
pairwise(kindn:bat[:oid,:bte],stringn:bat[:oid,:str],integern:bat[:oid,:lng],doublen:bat[:oid,:dbl],arrayn:bat[:oid,:oid],objectn:bat[:oid,:oid],namen:bat[:oid,:str],kindv:bat[:oid,:bte],stringv:bat[:oid,:str],integerv:bat[:oid,:lng],doublev:bat[:oid,:dbl],arrayv:bat[:oid,:oid],objectv:bat[:oid,:oid],namev:bat[:oid,:str])(kind:bat[:oid,:bte],string:bat[:oid,:str],integer:bat[:oid,:lng],double:bat[:oid,:dbl],array:bat[:oid,:oid],object:bat[:oid,:oid],name:bat[:oid,:str]);
+       nextid := json.nextid(kindn);
+
+       # re-base second json to be appended to the first
+       elems := algebra.selectH(arrayv, 0@0);
+       (v1,v2,v3,v4,v5,v6,v7) := json.extract(kindv, stringv, integerv, 
doublev, arrayv, objectv, namev, elems, nextid);
+
+       u1 := bat.insert(kindn, v1);
+       u2 := bat.insert(stringn, v2);
+       u3 := bat.insert(integern, v3);
+       u4 := bat.insert(doublen, v4);
+       u5 := bat.insert(arrayn, v5);
+       u6 := bat.insert(objectn, v6);
+       u7 := bat.insert(namen, v7);
+
+       # construct arrays with values from n and v, the size of n is
+       # leading, that is, we pad with nulls on v, but don't pad nulls on n
+       # when v is larger
+       elemsn := algebra.selectH(u5, 0@0);
+       elemsv := algebra.selectH(u5, nextid);
+
+       nullid := json.nextid(u1);
+       u1 := bat.insert(u1, nullid, 110:bte);  # n
+
+       nextid := json.nextid(u1);
+
+       t1 := algebra.project(elemsn, 97:bte);  # a
+       t2 := algebra.markH(t1, nextid);
+
+       t3 := algebra.markH(elemsn, nextid);
+       t4 := algebra.markH(elemsv, nextid);
+
+       # find size mismatch between t3 and t4, and pad with nulls
+       d := algebra.kdifference(t3, t4);
+       dn := algebra.project(d, nullid);
+       t4 := bat.insert(t4, dn);
+
+       u1 := bat.insert(u1, t2);
+       u5 := bat.insert(u5, t3);
+       u5 := bat.insert(u5, t4);
+
+       t6 := bat.mirror(t2);
+
+       (r1,r2,r3,r4,r5,r6,r7) := json.extract(u1,u2,u3,u4,u5,u6,u7, t6, 0@0);
+
+       return (r1,r2,r3,r4,r5,r6,r7);
+end pairwise;
+
 # read JSON data from URI
 function 
shred(uri:str)(kind:bat[:oid,:bte],string:bat[:oid,:str],integer:bat[:oid,:lng],double:bat[:oid,:dbl],array:bat[:oid,:oid],object:bat[:oid,:oid],name:bat[:oid,:str]);
        (r1,r2,r3,r4,r5,r6,r7) := json.shreduri(uri);
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
@@ -7087,6 +7087,17 @@ dumptree(jc *j, Client cntxt, MalBlkPtr 
                                                                        
assert(0);
                                                        }
                                                        break;
+                                               case j_var:
+                                                       dumpgetvar(mb, 
w->tval1->sval,
+                                                                       &a1, 
&a2, &a3, &a4, &a5, &a6, &a7);
+                                                       dynaarg[i][0] = a1;
+                                                       dynaarg[i][1] = a2;
+                                                       dynaarg[i][2] = a3;
+                                                       dynaarg[i][3] = a4;
+                                                       dynaarg[i][4] = a5;
+                                                       dynaarg[i][5] = a6;
+                                                       dynaarg[i][6] = a7;
+                                                       break;
                                                case j_str:
                                                case j_num:
                                                case j_dbl:
@@ -7144,8 +7155,6 @@ dumptree(jc *j, Client cntxt, MalBlkPtr 
                                                        pushInstruction(mb, q);
                                                        dynaarg[i][0] = a;
                                                        break;
-                                               case j_var: /* TODO */
-                                                       /* j_var is actually 
impossible at this level */
                                                default:
                                                        snprintf(j->err, 
sizeof(j->err),
                                                                        
"unhandled argument type (1)");
@@ -7177,6 +7186,7 @@ dumptree(jc *j, Client cntxt, MalBlkPtr 
                                                switch (coltypes[i]) {
                                                        case j_json:
                                                        case j_json_arr:
+                                                       case j_var:
                                                                q = 
pushArgument(mb, q, dynaarg[i][0]);
                                                                q = 
pushArgument(mb, q, dynaarg[i][1]);
                                                                q = 
pushArgument(mb, q, dynaarg[i][2]);
diff --git a/monetdb5/extras/jaql/jaqltests/Tests/calculations.jaql 
b/monetdb5/extras/jaql/jaqltests/Tests/calculations.jaql
new file mode 100644
--- /dev/null
+++ b/monetdb5/extras/jaql/jaqltests/Tests/calculations.jaql
@@ -0,0 +1,33 @@
+# some simple "direct" calculations (calculated compile-time)
+[ 1 ] -> transform 1 + 1;
+[ 1 ] -> transform 5 / 2;
+[ 1 ] -> transform 2 * 6;
+[ 1 ] -> transform 4.1 / 2.1;
+[ 1 ] -> transform 5 - 2.1;
+
+A = [
+       1,
+       5,
+       2,
+       4.1,
+       5,
+];
+
+B = [
+       1,
+       2,
+       6,
+       2.1,
+       2.1,
+];
+
+AB = pairwise(A, B) -> transform {"A": $[0], "B": $[1]};
+AB;
+
+# some runtime evaluated queries
+A -> transform $ / 2;
+B -> transform 10 / $;
+AB -> transform $.A / $.B;
+AB -> transform $.A * $.B;
+AB -> transform $.A + $.B;
+AB -> transform $.A - $.B;
diff --git a/monetdb5/extras/jaql/jaqltests/Tests/calculations.stable.err 
b/monetdb5/extras/jaql/jaqltests/Tests/calculations.stable.err
new file mode 100644
--- /dev/null
+++ b/monetdb5/extras/jaql/jaqltests/Tests/calculations.stable.err
@@ -0,0 +1,36 @@
+stderr of test 'calculations` in directory 'extras/jaql/jaqltests` itself:
+
+
+# 21:20:59 >  
+# 21:20:59 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"gdk_dbfarm=/net/sofia.ins.cwi.nl/export/scratch1/fabian/tmp/mtest-Oct2012-sofia.ins.cwi.nl/five/dbfarm"
 "--set" "mapi_open=true" "--set" "mapi_port=30176" "--set" "monet_prompt=" 
"--trace" "--forcemito" "--set" "mal_listing=2" 
"--dbname=mTests_extras_jaql_jaqltests" "--set" "mal_listing=0"
+# 21:20:59 >  
+
+# builtin opt  gdk_dbname = demo
+# builtin opt  gdk_dbfarm = 
/ufs/fabian/scratch/ssd/monetdb/Oct2012/program-x86_64/var/lib/monetdb5/dbfarm
+# builtin opt  gdk_debug = 0
+# 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-Oct2012-sofia.ins.cwi.nl/five/dbfarm
+# cmdline opt  mapi_open = true
+# cmdline opt  mapi_port = 30176
+# cmdline opt  monet_prompt = 
+# cmdline opt  mal_listing = 2
+# cmdline opt  gdk_dbname = mTests_extras_jaql_jaqltests
+# cmdline opt  mal_listing = 0
+
+# 21:20:59 >  
+# 21:20:59 >  "mclient" "-ljaql" "-ftest" "-Eutf-8" "-i" "-e" "--host=sofia" 
"--port=30176"
+# 21:20:59 >  
+
+
+# 21:20:59 >  
+# 21:20:59 >  "Done."
+# 21:20:59 >  
+
diff --git a/monetdb5/extras/jaql/jaqltests/Tests/calculations.stable.out 
b/monetdb5/extras/jaql/jaqltests/Tests/calculations.stable.out
new file mode 100644
--- /dev/null
+++ b/monetdb5/extras/jaql/jaqltests/Tests/calculations.stable.out
@@ -0,0 +1,110 @@
+stdout of test 'calculations` in directory 'extras/jaql/jaqltests` itself:
+
+
+# 21:20:59 >  
+# 21:20:59 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"gdk_dbfarm=/net/sofia.ins.cwi.nl/export/scratch1/fabian/tmp/mtest-Oct2012-sofia.ins.cwi.nl/five/dbfarm"
 "--set" "mapi_open=true" "--set" "mapi_port=30176" "--set" "monet_prompt=" 
"--trace" "--forcemito" "--set" "mal_listing=2" 
"--dbname=mTests_extras_jaql_jaqltests" "--set" "mal_listing=0"
+# 21:20:59 >  
+
+# MonetDB 5 server v11.13.4 "Oct2012-3a365170cd97"
+# Serving database 'mTests_extras_jaql_jaqltests', 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:30176/
+# MonetDB/GIS module loaded
+# MonetDB/JAQL module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 21:20:59 >  
+# 21:20:59 >  "mclient" "-ljaql" "-ftest" "-Eutf-8" "-i" "-e" "--host=sofia" 
"--port=30176"
+# 21:20:59 >  
+
+## some simple "direct" calculations (calculated compile-time)
+#[ 1 ] -> transform 1 + 1;
+% .json # table_name
+% json # name
+% clob # type
+% 5 # length
+[ 2 ]
+#[ 1 ] -> transform 5 / 2;
+% .json # table_name
+% json # name
+% clob # type
+% 5 # length
+[ 2 ]
+#[ 1 ] -> transform 2 * 6;
+% .json # table_name
+% json # name
+% clob # type
+% 6 # length
+[ 12 ]
+#[ 1 ] -> transform 4.1 / 2.1;
+% .json # table_name
+% json # name
+% clob # type
+% 12 # length
+[ 1.952381 ]
+#[ 1 ] -> transform 5 - 2.1;
+% .json # table_name
+% json # name
+% clob # type
+% 12 # length
+[ 2.900000 ]
+#AB;
+% .json # table_name
+% json # name
+% clob # type
+% 35 # length
+[
+  { "A": 1, "B": 1 },
+  { "A": 5, "B": 2 },
+  { "A": 2, "B": 6 },
+  { "A": 4.100000, "B": 2.100000 },
+  { "A": 5, "B": 2.100000 }
+]
+## some runtime evaluated queries
+#A -> transform $ / 2;
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to