Changeset: 5c90704ced87 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5c90704ced87
Removed Files:
        monetdb5/mal/Tests/tst274.stable.out.oid64
Modified Files:
        monetdb5/mal/Tests/tst273.mal
        monetdb5/mal/Tests/tst273.stable.out
        monetdb5/mal/Tests/tst274.mal
        monetdb5/mal/Tests/tst274.stable.out
        monetdb5/modules/kernel/aggr.c
Branch: default
Log Message:

Cleanup: require dense head in aggregates.


diffs (298 lines):

diff --git a/monetdb5/mal/Tests/tst273.mal b/monetdb5/mal/Tests/tst273.mal
--- a/monetdb5/mal/Tests/tst273.mal
+++ b/monetdb5/mal/Tests/tst273.mal
@@ -6,7 +6,7 @@ b:= bat.new(:oid,:lng);
 barrier i:= 0:lng;
        k:= mmath.rand();
        l:= calc.lng(k);
-       bat.insert(b,nil:oid,l);
+       bat.append(b,l);
        redo i:= iterator.next(1:lng,10000:lng);
 exit i;
 
diff --git a/monetdb5/mal/Tests/tst273.stable.out 
b/monetdb5/mal/Tests/tst273.stable.out
--- a/monetdb5/mal/Tests/tst273.stable.out
+++ b/monetdb5/mal/Tests/tst273.stable.out
@@ -27,7 +27,7 @@ function user.main():void;
 barrier i := 0:lng;
     k := mmath.rand();
     l := calc.lng(k);
-    bat.insert(b,nil:oid,l);
+    bat.append(b,l);
     redo i := iterator.next(1:lng,10000:lng);
 exit i;
     profiler.setFilter(b);
diff --git a/monetdb5/mal/Tests/tst274.mal b/monetdb5/mal/Tests/tst274.mal
--- a/monetdb5/mal/Tests/tst274.mal
+++ b/monetdb5/mal/Tests/tst274.mal
@@ -7,7 +7,7 @@ b:= bat.new(:oid,:lng);
 barrier i:= 0:lng;
        k:= mmath.rand();
        l:= calc.lng(k);
-       bat.insert(b,nil:oid,l);
+       bat.append(b,l);
        redo i:= iterator.next(1:lng,10000:lng);
 exit i;
 
diff --git a/monetdb5/mal/Tests/tst274.stable.out 
b/monetdb5/mal/Tests/tst274.stable.out
--- a/monetdb5/mal/Tests/tst274.stable.out
+++ b/monetdb5/mal/Tests/tst274.stable.out
@@ -24,7 +24,7 @@ function user.main():void;
 barrier i := 0:lng;
     k := mmath.rand();
     l := calc.lng(k);
-    bat.insert(b,nil:oid,l);
+    bat.append(b,l);
     redo i := iterator.next(1:lng,10000:lng);
 exit i;
     profiler.activate("ticks");
@@ -74,22 +74,22 @@ end main;
 # void lng       # type
 #-----------------#
 [ 0@0,   0       ]
-[ 1@0,   120000  ]
+[ 1@0, 80000  ]
 [ 2@0,   0       ]
 [ 3@0,   0       ]
-[ 4@0,   120000  ]
-[ 5@0,   120000  ]
+[ 4@0, 80000  ]
+[ 5@0, 80000  ]
 [ 6@0,   0       ]
 #-------------------------#
 # h    t       t         # name
 # void lng     lng       # type
 #-------------------------#
 [ 0@0,   0,      0       ]
-[ 1@0,   0,      120000  ]
+[ 1@0, 0,      80000  ]
 [ 2@0,   0,      0       ]
 [ 3@0,   0,      0       ]
-[ 4@0,   0,      120000  ]
-[ 5@0,   0,      120000  ]
+[ 4@0, 0,      80000  ]
+[ 5@0, 0,      80000  ]
 [ 6@0,   0,      0       ]
 
 # 17:57:29 >  
diff --git a/monetdb5/mal/Tests/tst274.stable.out.oid64 
b/monetdb5/mal/Tests/tst274.stable.out.oid64
deleted file mode 100644
--- a/monetdb5/mal/Tests/tst274.stable.out.oid64
+++ /dev/null
@@ -1,98 +0,0 @@
-stdout of test 'tst274` in directory 'monetdb5/mal` itself:
-
-
-# 17:57:28 >  
-# 17:57:28 >   mserver5 "--config=/ufs/mk/current//Linux/etc/monetdb5.conf" 
--debug=10 --set gdk_nr_threads=0 --set 
"monet_mod_path=/ufs/mk/current//Linux/lib/MonetDB5:/ufs/mk/current//Linux/lib/MonetDB5/lib:/ufs/mk/current//Linux/lib/MonetDB5/bin"
 --set "gdk_dbfarm=/ufs/mk/current//Linux/var/MonetDB5/dbfarm"  --set 
mapi_open=true --set xrpc_open=true --set mapi_port=38637 --set xrpc_port=40729 
--set monet_prompt= --set mal_listing=2 --trace  --dbname=mTests_src_mal  
tst274.mal
-# 17:57:28 >  
-
-# MonetDB server v5.21.0, based on kernel v1.39.0
-# Serving database 'mTests_src_mal', using 4 threads
-# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically 
linked
-# Found 7.751 GiB available main-memory.
-# Copyright (c) 1993-July 2008 CWI.
-# Copyright (c) August 2008-2015 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:38637/
-# MonetDB/SQL module v2.39.0 loaded
-# MonetDB/GIS module v0.19.0 loaded
-function user.main():void;
-# the multiplex code blocks. 
-#watch out, the random generator on SUN has a limited range. 
-    r := mmath.srand(0);
-    t0 := alarm.usec();
-    b := bat.new(:oid,:lng);
-barrier i := 0:lng;
-    k := mmath.rand();
-    l := calc.lng(k);
-    bat.insert(b,nil:oid,l);
-    redo i := iterator.next(1:lng,10000:lng);
-exit i;
-    profiler.activate("ticks");
-    profiler.activate("stmt");
-    profiler.activate("rbytes");
-    profiler.activate("wbytes");
-    profiler.setAll();
-    profiler.start();
-    io.printf("#monitor \n");
-    mx := aggr.max(b);
-    mx := calc.+(mx,1);
-#enforce an empty set later on 
-    k1 := algebra.select(b,nil:lng,mx);
-    k2 := algebra.select(b,mx,nil:lng);
-    d := mmath.sin(0.20000000298023224:dbl);
-    profiler.stop();
-    stmt := profiler.getTrace("stmt");
-#io.print(stmt); 
-    c := aggr.count(stmt);
-    io.print(c);
-    ticks := profiler.getTrace("ticks");
-#io.print(ticks); 
-    c := aggr.count(ticks);
-    io.print(c);
-    rdbytes := profiler.getTrace("rbytes");
-    io.print(rdbytes);
-    wrbytes := profiler.getTrace("wbytes");
-    io.print(wrbytes);
-    io.print(rdbytes,wrbytes);
-end main;
-#monitor 
-[ 7 ]
-[ 7 ]
-#-----------------#
-# h    t         # name
-# void lng       # type
-#-----------------#
-[ 0@0,   0       ]
-[ 1@0,   0       ]
-[ 2@0,   0       ]
-[ 3@0,   0       ]
-[ 4@0,   0       ]
-[ 5@0,   0       ]
-[ 6@0,   0       ]
-#-----------------#
-# h    t         # name
-# void lng       # type
-#-----------------#
-[ 0@0,   0       ]
-[ 1@0,   160000  ]
-[ 2@0,   0       ]
-[ 3@0,   0       ]
-[ 4@0,   160000  ]
-[ 5@0,   160000  ]
-[ 6@0,   0       ]
-#-------------------------#
-# h    t       t         # name
-# void lng     lng       # type
-#-------------------------#
-[ 0@0,   0,      0       ]
-[ 1@0,   0,      160000  ]
-[ 2@0,   0,      0       ]
-[ 3@0,   0,      0       ]
-[ 4@0,   0,      160000  ]
-[ 5@0,   0,      160000  ]
-[ 6@0,   0,      0       ]
-
-# 17:57:29 >  
-# 17:57:29 >  Done.
-# 17:57:29 >  
-
diff --git a/monetdb5/modules/kernel/aggr.c b/monetdb5/modules/kernel/aggr.c
--- a/monetdb5/modules/kernel/aggr.c
+++ b/monetdb5/modules/kernel/aggr.c
@@ -39,7 +39,7 @@ AGGRgrouped(bat *retval1, bat *retval2, 
                        int skip_nils,
                        const char *malfunc)
 {
-       BAT *bn, *cnts = NULL, *t, *map;
+       BAT *bn, *cnts = NULL;
        double qvalue;
 
    /* one of grpfunc1, grpfunc2 and quantilefunc is non-NULL and the others 
are */
@@ -59,58 +59,13 @@ AGGRgrouped(bat *retval1, bat *retval2, 
                        BBPunfix(e->batCacheid);
                throw(MAL, malfunc, RUNTIME_OBJECT_MISSING);
        }
+       assert(BAThdense(b));
+       assert(BAThdense(g));
+       assert(BAThdense(e));
+       assert(b->hseqbase == g->hseqbase);
+       assert(BATcount(b) == BATcount(g));
        if (tp == TYPE_any && (grpfunc1 == BATgroupmedian || quantilefunc == 
BATgroupquantile))
                tp = b->ttype;
-       if (!BAThdense(b) || !BAThdense(g)) {
-               /* if b or g don't have a dense head, replace the head with a
-                * dense sequence */
-               t = BATjoin(BATmirror(b), g, MIN(BATcount(b), BATcount(g)));
-               BBPunfix(b->batCacheid);
-               BBPunfix(g->batCacheid);
-               b = BATmirror(BATmark(t, 0));
-               g = BATmirror(BATmark(BATmirror(t), 0));
-               BBPunfix(t->batCacheid);
-       }
-       if (b->hseqbase != g->hseqbase || BATcount(b) != BATcount(g)) {
-               /* b and g are not aligned: align them by creating a view on
-                * one or the other */
-               oid min;                                /* lowest common oid */
-               oid max;                                /* highest common oid */
-               min = b->hseqbase;
-               if (min < g->hseqbase)
-                       min = g->hseqbase;
-               max = b->hseqbase + BATcount(b);
-               if (g->hseqbase + BATcount(g) < max)
-                       max = g->hseqbase + BATcount(g);
-               if (b->hseqbase != min || b->hseqbase + BATcount(b) != max) {
-                       if (min >= max)
-                               min = max = b->hseqbase;
-                       t = BATslice(b, BUNfirst(b) + (BUN) (min - b->hseqbase),
-                                                BUNfirst(b) + (BUN) (max - 
b->hseqbase));
-                       BBPunfix(b->batCacheid);
-                       b = t;
-               }
-               if (g->hseqbase != min || g->hseqbase + BATcount(g) != max) {
-                       if (min >= max)
-                               min = max = g->hseqbase;
-                       t = BATslice(g, BUNfirst(g) + (BUN) (min - g->hseqbase),
-                                                BUNfirst(g) + (BUN) (max - 
g->hseqbase));
-                       BBPunfix(g->batCacheid);
-                       g = t;
-               }
-       }
-       if (!BAThdense(e)) {
-               /* if e doesn't have a dense head, renumber the group ids with
-                * a dense sequence at the cost of some left joins */
-               map = BATmark(e, 0);    /* [gid,newgid(dense)] */
-               BBPunfix(e->batCacheid);
-               e = BATmirror(map);             /* [newgid(dense),gid] */
-               t = BATleftjoin(g, map, BATcount(g)); /* [oid,newgid] */
-               BBPunfix(g->batCacheid);
-               g = t;
-       } else {
-               map = NULL;
-       }
        if (grpfunc1)
                bn = (*grpfunc1)(b, g, e, NULL, tp, skip_nils, 1);
        if (quantilefunc) {
@@ -127,21 +82,17 @@ AGGRgrouped(bat *retval1, bat *retval2, 
        if (grpfunc2 && (*grpfunc2)(&bn, retval2 ? &cnts : NULL, b, g, e, NULL, 
tp, skip_nils, 1) == GDK_FAIL)
                bn = NULL;
        if (bn != NULL && (grpfunc1 == BATgroupmin || grpfunc1 == BATgroupmax)) 
{
-               t = BATproject(bn, b);
+               BAT *t = BATproject(bn, b);
                BBPunfix(bn->batCacheid);
                bn = t;
        }
        BBPunfix(b->batCacheid);
        BBPunfix(g->batCacheid);
-       if (map == NULL)                        /* if map!=NULL, e is mirror of 
map */
-               BBPunfix(e->batCacheid);
+       BBPunfix(e->batCacheid);
        if (bn == NULL) {
                char *errbuf = GDKerrbuf;
                char *s;
 
-               if (map)
-                       BBPunfix(map->batCacheid);
-
                if (errbuf && *errbuf) {
                        if (strncmp(errbuf, "!ERROR: ", 8) == 0)
                                errbuf += 8;
@@ -157,17 +108,6 @@ AGGRgrouped(bat *retval1, bat *retval2, 
                }
                throw(MAL, malfunc, OPERATION_FAILED);
        }
-       if (map) {
-               t = BATleftjoin(map, bn, BATcount(bn));
-               BBPunfix(bn->batCacheid);
-               bn = t;
-               if (cnts) {
-                       t = BATleftjoin(map, cnts, BATcount(cnts));
-                       BBPunfix(cnts->batCacheid);
-                       cnts = t;
-               }
-               BBPunfix(map->batCacheid);
-       }
        *retval1 = bn->batCacheid;
        BBPkeepref(bn->batCacheid);
        if (retval2) {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to