Changeset: e06f9ca778bc for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e06f9ca778bc
Modified Files:
        monetdb5/modules/kernel/algebra.mx
        monetdb5/tests/BugTracker/Tests/All
        monetdb5/tests/BugTracker/Tests/algebra_project.Bug-3045.mal
        monetdb5/tests/BugTracker/Tests/algebra_project.Bug-3045.stable.err
        monetdb5/tests/BugTracker/Tests/algebra_project.Bug-3045.stable.out
Branch: Dec2011
Log Message:

Reuse implementation in GDK for algebra.project + add test for bug 3045.
algebra.project does basically what BATconst does, so use that to do
the work.
Thid also fixes bug 3045.


diffs (201 lines):

diff --git a/monetdb5/modules/kernel/algebra.mx 
b/monetdb5/modules/kernel/algebra.mx
--- a/monetdb5/modules/kernel/algebra.mx
+++ b/monetdb5/modules/kernel/algebra.mx
@@ -3695,51 +3695,37 @@ ALGprojectNIL(int *ret, int *bid)
  * The constant versions are typed by the parser
  */
 @= projectImpl
-str ALGprojecthead_@1(int *ret,ptr *val, int *bid){
+str
+ALGprojecthead_@1(int *ret,ptr *val, int *bid)
+{
        BAT *b, *bn;
-       BUN p,q;
-       BATiter bi;
 
        @:getBATdescriptor(bid,b,"batcalc.project")@
 
-       bn= BATnew(TYPE_@1,BATttype(b),BATcount(b));
+       b = BATmirror(b);
+       bn = BATconst(b, TYPE_@1, val);
+       bn = BATmirror(bn);
+
        @:tstBAT("algebra.project")@
-       bi = bat_iterator(b);
-       BATaccessBegin(b,USE_TAIL,MMAP_SEQUENTIAL);
-       BATloop(b, p, q) {
-               ptr v = BUNtail(bi,p);
-               bunfastins(bn, val,v);
-       }
-       bn->H->nonil = (ATOMcmp(bn->htype, val, ATOMnilptr(bn->htype))); 
-       bn->T->nonil = b->T->nonil;
-bunins_failed:
-       BATaccessEnd(b,USE_TAIL,MMAP_SEQUENTIAL);
-       if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ); \
+       if (!(bn->batDirty&2))
+               bn = BATsetaccess(bn, BAT_READ);
        *ret= bn->batCacheid;
        BBPkeepref(bn->batCacheid);
        BBPreleaseref(b->batCacheid);
        return MAL_SUCCEED;
 }
-str ALGprojecttail_@1(int *ret,int *bid, ptr *val){
+str
+ALGprojecttail_@1(int *ret,int *bid, ptr *val)
+{
        BAT *b, *bn;
-       BUN p,q;
-       BATiter bi;
 
        @:getBATdescriptor(bid,b,"batcalc.project")@
 
-       bn= BATnew(BAThtype(b),TYPE_@1,BATcount(b));
+       bn = BATconst(b, TYPE_@1, val);
+
        @:tstBAT("algebra.project")@
-       bi = bat_iterator(b);
-       BATaccessBegin(b,USE_HEAD,MMAP_SEQUENTIAL);
-       BATloop(b, p, q) {
-               ptr v = BUNhead(bi,p);
-               bunfastins(bn,v, val);
-       }
-       bn->H->nonil = b->H->nonil;
-       bn->T->nonil = (ATOMcmp(bn->ttype, val, ATOMnilptr(bn->ttype))); 
-bunins_failed:
-       BATaccessEnd(b,USE_HEAD,MMAP_SEQUENTIAL);
-       if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ); \
+       if (!(bn->batDirty&2))
+               bn = BATsetaccess(bn, BAT_READ);
        *ret= bn->batCacheid;
        BBPkeepref(bn->batCacheid);
        BBPreleaseref(b->batCacheid);
diff --git a/monetdb5/tests/BugTracker/Tests/All 
b/monetdb5/tests/BugTracker/Tests/All
--- a/monetdb5/tests/BugTracker/Tests/All
+++ b/monetdb5/tests/BugTracker/Tests/All
@@ -9,3 +9,4 @@ parser.SF-2051309
 mal_var_persistent_over_sessions.SF-2581675
 merge-join_properties.SF-2952191
 joinpath-loop.Bug-2965
+algebra_project.Bug-3045
diff --git a/monetdb5/tests/BugTracker/Tests/algebra_project.Bug-3045.mal 
b/monetdb5/tests/BugTracker/Tests/algebra_project.Bug-3045.mal
new file mode 100644
--- /dev/null
+++ b/monetdb5/tests/BugTracker/Tests/algebra_project.Bug-3045.mal
@@ -0,0 +1,12 @@
+b := bat.new(:oid, :bte);
+b := bat.append(b, 100:bte);
+b := bat.append(b, 105:bte);
+b := bat.append(b, 100:bte);
+b := bat.append(b, 105:bte);
+b := bat.append(b, 115:bte);
+io.print(b);
+c := algebra.project(0@0,b);
+io.print(c);
+d := bat.reverse(b);
+e := algebra.project(d,0@0);
+io.print(e);
diff --git 
a/monetdb5/tests/BugTracker/Tests/algebra_project.Bug-3045.stable.err 
b/monetdb5/tests/BugTracker/Tests/algebra_project.Bug-3045.stable.err
new file mode 100644
--- /dev/null
+++ b/monetdb5/tests/BugTracker/Tests/algebra_project.Bug-3045.stable.err
@@ -0,0 +1,31 @@
+stderr of test 'algebra_project.Bug-3045` in directory 'tests/BugTracker` 
itself:
+
+
+# 13:21:49 >  
+# 13:21:49 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"gdk_dbfarm=/ufs/sjoerd/Monet-stable/var/MonetDB" "--set" "mapi_open=true" 
"--set" "mapi_port=39429" "--set" "monet_prompt=" "--trace" "--forcemito" 
"--set" "mal_listing=2" "--dbname=mTests_tests_BugTracker" 
"algebra_project.Bug-3045.mal"
+# 13:21:49 >  
+
+# builtin opt  gdk_dbname = demo
+# builtin opt  gdk_dbfarm = /ufs/sjoerd/Monet-stable/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/sjoerd/Monet-stable/var/MonetDB
+# cmdline opt  mapi_open = true
+# cmdline opt  mapi_port = 39429
+# cmdline opt  monet_prompt = 
+# cmdline opt  mal_listing = 2
+# cmdline opt  gdk_dbname = mTests_tests_BugTracker
+
+# 13:21:49 >  
+# 13:21:49 >  "Done."
+# 13:21:49 >  
+
diff --git 
a/monetdb5/tests/BugTracker/Tests/algebra_project.Bug-3045.stable.out 
b/monetdb5/tests/BugTracker/Tests/algebra_project.Bug-3045.stable.out
new file mode 100644
--- /dev/null
+++ b/monetdb5/tests/BugTracker/Tests/algebra_project.Bug-3045.stable.out
@@ -0,0 +1,64 @@
+stdout of test 'algebra_project.Bug-3045` in directory 'tests/BugTracker` 
itself:
+
+
+# 13:21:49 >  
+# 13:21:49 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"gdk_dbfarm=/ufs/sjoerd/Monet-stable/var/MonetDB" "--set" "mapi_open=true" 
"--set" "mapi_port=39429" "--set" "monet_prompt=" "--trace" "--forcemito" 
"--set" "mal_listing=2" "--dbname=mTests_tests_BugTracker" 
"algebra_project.Bug-3045.mal"
+# 13:21:49 >  
+
+# MonetDB 5 server v11.7.8 (hg id: 8594feb8b79b+)
+# This is an unreleased version
+# Serving database 'mTests_tests_BugTracker', using 8 threads
+# Compiled for x86_64-unknown-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://madrid.ins.cwi.nl:39429/
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+function user.main():void;
+    b := bat.new(:oid,:bte);
+    b := bat.append(b,100:bte);
+    b := bat.append(b,105:bte);
+    b := bat.append(b,100:bte);
+    b := bat.append(b,105:bte);
+    b := bat.append(b,115:bte);
+    io.print(b);
+    c := algebra.project(0@0,b);
+    io.print(c);
+    d := bat.reverse(b);
+    e := algebra.project(d,0@0);
+    io.print(e);
+end main;
+#-----------------#
+# h    t         # name
+# void bte       # type
+#-----------------#
+[ 0@0,   100     ]
+[ 1@0,   105     ]
+[ 2@0,   100     ]
+[ 3@0,   105     ]
+[ 4@0,   115     ]
+#-----------------#
+# t    h         # name
+# oid  bte       # type
+#-----------------#
+[ 0@0,   100     ]
+[ 0@0,   105     ]
+[ 0@0,   100     ]
+[ 0@0,   105     ]
+[ 0@0,   115     ]
+#-----------------#
+# h    t         # name
+# bte  oid       # type
+#-----------------#
+[ 100,   0@0     ]
+[ 105,   0@0     ]
+[ 100,   0@0     ]
+[ 105,   0@0     ]
+[ 115,   0@0     ]
+
+# 13:21:49 >  
+# 13:21:49 >  "Done."
+# 13:21:49 >  
+
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to