Changeset: 3e042f7482d2 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3e042f7482d2
Added Files:
        monetdb5/extras/jaql/jaqltests/Tests/documents.jaql
        monetdb5/extras/jaql/jaqltests/Tests/documents.stable.err
        monetdb5/extras/jaql/jaqltests/Tests/documents.stable.out
Modified Files:
        monetdb5/extras/jaql/jaqlfunc.mal
        monetdb5/extras/jaql/jaqltests/Tests/All
Branch: Oct2012
Log Message:

jaql: add test for store/load/drop


diffs (193 lines):

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
@@ -126,6 +126,36 @@ function drop(docname:str)(kind:bat[:oid
        return (r1,r2,r3,r4,r5,r6,r7);
 end drop;
 
+# show all stored documents
+function 
list()(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]);
+       bats := bbp.getNames();
+       docs := pcre.select("json_.*_kind", bats);
+
+       jdocs := batstr.string(docs, 5);
+
+       # in the future we could try to list some info about the document
+       # here, like size
+
+       r1 := bat.new(:oid,:bte);
+       #r2 := bat.new(:oid,:str);
+       r3 := bat.new(:oid,:lng);
+       r4 := bat.new(:oid,:dbl);
+       #r5 := bat.new(:oid,:oid);
+       r6 := bat.new(:oid,:oid);
+       r7 := bat.new(:oid,:str);
+
+       r1 := bat.insert(r1, 0@0, 97:bte); # a
+       r2 := algebra.markH(jdocs, 1@0);
+
+       t1 := algebra.project(r2, 115:bte); # s
+       r1 := bat.insert(r1, t1);
+       
+       t2 := algebra.project(r2, 0@0);
+       r5 := bat.reverse(t2);
+
+       return (r1,r2,r3,r4,r5,r6,r7);
+end list();
+
 # produce a JSON document with trace information
 function 
gettrace()(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);
diff --git a/monetdb5/extras/jaql/jaqltests/Tests/All 
b/monetdb5/extras/jaql/jaqltests/Tests/All
--- a/monetdb5/extras/jaql/jaqltests/Tests/All
+++ b/monetdb5/extras/jaql/jaqltests/Tests/All
@@ -8,3 +8,4 @@ HAVE_JAQL?sort
 HAVE_JAQL?transform
 HAVE_JAQL?shred
 HAVE_JAQL?in
+HAVE_JAQL?documents
diff --git a/monetdb5/extras/jaql/jaqltests/Tests/documents.jaql 
b/monetdb5/extras/jaql/jaqltests/Tests/documents.jaql
new file mode 100644
--- /dev/null
+++ b/monetdb5/extras/jaql/jaqltests/Tests/documents.jaql
@@ -0,0 +1,23 @@
+# shouldn't exist
+load("doctest");
+
+# create one
+[1,2.0,"drie"] -> store("doctest");
+
+# re-retrieve it
+load("doctest");
+
+# drop it again
+drop("doctest");
+
+# hence, shouldn't exist any more
+load("doctest");
+
+# and we can store another thing under that name
+[4,5,6] -> store("doctest");
+
+# verify it's another document
+load("doctest");
+
+# cleanup
+drop("doctest");
diff --git a/monetdb5/extras/jaql/jaqltests/Tests/documents.stable.err 
b/monetdb5/extras/jaql/jaqltests/Tests/documents.stable.err
new file mode 100644
--- /dev/null
+++ b/monetdb5/extras/jaql/jaqltests/Tests/documents.stable.err
@@ -0,0 +1,42 @@
+stderr of test 'documents` in directory 'extras/jaql/jaqltests` itself:
+
+
+# 09:19:01 >  
+# 09:19:01 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"gdk_dbfarm=/Volumes/Scratch/MonetDB/Oct2012/mtest-Phoebe.lan/five/dbfarm" 
"--set" "mapi_open=true" "--set" "mapi_port=31818" "--set" "monet_prompt=" 
"--trace" "--forcemito" "--set" "mal_listing=2" 
"--dbname=mTests_extras_jaql_jaqltests" "--set" "mal_listing=0"
+# 09:19:01 >  
+
+# builtin opt  gdk_dbname = demo
+# builtin opt  gdk_dbfarm = 
/Volumes/Scratch/MonetDB/Oct2012/program-i386/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 = 
/Volumes/Scratch/MonetDB/Oct2012/mtest-Phoebe.lan/five/dbfarm
+# cmdline opt  mapi_open = true
+# cmdline opt  mapi_port = 31818
+# cmdline opt  monet_prompt = 
+# cmdline opt  mal_listing = 2
+# cmdline opt  gdk_dbname = mTests_extras_jaql_jaqltests
+# cmdline opt  mal_listing = 0
+
+# 09:19:01 >  
+# 09:19:01 >  "mclient" "-ljaql" "-ftest" "-Eutf-8" "-i" "-e" "--host=Phoebe" 
"--port=31818"
+# 09:19:01 >  
+
+MAPI  = monetdb@Phoebe:31818
+QUERY = load("doctest");
+ERROR = !no such JSON object with name: doctest
+MAPI  = monetdb@Phoebe:31818
+QUERY = load("doctest");
+ERROR = !no such JSON object with name: doctest
+
+# 09:19:01 >  
+# 09:19:01 >  "Done."
+# 09:19:01 >  
+
diff --git a/monetdb5/extras/jaql/jaqltests/Tests/documents.stable.out 
b/monetdb5/extras/jaql/jaqltests/Tests/documents.stable.out
new file mode 100644
--- /dev/null
+++ b/monetdb5/extras/jaql/jaqltests/Tests/documents.stable.out
@@ -0,0 +1,65 @@
+stdout of test 'documents` in directory 'extras/jaql/jaqltests` itself:
+
+
+# 09:19:01 >  
+# 09:19:01 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"gdk_dbfarm=/Volumes/Scratch/MonetDB/Oct2012/mtest-Phoebe.lan/five/dbfarm" 
"--set" "mapi_open=true" "--set" "mapi_port=31818" "--set" "monet_prompt=" 
"--trace" "--forcemito" "--set" "mal_listing=2" 
"--dbname=mTests_extras_jaql_jaqltests" "--set" "mal_listing=0"
+# 09:19:01 >  
+
+# MonetDB 5 server v11.13.2 "Oct2012-08b31d1252ae"
+# Serving database 'mTests_extras_jaql_jaqltests', using 2 threads
+# Compiled for i686-apple-darwin9/32bit with 32bit OIDs dynamically linked
+# Found 2.000 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://Phoebe.lan:31818/
+# MonetDB/JAQL module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 09:19:01 >  
+# 09:19:01 >  "mclient" "-ljaql" "-ftest" "-Eutf-8" "-i" "-e" "--host=Phoebe" 
"--port=31818"
+# 09:19:01 >  
+
+#[1,2.0,"drie"] -> store("doctest");
+% .json # table_name
+% json # name
+% clob # type
+% 4 # length
+true
+#load("doctest");
+% .json # table_name
+% json # name
+% clob # type
+% 23 # length
+[ 1, 2.000000, "drie" ]
+#drop("doctest");
+% .json # table_name
+% json # name
+% clob # type
+% 4 # length
+true
+#[4,5,6] -> store("doctest");
+% .json # table_name
+% json # name
+% clob # type
+% 4 # length
+true
+#load("doctest");
+% .json # table_name
+% json # name
+% clob # type
+% 11 # length
+[ 4, 5, 6 ]
+#drop("doctest");
+% .json # table_name
+% json # name
+% clob # type
+% 4 # length
+true
+
+# 09:19:01 >  
+# 09:19:01 >  "Done."
+# 09:19:01 >  
+
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to