Changeset: f4ff7332115a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f4ff7332115a
Modified Files:
        monetdb5/modules/kernel/aggr.c
        monetdb5/modules/kernel/aggr.mal
        monetdb5/modules/kernel/aggr.mal.sh
        monetdb5/modules/kernel/algebra.mx
        monetdb5/modules/mal/mat.c
        monetdb5/optimizer/opt_mergetable.c
        monetdb5/optimizer/opt_mitosis.c
        monetdb5/optimizer/opt_prelude.c
        monetdb5/optimizer/opt_prelude.h
        monetdb5/optimizer/opt_support.c
        monetdb5/optimizer/opt_support.h
        sql/backends/monet5/sql_gencode.c
        sql/benchmarks/viam/Tests/viam.stable.out
        sql/server/rel_bin.c
        sql/server/sql_rel2bin.c
        sql/server/sql_statement.c
        sql/server/sql_statement.h
        sql/test/leaks/Tests/check0.stable.out
Branch: default
Log Message:

merge table now handles join's again (and tdiff/tinter)


diffs (truncated from 1627 to 300 lines):

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
@@ -854,6 +854,87 @@ AGGRsubmaxcand(bat *retval, bat *bid, ba
                                                  0, TYPE_oid, BATgroupmax, 
"aggr.submax");
 }
 
+aggr_export str AGGRsubmin_val(bat *retval, bat *bid, bat *gid, bat *eid, int 
*skip_nils);
+str
+AGGRsubmin_val(bat *retval, bat *bid, bat *gid, bat *eid, int *skip_nils)
+{
+       BAT *a, *b, *r;
+       str res;
+
+       if ((res = AGGRsubgrouped(retval, bid, gid, eid, NULL, *skip_nils,
+                                                 0, TYPE_oid, BATgroupmin, 
"aggr.submin")) != MAL_SUCCEED)
+               return res;
+       b = BATdescriptor(*bid);
+       a = BATdescriptor(*retval);
+       r = BATouterjoin(a, b, BATcount(a));
+       BBPreleaseref(b->batCacheid);
+       BBPreleaseref(a->batCacheid);
+       BBPdecref(*retval, TRUE);
+       BBPkeepref(*retval = r->batCacheid);
+       return MAL_SUCCEED;
+}
+
+aggr_export str AGGRsubmincand_val(bat *retval, bat *bid, bat *gid, bat *eid, 
bat *sid, int *skip_nils);
+str
+AGGRsubmincand_val(bat *retval, bat *bid, bat *gid, bat *eid, bat *sid, int 
*skip_nils)
+{
+       BAT *a, *b, *r;
+       str res;
+
+       if ((res = AGGRsubgrouped(retval, bid, gid, eid, sid, *skip_nils,
+                                                 0, TYPE_oid, BATgroupmin, 
"aggr.submin")) != MAL_SUCCEED)
+               return res;
+       b = BATdescriptor(*bid);
+       a = BATdescriptor(*retval);
+       r = BATouterjoin(a, b, BATcount(a));
+       BBPreleaseref(b->batCacheid);
+       BBPreleaseref(a->batCacheid);
+       BBPdecref(*retval, TRUE);
+       BBPkeepref(*retval = r->batCacheid);
+       return MAL_SUCCEED;
+}
+
+aggr_export str AGGRsubmax_val(bat *retval, bat *bid, bat *gid, bat *eid, int 
*skip_nils);
+str
+AGGRsubmax_val(bat *retval, bat *bid, bat *gid, bat *eid, int *skip_nils)
+{
+       BAT *a, *b, *r;
+       str res;
+
+       if ((res = AGGRsubgrouped(retval, bid, gid, eid, NULL, *skip_nils,
+                                                 0, TYPE_oid, BATgroupmax, 
"aggr.submax")) != MAL_SUCCEED)
+               return res;
+       b = BATdescriptor(*bid);
+       a = BATdescriptor(*retval);
+       r = BATouterjoin(a, b, BATcount(a));
+       BBPreleaseref(b->batCacheid);
+       BBPreleaseref(a->batCacheid);
+       BBPdecref(*retval, TRUE);
+       BBPkeepref(*retval = r->batCacheid);
+       return MAL_SUCCEED;
+}
+
+aggr_export str AGGRsubmaxcand_val(bat *retval, bat *bid, bat *gid, bat *eid, 
bat *sid, int *skip_nils);
+str
+AGGRsubmaxcand_val(bat *retval, bat *bid, bat *gid, bat *eid, bat *sid, int 
*skip_nils)
+{
+       BAT *a, *b, *r;
+       str res;
+
+       if ((res = AGGRsubgrouped(retval, bid, gid, eid, sid, *skip_nils,
+                                                 0, TYPE_oid, BATgroupmax, 
"aggr.submax")) != MAL_SUCCEED)
+               return res;
+       b = BATdescriptor(*bid);
+       a = BATdescriptor(*retval);
+       r = BATouterjoin(a, b, BATcount(a));
+       BBPreleaseref(b->batCacheid);
+       BBPreleaseref(a->batCacheid);
+       BBPdecref(*retval, TRUE);
+       BBPkeepref(*retval = r->batCacheid);
+       return MAL_SUCCEED;
+}
+
+
 aggr_export str AGGRmedian(bat *retval, bat *bid, int *skip_nils);
 str
 AGGRmedian(bat *retval, bat *bid, int *skip_nils)
diff --git a/monetdb5/modules/kernel/aggr.mal b/monetdb5/modules/kernel/aggr.mal
--- a/monetdb5/modules/kernel/aggr.mal
+++ b/monetdb5/modules/kernel/aggr.mal
@@ -817,6 +817,22 @@ command submax(b:bat[:oid,:any_1],g:bat[
 address AGGRsubmaxcand
 comment "Grouped maximum aggregate with candidates list";
 
+command 
submin(b:bat[:oid,:any_1],g:bat[:oid,:oid],e:bat[:oid,:any_2],skip_nils:int) 
:bat[:oid,:any_1]
+address AGGRsubmin_val
+comment "Grouped minimum aggregate";
+
+command 
submin(b:bat[:oid,:any_1],g:bat[:oid,:oid],e:bat[:oid,:any_2],s:bat[:oid,:oid],skip_nils:int)
 :bat[:oid,:any_1]
+address AGGRsubmincand_val
+comment "Grouped minimum aggregate with candidates list";
+
+command 
submax(b:bat[:oid,:any_1],g:bat[:oid,:oid],e:bat[:oid,:any_2],skip_nils:int) 
:bat[:oid,:any_1]
+address AGGRsubmax_val
+comment "Grouped maximum aggregate";
+
+command 
submax(b:bat[:oid,:any_1],g:bat[:oid,:oid],e:bat[:oid,:any_2],s:bat[:oid,:oid],skip_nils:int)
 :bat[:oid,:any_1]
+address AGGRsubmaxcand_val
+comment "Grouped maximum aggregate with candidates list";
+
 command count(b:bat[:oid,:any_1], e:bat[:oid,:any_2], ignorenils:bit)
        :bat[:oid,:wrd]
 address AGGRcount2
diff --git a/monetdb5/modules/kernel/aggr.mal.sh 
b/monetdb5/modules/kernel/aggr.mal.sh
--- a/monetdb5/modules/kernel/aggr.mal.sh
+++ b/monetdb5/modules/kernel/aggr.mal.sh
@@ -191,6 +191,22 @@ command submax(b:bat[:oid,:any_1],g:bat[
 address AGGRsubmaxcand
 comment "Grouped maximum aggregate with candidates list";
 
+command 
submin(b:bat[:oid,:any_1],g:bat[:oid,:oid],e:bat[:oid,:any_2],skip_nils:int) 
:bat[:oid,:any_1]
+address AGGRsubmin_val
+comment "Grouped minimum aggregate";
+
+command 
submin(b:bat[:oid,:any_1],g:bat[:oid,:oid],e:bat[:oid,:any_2],s:bat[:oid,:oid],skip_nils:int)
 :bat[:oid,:any_1]
+address AGGRsubmincand_val
+comment "Grouped minimum aggregate with candidates list";
+
+command 
submax(b:bat[:oid,:any_1],g:bat[:oid,:oid],e:bat[:oid,:any_2],skip_nils:int) 
:bat[:oid,:any_1]
+address AGGRsubmax_val
+comment "Grouped maximum aggregate";
+
+command 
submax(b:bat[:oid,:any_1],g:bat[:oid,:oid],e:bat[:oid,:any_2],s:bat[:oid,:oid],skip_nils:int)
 :bat[:oid,:any_1]
+address AGGRsubmaxcand_val
+comment "Grouped maximum aggregate with candidates list";
+
 command count(b:bat[:oid,:any_1], e:bat[:oid,:any_2], ignorenils:bit)
        :bat[:oid,:wrd]
 address AGGRcount2
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
@@ -475,6 +475,8 @@ comment "Returns the intersection taken 
 command tintersect( left:bat[:any_1,:any_2], right:bat[:any_1,:any] ) 
                :bat[:any_1,:any_2] 
 address ALGtintersect;
+command tinter( left:bat[:oid,:oid], right:bat[:oid,:oid] ) :bat[:oid,:oid] 
+address ALGtinter;
 
 # @- Bun-differing elements
 command difference( left:bat[:any_1,:any_2], right:bat[:any_1,:any_2] ) 
@@ -501,6 +503,8 @@ comment "Returns the difference taken ov
        or: 'kdifference(left,right).kunique'.";
 command tdifference ( left:bat[:any_1,:any_2], right:bat[:any_1,:any] ) 
                :bat[:any_1,:any_2] 
+address ALGtdifference;
+command tdiff( left:bat[:oid,:oid], right:bat[:oid,:oid] ) :bat[:oid,:oid] 
 address ALGtdiff;
 # @- Unions on bun
 command union ( left:bat[:any_1,:any_2], right:bat[:any_1,:any_2]) 
@@ -1060,8 +1064,10 @@ algebra_export str ALG@1(int *result, in
 @:ALGbinaryExport(tunion)@
 @:ALGbinaryExport(sintersect)@
 @:ALGbinaryExport(tintersect)@
+@:ALGbinaryExport(tinter)@
 @:ALGbinaryExport(sdiff)@
 @:ALGbinaryExport(kdiff)@
+@:ALGbinaryExport(tdifference)@
 @:ALGbinaryExport(tdiff)@
 @:ALGbinaryintExport(sample)@
 
@@ -2803,7 +2809,7 @@ ALGtunion(int *result, int *bid, int *bi
 }
 
 str
-ALGtdiff(int *result, int *bid, int *bid2)
+ALGtdifference(int *result, int *bid, int *bid2)
 {
        BAT *b, *b2, *bn;
 
@@ -2830,30 +2836,84 @@ ALGtdiff(int *result, int *bid, int *bid
 }
 
 str
+ALGtdiff(int *result, int *bid, int *bid2)
+{
+       BAT *b, *b2, *bn;
+
+       if ((b = BATdescriptor(*bid)) == NULL)
+               throw(MAL, "algebra.tdiff", RUNTIME_OBJECT_MISSING);
+       if ((b2 = BATdescriptor(*bid2)) == NULL){
+               BBPreleaseref(*bid2);
+               throw(MAL, "algebra.tdiff", RUNTIME_OBJECT_MISSING);
+       }
+       
+       bn = BATkdiff(BATmirror(b),BATmirror(b2));
+       BBPreleaseref(b->batCacheid);
+       BBPreleaseref(b2->batCacheid);
+       if (bn) {
+               BAT *r = BATmirror(BATmark(bn,0));
+               
+               BBPreleaseref(bn->batCacheid);
+               bn = r;
+               if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);
+               *result = bn->batCacheid;
+               BBPkeepref(*result);
+               return MAL_SUCCEED;
+       }
+       throw(MAL, "algebra.tdiff", GDK_EXCEPTION);
+}
+
+str
 ALGtintersect(int *result, int *bid, int *bid2)
 {
        BAT *b, *b2, *bn;
 
        if ((b = BATdescriptor(*bid)) == NULL)
-               throw(MAL, "algebra.tdifference", RUNTIME_OBJECT_MISSING);
+               throw(MAL, "algebra.tintersect", RUNTIME_OBJECT_MISSING);
        if ((b2 = BATdescriptor(*bid2)) == NULL){
                BBPreleaseref(*bid2);
-               throw(MAL, "algebra.tdifference", RUNTIME_OBJECT_MISSING);
+               throw(MAL, "algebra.tintersect", RUNTIME_OBJECT_MISSING);
        }
        
        bn = BATsemijoin(BATmirror(b),BATmirror(b2));
+       BBPreleaseref(b->batCacheid);
+       BBPreleaseref(b2->batCacheid);
        if (bn) {
                bn = BATmirror(bn);
                if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);
                *result = bn->batCacheid;
                BBPkeepref(*result);
-               BBPreleaseref(b->batCacheid);
-               BBPreleaseref(b2->batCacheid);
                return MAL_SUCCEED;
        }
+       throw(MAL, "algebra.tintersect", GDK_EXCEPTION);
+}
+
+str
+ALGtinter(int *result, int *bid, int *bid2)
+{
+       BAT *b, *b2, *bn;
+
+       if ((b = BATdescriptor(*bid)) == NULL)
+               throw(MAL, "algebra.tinter", RUNTIME_OBJECT_MISSING);
+       if ((b2 = BATdescriptor(*bid2)) == NULL){
+               BBPreleaseref(*bid2);
+               throw(MAL, "algebra.tinter", RUNTIME_OBJECT_MISSING);
+       }
+       
+       bn = BATsemijoin(BATmirror(b),BATmirror(b2));
        BBPreleaseref(b->batCacheid);
        BBPreleaseref(b2->batCacheid);
-       throw(MAL, "algebra.tdifference", GDK_EXCEPTION);
+       if (bn) {
+               BAT *r = BATmirror(BATmark(bn,0));
+
+               BBPreleaseref(bn->batCacheid);
+               bn = r;
+               if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);
+               *result = bn->batCacheid;
+               BBPkeepref(*result);
+               return MAL_SUCCEED;
+       }
+       throw(MAL, "algebra.tinter", GDK_EXCEPTION);
 }
 
 str
diff --git a/monetdb5/modules/mal/mat.c b/monetdb5/modules/mal/mat.c
--- a/monetdb5/modules/mal/mat.c
+++ b/monetdb5/modules/mal/mat.c
@@ -101,6 +101,8 @@ MATpackInternal(MalStkPtr stk, InstrPtr 
                                ht = b->htype;
                                tt = b->ttype;
                        }
+                       if (!tt && tt != b->ttype)
+                               tt = b->ttype;
                        cap += BATcount(b);
                }
        }
@@ -126,6 +128,8 @@ MATpackInternal(MalStkPtr stk, InstrPtr 
                        BBPunfix(b->batCacheid);
                }
        }
+       assert(!bn->H->nil || !bn->H->nonil);
+       assert(!bn->T->nil || !bn->T->nonil);
        BBPkeepref(*ret = bn->batCacheid);
        return MAL_SUCCEED;
 }
diff --git a/monetdb5/optimizer/opt_mergetable.c 
b/monetdb5/optimizer/opt_mergetable.c
--- a/monetdb5/optimizer/opt_mergetable.c
+++ b/monetdb5/optimizer/opt_mergetable.c
@@ -29,9 +29,6 @@ typedef enum mat_type_t {
        mat_rdr = 6     /* Phase one of sorting, ie sorted the parts sofar */
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to