Changeset: 93a4399e15c1 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=93a4399e15c1
Added Files:
        monetdb5/modules/mal/Tests/arrange00.mal
        monetdb5/modules/mal/Tests/arrange00.stable.err
        monetdb5/modules/mal/Tests/arrange00.stable.out
        monetdb5/modules/mal/arrange.c
        monetdb5/modules/mal/arrange.h
        monetdb5/modules/mal/arrange.mal
Modified Files:
        clients/Tests/exports.stable.out
        monetdb5/mal/mal_resolve.c
        monetdb5/modules/mal/Makefile.ag
        monetdb5/modules/mal/Tests/All
        monetdb5/modules/mal/Tests/inspect05.stable.out
        monetdb5/modules/mal/Tests/inspect05.stable.out.int128
        monetdb5/modules/mal/mal_init.mal
Branch: leftmart
Log Message:

Experimental code
Small project of Lefteris and Martin


diffs (truncated from 431 to 300 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -805,6 +805,8 @@ str ALGtsort_rev(bat *result, const bat 
 str ALGtunion(bat *result, const bat *lid, const bat *rid);
 str ALGvariance(dbl *res, const bat *bid);
 str ALGvariancep(dbl *res, const bat *bid);
+str ARNGcreate(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
+str ARNGmerge(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str AUTHaddUser(oid *ret, Client *c, str *user, str *pass);
 str AUTHchangePassword(Client *c, str *oldpass, str *passwd);
 str AUTHchangeUsername(Client *c, str *olduser, str *newuser);
diff --git a/monetdb5/mal/mal_resolve.c b/monetdb5/mal/mal_resolve.c
--- a/monetdb5/mal/mal_resolve.c
+++ b/monetdb5/mal/mal_resolve.c
@@ -660,7 +660,7 @@ typeChecker(stream *out, Module scope, M
                        if (!silent) {
                                char *errsig;
 
-                               errsig = instruction2str(mb,0,p,(LIST_MAL_NAME 
| LIST_MAL_TYPE | LIST_MAL_VALUE));
+                               errsig = instruction2str(mb,0,p,LIST_MAL_ALL );
                                showScriptException(out, mb, getPC(mb, p), TYPE,
                                                                        
"'%s%s%s' undefined in: %s",
                                                                        
(getModuleId(p) ? getModuleId(p) : ""),
diff --git a/monetdb5/modules/mal/Makefile.ag b/monetdb5/modules/mal/Makefile.ag
--- a/monetdb5/modules/mal/Makefile.ag
+++ b/monetdb5/modules/mal/Makefile.ag
@@ -25,6 +25,7 @@ lib_mal = {
                factories.c factories.h \
                groupby.c groupby.h \
                inspect.c inspect.h \
+               arrange.c arrange.h \
                iterator.c  iterator.h \
                joinpath.c  joinpath.h \
                language.c language.h \
@@ -56,7 +57,7 @@ headers_mal = {
        HEADERS = mal
        DIR = libdir/monetdb5
        SOURCES = language.mal mal_init.mal bbp.mal \
-               profiler.mal batExtensions.mal \
+               profiler.mal batExtensions.mal arrange.mal \
                inspect.mal manual.mal mal_io.mal mkey.mal manifold.mal \
                iterator.mal clients.mal \
                factories.mal groupby.mal mdb.mal pcre.mal mat.mal \
@@ -85,7 +86,7 @@ headers_hge = {
 
 EXTRA_DIST = batExtensions.mal iterator.mal \
        groupby.mal mal_init.mal manual.mal mkey.mal manifold.mal pcre.mal \
-       profiler.mal recycle.mal remote.mal sabaoth.mal \
+       profiler.mal recycle.mal remote.mal sabaoth.mal arrange.mal \
        transaction.mal txtsim.mal tablet.mal tablet.h sample.mal json_util.mal 
\
        mal_mapi.mal mat.mal tokenizer.mal \
        batmtime.mal querylog.mal sysmon.mal \
diff --git a/monetdb5/modules/mal/Tests/All b/monetdb5/modules/mal/Tests/All
--- a/monetdb5/modules/mal/Tests/All
+++ b/monetdb5/modules/mal/Tests/All
@@ -81,3 +81,5 @@ clients-getpasswd
 pqueue
 pqueue2
 pqueue3
+
+arrange00
diff --git a/monetdb5/modules/mal/Tests/arrange00.mal 
b/monetdb5/modules/mal/Tests/arrange00.mal
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mal/Tests/arrange00.mal
@@ -0,0 +1,12 @@
+# create sorted oid arrangement 
+
+bv:= bat.new(:oid,:int);
+barrier v:= 0:int;
+       w:= mmath.rand();
+    bat.append(bv,w);
+    redo v:= iterator.next(1:int,10:int);
+exit v;
+
+io.print(bv);
+
+bat.arrange(bv,3);
diff --git a/monetdb5/modules/mal/Tests/arrange00.stable.err 
b/monetdb5/modules/mal/Tests/arrange00.stable.err
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mal/Tests/arrange00.stable.err
@@ -0,0 +1,30 @@
+stderr of test 'arrange00` in directory 'monetdb5/modules/mal` itself:
+
+
+# 20:25:42 >  
+# 20:25:42 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=37874" "--set" 
"mapi_usock=/var/tmp/mtest-19995/.s.monetdb.37874" "--set" "monet_prompt=" 
"--forcemito" "--set" "mal_listing=2" 
"--dbpath=/export/scratch1/mk/leftmart//Linux/var/MonetDB/mTests_monetdb5_modules_mal"
 "arrange00.mal"
+# 20:25:42 >  
+
+# builtin opt  gdk_dbpath = 
/export/scratch1/mk/leftmart//Linux/var/monetdb5/dbfarm/demo
+# builtin opt  gdk_debug = 0
+# builtin opt  gdk_vmtrim = no
+# builtin opt  monet_prompt = >
+# builtin opt  monet_daemon = no
+# builtin opt  mapi_port = 50000
+# builtin opt  mapi_open = false
+# builtin opt  mapi_autosense = false
+# builtin opt  sql_optimizer = default_pipe
+# builtin opt  sql_debug = 0
+# cmdline opt  gdk_nr_threads = 0
+# cmdline opt  mapi_open = true
+# cmdline opt  mapi_port = 37874
+# cmdline opt  mapi_usock = /var/tmp/mtest-19995/.s.monetdb.37874
+# cmdline opt  monet_prompt = 
+# cmdline opt  mal_listing = 2
+# cmdline opt  gdk_dbpath = 
/export/scratch1/mk/leftmart//Linux/var/MonetDB/mTests_monetdb5_modules_mal
+# cmdline opt  gdk_debug = 536870922
+
+# 20:25:42 >  
+# 20:25:42 >  "Done."
+# 20:25:42 >  
+
diff --git a/monetdb5/modules/mal/Tests/arrange00.stable.out 
b/monetdb5/modules/mal/Tests/arrange00.stable.out
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mal/Tests/arrange00.stable.out
@@ -0,0 +1,66 @@
+stdout of test 'arrange00` in directory 'monetdb5/modules/mal` itself:
+
+
+# 20:25:42 >  
+# 20:25:42 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=37874" "--set" 
"mapi_usock=/var/tmp/mtest-19995/.s.monetdb.37874" "--set" "monet_prompt=" 
"--forcemito" "--set" "mal_listing=2" 
"--dbpath=/export/scratch1/mk/leftmart//Linux/var/MonetDB/mTests_monetdb5_modules_mal"
 "arrange00.mal"
+# 20:25:42 >  
+
+# MonetDB 5 server v11.20.0
+# This is an unreleased version
+# Serving database 'mTests_monetdb5_modules_mal', using 8 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs and 128bit 
integers dynamically linked
+# Found 15.590 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2015 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://vienna.ins.cwi.nl:37874/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-19995/.s.monetdb.37874
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+function user.main():void;
+# create sorted oid arrangement  
+    bv := bat.new(:oid,:int);
+barrier v := 0:int;
+    w := mmath.rand();
+    bat.append(bv,w);
+    redo v := iterator.next(1:int,10:int);
+exit v;
+    io.print(bv);
+    bat.arrange(bv,3);
+end user.main;
+#--------------------------#
+# h    t  # name
+# void int  # type
+#--------------------------#
+[ 0@0, 1487234864  ]
+[ 1@0, 1592400937  ]
+[ 2@0, 701036934  ]
+[ 3@0, 1760828847  ]
+[ 4@0, 967339068  ]
+[ 5@0, 769106223  ]
+[ 6@0, 490462704  ]
+[ 7@0, 237432659  ]
+[ 8@0, 814072936  ]
+[ 9@0, 394304748  ]
+#bat.arrange pieces 3
+&1 0 11 1 11
+% .explain # table_name
+% mal # name
+% clob # type
+% 96 # length
+
+
+
+
+
+
+
+
+
+
+
+
+# 20:25:42 >  
+# 20:25:42 >  "Done."
+# 20:25:42 >  
+
diff --git a/monetdb5/modules/mal/Tests/inspect05.stable.out 
b/monetdb5/modules/mal/Tests/inspect05.stable.out
--- a/monetdb5/modules/mal/Tests/inspect05.stable.out
+++ b/monetdb5/modules/mal/Tests/inspect05.stable.out
@@ -38,10 +38,13 @@ end user.main;
 # t    t       t       t       t  # name
 # str  str     str     str     str  # type
 #--------------------------#
+[ "append",    "pattern",      "bat",  
"(bv:bat[:oid,:any_1],l:bat[:oid,:oid]...):void ",      "ARNGmerge;"  ]
+[ "append",    "pattern",      "bat",  
"(bv:bat[:oid,:any_1],pieces:int):bat[:oid,:any_1] ",   "ARNGcreate;"  ]
+[ "append",    "pattern",      "bat",  "(bv:bat[:oid,:any_1]):void ",  
"ARNGcreate;"  ]
 [ "append",    "command",      "bat",  
"(i:bat[:oid,:any_1],u:any_1):bat[:oid,:any_1] ",       "BKCappend_val_wrap;"  ]
-[ "append",    "command",      "bat",  "(tt:int,heapfile:str):bat[:oid,:any_1] 
",      "BKCattach;"  ]
-[ "append",    "command",      "bat",  
"(i:bat[:oid,:any_1],u:any_1,force:bit):bat[:oid,:any_1] ",     
"BKCappend_val_force_wrap;"  ]
-[ "append",    "command",      "bat",  
"(i:bat[:oid,:any_1],u:bat[:oid,:any_1],force:bit):bat[:oid,:any_1] ",  
"BKCappend_force_wrap;"  ]
+[ "arrange",   "command",      "bat",  "(tt:int,heapfile:str):bat[:oid,:any_1] 
",      "BKCattach;"  ]
+[ "arrange",   "command",      "bat",  
"(i:bat[:oid,:any_1],u:any_1,force:bit):bat[:oid,:any_1] ",     
"BKCappend_val_force_wrap;"  ]
+[ "arrange",   "command",      "bat",  
"(i:bat[:oid,:any_1],u:bat[:oid,:any_1],force:bit):bat[:oid,:any_1] ",  
"BKCappend_force_wrap;"  ]
 [ "attach",    "command",      "bat",  
"(i:bat[:oid,:any_1],u:bat[:oid,:any_1]):bat[:oid,:any_1] ",    
"BKCappend_wrap;"  ]
 [ "delete",    "command",      "bat",  "(sz:wrd):bat[:oid,:oid] ",     
"BKCdensebat;"  ]
 [ "delete",    "command",      "bat",  
"(b:bat[:oid,:any_1],src:bat[:oid,:any_1]):bat[:oid,:any_1] ",  
"BKCdelete_bat_bun;"  ]
diff --git a/monetdb5/modules/mal/Tests/inspect05.stable.out.int128 
b/monetdb5/modules/mal/Tests/inspect05.stable.out.int128
--- a/monetdb5/modules/mal/Tests/inspect05.stable.out.int128
+++ b/monetdb5/modules/mal/Tests/inspect05.stable.out.int128
@@ -38,10 +38,13 @@ end user.main;
 # t    t       t       t       t  # name
 # str  str     str     str     str  # type
 #--------------------------#
+[ "append",    "pattern",      "bat",  
"(bv:bat[:oid,:any_1],l:bat[:oid,:oid]...):void ",      "ARNGmerge;"  ]
+[ "append",    "pattern",      "bat",  
"(bv:bat[:oid,:any_1],pieces:int):bat[:oid,:any_1] ",   "ARNGcreate;"  ]
+[ "append",    "pattern",      "bat",  "(bv:bat[:oid,:any_1]):void ",  
"ARNGcreate;"  ]
 [ "append",    "command",      "bat",  
"(i:bat[:oid,:any_1],u:any_1):bat[:oid,:any_1] ",       "BKCappend_val_wrap;"  ]
-[ "append",    "command",      "bat",  "(tt:int,heapfile:str):bat[:oid,:any_1] 
",      "BKCattach;"  ]
-[ "append",    "command",      "bat",  
"(i:bat[:oid,:any_1],u:any_1,force:bit):bat[:oid,:any_1] ",     
"BKCappend_val_force_wrap;"  ]
-[ "append",    "command",      "bat",  
"(i:bat[:oid,:any_1],u:bat[:oid,:any_1],force:bit):bat[:oid,:any_1] ",  
"BKCappend_force_wrap;"  ]
+[ "arrange",   "command",      "bat",  "(tt:int,heapfile:str):bat[:oid,:any_1] 
",      "BKCattach;"  ]
+[ "arrange",   "command",      "bat",  
"(i:bat[:oid,:any_1],u:any_1,force:bit):bat[:oid,:any_1] ",     
"BKCappend_val_force_wrap;"  ]
+[ "arrange",   "command",      "bat",  
"(i:bat[:oid,:any_1],u:bat[:oid,:any_1],force:bit):bat[:oid,:any_1] ",  
"BKCappend_force_wrap;"  ]
 [ "attach",    "command",      "bat",  
"(i:bat[:oid,:any_1],u:bat[:oid,:any_1]):bat[:oid,:any_1] ",    
"BKCappend_wrap;"  ]
 [ "delete",    "command",      "bat",  "(sz:wrd):bat[:oid,:oid] ",     
"BKCdensebat;"  ]
 [ "delete",    "command",      "bat",  
"(b:bat[:oid,:any_1],src:bat[:oid,:any_1]):bat[:oid,:any_1] ",  
"BKCdelete_bat_bun;"  ]
diff --git a/monetdb5/modules/mal/arrange.c b/monetdb5/modules/mal/arrange.c
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mal/arrange.c
@@ -0,0 +1,133 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+/*
+ * (c) Martin Kersten
+ * Implement a parallel sort-merge MAL program generator
+ */
+#include "monetdb_config.h"
+#include "arrange.h"
+
+str
+ARNGcreate(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+       int pieces = 3;
+       int i, loopvar, bid, arg;
+       BUN cnt, step=0,o;
+       MalBlkPtr smb;
+       MalStkPtr newstk;
+       Symbol snew;
+       InstrPtr q, pack;
+       BAT *b;
+       char name[IDLENGTH];
+       str msg= MAL_SUCCEED;
+
+       if( pci->argc == 3){
+               pieces = stk->stk[pci->argv[2]].val.ival;
+       } else {
+               // educated guess needed on number of partitions
+       }
+#ifdef _DEBUG_INDEX_
+       mnstr_printf(cntxt->fdout,"#bat.arrange pieces %d\n",pieces);
+#endif
+
+       if( pieces <0)
+               throw(MAL,"bat.arrange","Positive number expected");
+
+       bid= *getArgReference_bat(stk, pci,1);
+       b= BATdescriptor(bid);
+       if( b == NULL)
+               throw(MAL,"bat.arrange",RUNTIME_OBJECT_MISSING);
+
+       // create a temporary MAL function
+       snprintf(name,IDLENGTH,"sort%d",rand() % 1000);
+       snew= newFunction(putName("user",4), putName(name, strlen(name)), 
FUNCTIONsymbol);
+       smb=  snew->def;
+       q= getInstrPtr(smb, 0);
+       arg = newTmpVariable(smb, getArgType(mb,pci,1)) ;
+       pushArgument(smb, q, arg);
+       getArg(q,0)=  newTmpVariable(smb, TYPE_void);
+
+       resizeMalBlk(smb, 2* pieces +10, 2 * pieces + 10); // large enough
+       // create the pack instruction first, as it will hold intermediate 
variables
+       pack = newInstruction(0,ASSIGNsymbol);
+       setModuleId(pack,putName("bat",3));
+       setFunctionId(pack,putName("arrange",7));
+       pack->argv[0]= newTmpVariable(smb, TYPE_void);
+       pack = pushArgument(smb,pack, arg);
+       setVarFixed(smb,getArg(pack,0));
+
+       // the costly part executed as a parallel block
+       loopvar = newTmpVariable(smb,TYPE_bit);
+       q = newStmt(smb,putName("language",8),putName("dataflow",8));
+       q->barrier= BARRIERsymbol;
+       q->argv[0]= loopvar;
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to