Changeset: 5645c4dcbdf6 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5645c4dcbdf6
Modified Files:
        monetdb5/modules/mal/Tests/array04.mal
        monetdb5/modules/mal/Tests/array04.stable.err
        monetdb5/modules/mal/Tests/array04.stable.out
        monetdb5/modules/mal/array.mx
Branch: sciql
Log Message:

Tiling template
The first simple vector based tiling operation.


diffs (260 lines):

diff --git a/monetdb5/modules/mal/Tests/array04.mal 
b/monetdb5/modules/mal/Tests/array04.mal
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mal/Tests/array04.mal
@@ -0,0 +1,16 @@
+# tiling operations
+
+#create array v(i int dimension[0:1:4], payload:int)
+v:= array.series(0,1,6,1,1);
+vv:= array.series(0,3,18,1,1);
+io.print(v,vv);
+
+#construct the tiles [0:1:2]
+template:= bat.new(:oid,:oid);
+template:= array.series(0@0,1@0,2@0,1,1);
+io.print(template);
+
+g:= array.tiling(vv,template);
+io.print(g);
+io.print(g,vv);
+
diff --git a/monetdb5/modules/mal/Tests/array04.stable.err 
b/monetdb5/modules/mal/Tests/array04.stable.err
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mal/Tests/array04.stable.err
@@ -0,0 +1,31 @@
+stderr of test 'array04` in directory 'modules/mal` itself:
+
+
+# 00:49:41 >  
+# 00:49:41 >   mserver5  --debug=10 --set gdk_nr_threads=0  --set 
"gdk_dbfarm=/ufs/mk/sciql//Linux/var/MonetDB" --set mapi_open=true --set 
mapi_port=35147 --set monet_prompt= --trace --forcemito --set mal_listing=2  
--dbname=mTests_modules_mal  array04.mal
+# 00:49:41 >  
+
+# builtin opt  gdk_dbname = demo
+# builtin opt  gdk_dbfarm = /ufs/mk/sciql//Linux/var/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 = /ufs/mk/sciql//Linux/var/MonetDB
+# cmdline opt  mapi_open = true
+# cmdline opt  mapi_port = 35147
+# cmdline opt  monet_prompt = 
+# cmdline opt  mal_listing = 2
+# cmdline opt  gdk_dbname = mTests_modules_mal
+
+# 00:49:41 >  
+# 00:49:41 >  Done.
+# 00:49:41 >  
+
diff --git a/monetdb5/modules/mal/Tests/array04.stable.out 
b/monetdb5/modules/mal/Tests/array04.stable.out
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mal/Tests/array04.stable.out
@@ -0,0 +1,85 @@
+stdout of test 'array04` in directory 'modules/mal` itself:
+
+
+# 00:49:41 >  
+# 00:49:41 >   mserver5  --debug=10 --set gdk_nr_threads=0  --set 
"gdk_dbfarm=/ufs/mk/sciql//Linux/var/MonetDB" --set mapi_open=true --set 
mapi_port=35147 --set monet_prompt= --trace --forcemito --set mal_listing=2  
--dbname=mTests_modules_mal  array04.mal
+# 00:49:41 >  
+
+# MonetDB 5 server v11.4.0
+# This is an unreleased version
+# Serving database 'mTests_modules_mal', using 4 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically 
linked
+# Found 7.749 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2011 MonetDB B.V., all rights reserved
+# Visit http://monetdb.cwi.nl/ for further information
+# Listening for connection requests on mapi:monetdb://eir.ins.cwi.nl:35147/
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+function user.main():void;
+# tiling operations 
+#create array v(i int dimension[0:1:4], payload:int) 
+    v := array.series(0,1,6,1,1);
+    vv := array.series(0,3,18,1,1);
+    io.print(v,vv);
+#construct the tiles [0:1:2] 
+    template := bat.new(:oid,:oid);
+    template := array.series(0@0,1@0,2@0,1,1);
+    io.print(template);
+    g := array.tiling(vv,template);
+    io.print(g);
+    io.print(g,vv);
+end main;
+#-------------------------#
+# h    t       t         # name
+# void int     int       # type
+#-------------------------#
+[ 0@0,   0,      0       ]
+[ 1@0,   1,      3       ]
+[ 2@0,   2,      6       ]
+[ 3@0,   3,      9       ]
+[ 4@0,   4,      12      ]
+[ 5@0,   5,      15      ]
+#-----------------#
+# h    t         # name
+# void oid       # type
+#-----------------#
+[ 0@0,   0@0     ]
+[ 1@0,   1@0     ]
+#-----------------#
+# h    t         # name
+# oid  oid       # type
+#-----------------#
+[ 0@0,   0@0     ]
+[ 0@0,   1@0     ]
+[ 1@0,   1@0     ]
+[ 1@0,   2@0     ]
+[ 2@0,   2@0     ]
+[ 2@0,   3@0     ]
+[ 3@0,   3@0     ]
+[ 3@0,   4@0     ]
+[ 4@0,   4@0     ]
+[ 4@0,   5@0     ]
+[ 5@0,   5@0     ]
+[ 5@0,   6@0     ]
+#-------------------------#
+# h    t       t         # name
+# oid  oid     int       # type
+#-------------------------#
+[ 0@0,   0@0,    0       ]
+[ 0@0,   1@0,    0       ]
+[ 1@0,   1@0,    3       ]
+[ 1@0,   2@0,    3       ]
+[ 2@0,   2@0,    6       ]
+[ 2@0,   3@0,    6       ]
+[ 3@0,   3@0,    9       ]
+[ 3@0,   4@0,    9       ]
+[ 4@0,   4@0,    12      ]
+[ 4@0,   5@0,    12      ]
+[ 5@0,   5@0,    15      ]
+[ 5@0,   6@0,    15      ]
+
+# 00:49:41 >  
+# 00:49:41 >  Done.
+# 00:49:41 >  
+
diff --git a/monetdb5/modules/mal/array.mx b/monetdb5/modules/mal/array.mx
--- a/monetdb5/modules/mal/array.mx
+++ b/monetdb5/modules/mal/array.mx
@@ -42,6 +42,7 @@
 
 @mal
 module array;
+@:array_mdefs(oid)@
 @:array_mdefs(sht)@
 @:array_mdefs(int)@
 @:array_mdefs(lng)@
@@ -85,6 +86,10 @@
 address ARRAYreplace
 comment "Replace values in v1 at the positions determined by idx with values 
in v2, return the modified v1.";
 
+pattern tiling(cells:bat[:oid,:any_1], template:bat[:oid,:oid]):bat[:oid,:oid]
+address ARRAYtiling
+comment "Construct the tiled cell id list using a template with relative 
offsets";
+
 command product(b:bat[:any_3,:any_1],c:bat[:any_4,:any_2]):bat[:any_1,:any_2]
 address ARRAYproduct
 comment "Produce an array product";
@@ -121,10 +126,12 @@
 array_export str ARRAYmapReverse(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr p);
 array_export str ARRAYreplace(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr p);
 array_export str ARRAYreplaceScalar(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr p);
+array_export str ARRAYtiling(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 
 @= array_defs
 array_export str ARRAYseries_@1(int *ret, @1 *start, @1 *step, @1 *stop, int 
*grp, int *series);
 @h
+@:array_defs(oid)@
 @:array_defs(sht)@
 @:array_defs(int)@
 @:array_defs(lng)@
@@ -178,7 +185,7 @@
        if ( *start < *stop && *step > 0) {
                cnt =  (BUN) ((*stop - *start) / *step) * *group * *series ;
        } else
-       if ( *start > *stop && *step < 0) {
+       if ( abs(*start) < abs(*stop) && abs(*step) > 0) {
                cnt =  (BUN) ((-*stop + *start) / *step ) * *group * *series ;
        } else
                throw(MAL, "array.series", "illegal range");
@@ -196,8 +203,7 @@
                                        *o = i;
                                        o++;
                                }
-       }
-       if ( *start > *stop && *step < 0) {
+       } else {
                for ( s = 0; s < *series; s++)
                        for ( i = *start; i > *stop; i += *step)
                                for( g = 0; g < *group; g++){
@@ -216,6 +222,7 @@
 }
 
 @c
+@:dim_wrapper_impl(oid)@
 @:dim_wrapper_impl(sht)@
 @:dim_wrapper_impl(int)@
 @:dim_wrapper_impl(lng)@
@@ -515,7 +522,7 @@
        bo = BATnew(bc->ttype, b->ttype, TRUE);
        bi = bat_iterator(bc);
        BATloop(bc,p,q){
-               oid o = *(oid*) BUNhloc(bi,p);
+               oid o = *(oid*) BUNhead(bi,p);
                BUNins(bo, &o, val, TRUE);
        }
        bn=  BATreplace(b,bo,TRUE);
@@ -530,6 +537,41 @@
        return MAL_SUCCEED;
 }
 
+
+str
+ARRAYtiling(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+       BAT *b, *bt, *bn;
+       int *ret = (int*) getArgReference(stk,pci,0);
+       BATiter bi, br;
+       BUN p,q;
+       BUN r,s;
+       oid g = 0;
+
+       (void) cntxt;
+       (void) mb;
+       if ((b = BATdescriptor(*(int*)getArgReference(stk,pci,1))) == NULL) 
+               throw(MAL, "array.tiling", RUNTIME_OBJECT_MISSING);
+       if ((bt = BATdescriptor(*(int*)getArgReference(stk,pci,2))) == NULL) {
+               BBPreleaseref(b->batCacheid);
+               throw(MAL, "array.tiling", RUNTIME_OBJECT_MISSING);
+       }
+       bn = BATnew(TYPE_oid, TYPE_oid, TRUE);
+       bi = bat_iterator(b);
+       br = bat_iterator(bt);
+       BATloop(b,p,q){
+               g = *(oid*) BUNhead(bi,p);
+               BATloop(bt,r,s){
+                       oid o = g + *(oid*) BUNtloc(br,r);
+                       BUNins(bn, &g, &o, TRUE);
+               }
+       }
+       BBPkeepref(*ret = bn->batCacheid);
+       BBPreleaseref(b->batCacheid);
+       BBPreleaseref(bt->batCacheid);
+       return MAL_SUCCEED;
+}
+
 @-
 The printing stuff is postponed to the future. Then it also needs
 a solution to the GDKout issues.
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to