Changeset: 87133fb1d118 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=87133fb1d118
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:

Tile aggregation
The basic structure for aggregation over tiles. It still needs a
proper check on the boundaries for the dimensions.


diffs (truncated from 352 to 300 lines):

diff --git a/monetdb5/modules/mal/Tests/array04.mal 
b/monetdb5/modules/mal/Tests/array04.mal
--- a/monetdb5/modules/mal/Tests/array04.mal
+++ b/monetdb5/modules/mal/Tests/array04.mal
@@ -2,15 +2,36 @@
 
 #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);
+vv:= array.series(0,1,6,1,1);
 io.print(v,vv);
 
-#construct the tiles [0:1:2]
-template:= bat.new(:oid,:oid);
+#select sum(V) from V group by V[0:1:2]
 template:= array.series(0@0,1@0,2@0,1,1);
 io.print(template);
 
-g:= array.tiling(vv,template);
+g:= array.tiles(vv,template);
 io.print(g);
-io.print(g,vv);
 
+gs:= array.sum(vv,template);
+io.print(gs);
+
+
+#create array M(x int dimension[0:1:4], y int dimension[0:1:4], int default 1);
+mx:= array.series(0,1,4,4,1);
+my:= array.series(0,1,4,1,4);
+mv:= array.series(0,1,16,1,1);
+io.print(mx,my,mv);
+
+#select sum(M) from M group by M[0:1:2][0:1:2]
+t0:= array.series(0,1,2,2,1);
+t1:= array.series(0,1,2,1,2);
+io.print(t0,t1);
+
+template:= array.map(mx,my,t0,t1);
+io.print(template);
+
+g:= array.tiles(mv,template);
+io.print(g);
+
+gs:= array.sum(mv,template);
+io.print(gs);
diff --git a/monetdb5/modules/mal/Tests/array04.stable.err 
b/monetdb5/modules/mal/Tests/array04.stable.err
deleted file mode 100644
--- a/monetdb5/modules/mal/Tests/array04.stable.err
+++ /dev/null
@@ -1,31 +0,0 @@
-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
deleted file mode 100644
--- a/monetdb5/modules/mal/Tests/array04.stable.out
+++ /dev/null
@@ -1,85 +0,0 @@
-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
@@ -86,14 +86,18 @@
 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
+pattern tiles(cells:bat[:oid,:any_1], template:bat[:oid,:oid]):bat[:oid,:oid]
+address ARRAYtiles
 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";
 
+pattern sum(cells:bat[:oid,:any_1], template:bat[:oid,:oid]):bat[:oid,:any_2]
+address ARRAYtilesSum
+comment "Construct the sum over all tiles";
+
 @- Implementation
 @include ../mal/prelude.mx
 @h
@@ -126,10 +130,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_export str ARRAYtiles(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+array_export str ARRAYtilesSum(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);
+array_export str ARRAYtilesSum_@1(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 @h
 @:array_defs(oid)@
 @:array_defs(sht)@
@@ -154,22 +160,6 @@
 
 
/*----------------------------------------------------------------------------*/
 
-
-@= array_impl
-array_export str ARRAYseries_@1(int *ret, @1 *start, @1 *step, @1 *stop, int 
*grp, int *series);
-
-@c
-@:array_impl(sht,"%d")@
-@:array_impl(int,"%d")@
-@:array_impl(lng,LLFMT)@
-@:array_impl(flt,"%f")@
-@:array_impl(dbl,"%f")@
-@-
-To be dealt with differently
-@:array_impl(date,"%s")@
-@:array_impl(daytime,"%s")@
-@:array_impl(timestamp,"%s")@
-
 @c
 #include "mal.h"
 #include "mal_interpreter.h"
@@ -537,33 +527,34 @@
        return MAL_SUCCEED;
 }
 
-
 str
-ARRAYtiling(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+ARRAYtiles(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;
+       oid g = 0, limit;
 
        (void) cntxt;
        (void) mb;
        if ((b = BATdescriptor(*(int*)getArgReference(stk,pci,1))) == NULL) 
-               throw(MAL, "array.tiling", RUNTIME_OBJECT_MISSING);
+               throw(MAL, "array.tiles", RUNTIME_OBJECT_MISSING);
        if ((bt = BATdescriptor(*(int*)getArgReference(stk,pci,2))) == NULL) {
                BBPreleaseref(b->batCacheid);
-               throw(MAL, "array.tiling", RUNTIME_OBJECT_MISSING);
+               throw(MAL, "array.tiles", RUNTIME_OBJECT_MISSING);
        }
        bn = BATnew(TYPE_oid, TYPE_oid, TRUE);
        bi = bat_iterator(b);
        br = bat_iterator(bt);
+       limit= BATcount(b);
        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);
+                       oid o = g + *(oid*) BUNhead(br,r);
+                       if ( o < limit)
+                               BUNins(bn, &g, &o, TRUE);
                }
        }
        BBPkeepref(*ret = bn->batCacheid);
@@ -572,6 +563,77 @@
        return MAL_SUCCEED;
 }
 
+@= tilesAggr
+str
+ARRAYtilesSum_@1(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,z;
+       oid g = 0, limit;
+       @1 sum, elm;
+
+       (void) cntxt;
+       (void) mb;
+       if ((b = BATdescriptor(*(int*)getArgReference(stk,pci,1))) == NULL) 
+               throw(MAL, "array.tiles", RUNTIME_OBJECT_MISSING);
+       if ((bt = BATdescriptor(*(int*)getArgReference(stk,pci,2))) == NULL) {
+               BBPreleaseref(b->batCacheid);
+               throw(MAL, "array.tiles", RUNTIME_OBJECT_MISSING);
+       }
+       bn = BATnew(TYPE_oid, TYPE_@1, TRUE);
+       bi = bat_iterator(b);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to