Changeset: e8e9e3aa7cc6 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e8e9e3aa7cc6
Modified Files:
        monetdb5/modules/kernel/algebra.mal
        monetdb5/modules/kernel/arrays.c
        monetdb5/modules/kernel/arrays.h
        monetdb5/modules/kernel/arrays.mal
        sql/backends/monet5/sql_gencode.c
Branch: arrays
Log Message:

When having selection over a non-dimensional column a ptr with tha mbr is 
selected and a BAT with the oids that
qualify the selection


diffs (167 lines):

diff --git a/monetdb5/modules/kernel/algebra.mal 
b/monetdb5/modules/kernel/algebra.mal
--- a/monetdb5/modules/kernel/algebra.mal
+++ b/monetdb5/modules/kernel/algebra.mal
@@ -51,9 +51,6 @@ command exist(b:bat[:oid,:any_1], val:an
 address ALGexist
 comment "Returns whether 'val' occurs in b.";
 
-#command algebra.subselect(pos:int, dims:ptr, low:any, high:any, li:bit, 
hi:bit, anti:bit) :bat[:oid,:oid]
-#address ALGdimensionSubselect1;
-
 # The range selections are targeted at the tail of the BAT.
 command subselect(b:bat[:oid,:any_1], low:any_1, high:any_1, li:bit, hi:bit, 
anti:bit) :bat[:oid,:oid]
 address ALGsubselect1
diff --git a/monetdb5/modules/kernel/arrays.c b/monetdb5/modules/kernel/arrays.c
--- a/monetdb5/modules/kernel/arrays.c
+++ b/monetdb5/modules/kernel/arrays.c
@@ -212,7 +212,7 @@ do { \
     } \
 } while(0)
 
-str ALGdimensionLeftfetchjoin(bat *result, const bat *cands, const ptr *dims, 
const ptr *dim) {
+str ALGdimensionLeftfetchjoin1(bat *result, const bat *cands, const ptr *dims, 
const ptr *dim) {
        gdk_array *array = (gdk_array*)*dims;
        gdk_dimension *dimension = (gdk_dimension*)*dim;
        BAT *candsBAT = NULL, *resBAT = NULL;
@@ -855,3 +855,20 @@ str ALGproject(bat *result, const ptr* c
        return MAL_SUCCEED;
 }
 
+
+str ALGnonDimensionSubselect2(ptr *dimsRes, bat* oidsRes, const bat* values, 
const ptr *dimsCand, const bat* oidsCand,
+                        const void *low, const void *high, const bit *li, 
const bit *hi, const bit *anti) {
+       (void)*dimsRes;
+       (void)*oidsRes;
+       (void)*values;
+       (void)*dimsCand;
+       (void)*oidsCand;
+       (void)*(int*)low;
+       (void)*(int*)high;
+       (void)*li;
+       (void)*hi;
+       (void)*anti;
+
+       return MAL_SUCCEED;
+}
+
diff --git a/monetdb5/modules/kernel/arrays.h b/monetdb5/modules/kernel/arrays.h
--- a/monetdb5/modules/kernel/arrays.h
+++ b/monetdb5/modules/kernel/arrays.h
@@ -12,7 +12,8 @@
 #define algebra_export extern
 #endif
 
-algebra_export str ALGdimensionLeftfetchjoin(bat* result, const bat* cands, 
const ptr *dims, const ptr *dim) ;
+algebra_export str ALGdimensionLeftfetchjoin1(bat* result, const bat* cands, 
const ptr *dims, const ptr *dim) ;
+algebra_export str ALGdimensionLeftfetchjoin2(bat* result, const ptr* 
dimsCand, const ptr *dims, const ptr *dim) ;
 algebra_export str ALGnonDimensionLeftfetchjoin(bat *result, const bat *lid, 
const bat *rid);
 //algebra_export str ALGdimensionLeftfetchjoin(bat *result, const bat *lid, 
const bat *rid);
 
@@ -23,8 +24,12 @@ algebra_export str ALGdimensionSubselect
 algebra_export str ALGdimensionThetasubselect2(ptr *dimsRes, bat* oidsRes, 
const ptr *dims, const ptr* dim, const ptr *dimsCand, const bat* oidsCand, 
const void *val, const char **op);
 algebra_export str ALGdimensionThetasubselect1(ptr *dimsRes, bat* oidsRes, 
const ptr *dims, const ptr* dim, const void *val, const char **op);
 
-algebra_export str ALGmbrsubselect(bat *result, const bat *bid, const bat 
*sid, const bat *cid);
-algebra_export str ALGmbrsubselect2(bat *result, const bat *bid, const bat 
*sid);
+
+algebra_export str ALGnonDimensionSubselect2(ptr *dimsRes, bat* oidsRes, const 
bat* values, const ptr *dimsCand, const bat* oidsCand, 
+                            const void *low, const void *high, const bit *li, 
const bit *hi, const bit *anti);
+
+algebra_export str ALGmbrsubselect(bat *result, const ptr *dims, const ptr* 
dim, const bat *sid, const bat *cid);
+algebra_export str ALGmbrsubselect2(bat *result, const ptr *dims, const ptr* 
dim, const bat *sid);
 
 algebra_export str ALGmbrproject(bat *result, const bat *bid, const bat *sid, 
const bat *rid);
 
diff --git a/monetdb5/modules/kernel/arrays.mal 
b/monetdb5/modules/kernel/arrays.mal
--- a/monetdb5/modules/kernel/arrays.mal
+++ b/monetdb5/modules/kernel/arrays.mal
@@ -1,6 +1,9 @@
 #leftfetch join when having a dimension from an array
 command algebra.leftfetchjoin(candsBAT:bat[:oid,:oid], dims:ptr, dim:ptr ) 
:bat[:oid,:any]
-address ALGdimensionLeftfetchjoin;
+address ALGdimensionLeftfetchjoin1;
+#it is called after a selection on a non-dimensional column and is the mbr of 
the qualifying cells
+command algebra.leftfetchjoin(dimsCand:ptr, dims:ptr, dim:ptr ) :bat[:oid,:any]
+address ALGdimensionLeftfetchjoin2;
 
 command algebra.mbrsubselect(b:bat[:oid,:any], s:bat[:oid, :oid], c:bat[:oid, 
:oid]) :bat[:oid,:oid]
 address ALGmbrsubselect;
@@ -15,10 +18,12 @@ address ALGdimensionSubselect1;
 command algebra.subselect(dims:ptr, dim:ptr, candDims:ptr, 
candBat:bat[:oid,:oid], low:any, high:any, li:bit, hi:bit, anti:bit) (:ptr, 
:bat[:oid, :oid])
 address ALGdimensionSubselect2;
 
-#subselection in non-dimenional columns of arrays after a subselection in 
dimensions has been performed
-command algebra.subselect(:bat[:oid, :any], candDims:ptr, 
candBat:bat[:oid,:oid], low:any, high:any, li:bit, hi:bit, anti:bit) :bat[:oid, 
:any]
-address ALGsubselect3;
-
+#subselect on non-dimensional column of an array
+#the ptr has the mbr dimensions and the bat{;oid,:oid] the oids that really 
qualify (rest of cells in mbr should be null)
+command algebra.subselect(valsBat:bat[:oid,:any], low:any, high:any, li:bit, 
hi:bit, anti:bit) (:ptr, :bat[:oid, :oid])
+address ALGnonDimensionSubselect1;
+command algebra.subselect(valsBat:bat[:oid,:any], candDims:ptr, 
candBat:bat[:oid,:oid], low:any, high:any, li:bit, hi:bit, anti:bit) (:ptr, 
:bat[:oid, :oid])
+address ALGnonDimensionSubselect2;
 
 command algebra.thetasubselect(dims:ptr, dim:ptr, val:any_1, op:str) (:ptr, 
:bat[:oid,:oid])
 address ALGdimensionThetasubselect1;
diff --git a/sql/backends/monet5/sql_gencode.c 
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -1222,8 +1222,9 @@ static int
                } break;
                case st_mbrselect:
 #if 0
-               }
-                       int l, r=-1, sub=-1;
+               {
+                       int l, r=-1, uval=-1, sub=-1;
+                       char nme[SMALLBUFSIZ];
                        if ((l = _dumpstmt(sql, mb, s->op1)) < 0)
                                return -1;
        
@@ -1453,6 +1454,11 @@ static int
                                                        q = pushReturn(mb, q, 
newTmpVariable(mb, newBatType(TYPE_oid, TYPE_oid)));
                                                        q = pushArgument(mb, q, 
l); //all the dimensions
                                                        q = pushArgument(mb, q, 
uval); //the current dimension
+                                               } else if(s->op1->type == 
st_join && s->op1->op2->type == st_bat && isArray(s->op1->op2->op4.cval->t)) { 
//seelctio over non-dimensional column of an array
+                                                       setVarType(mb, 
getArg(q, 0), TYPE_ptr);
+                                                       setVarUDFtype(mb, 
getArg(q, 0));
+                                                       q = pushReturn(mb, q, 
newTmpVariable(mb, newBatType(TYPE_oid, TYPE_oid)));
+                                                       q = pushArgument(mb, q, 
l);
                                                } else
                                                        q = pushArgument(mb, q, 
l);
 
@@ -1486,6 +1492,11 @@ static int
                                                        q = pushReturn(mb, q, 
newTmpVariable(mb, newBatType(TYPE_oid, TYPE_oid)));
                                                        q = pushArgument(mb, q, 
l); //all the dimensions
                                                        q = pushArgument(mb, q, 
uval); //the current dimension
+                                               } else if(s->op1->type == 
st_join && s->op1->op2->type == st_bat && isArray(s->op1->op2->op4.cval->t)) { 
//seelctio over non-dimensional column of an array
+                                                       setVarType(mb, 
getArg(q, 0), TYPE_ptr);
+                                                       setVarUDFtype(mb, 
getArg(q, 0));
+                                                       q = pushReturn(mb, q, 
newTmpVariable(mb, newBatType(TYPE_oid, TYPE_oid)));
+                                                       q = pushArgument(mb, q, 
l);
                                                } else
                                                        q = pushArgument(mb, q, 
l);
 
@@ -1531,7 +1542,7 @@ static int
                        }
                        if (q) {
                                s->nr = getDestVar(q);
-                               if(s->op1->type == st_dimension) { 
+                               if(s->op1->type == st_dimension || 
(s->op1->type == st_join && s->op1->op2->type == st_bat && 
isArray(s->op1->op2->op4.cval->t))) { 
                                        /* rename second result */
                                        renameVariable(mb, getArg(q, 1), 
"Y_%d", s->nr);
                                }
@@ -1833,7 +1844,12 @@ static int
                                        q = newStmt1(mb, algebraRef, 
"leftfetchjoin");
                                else
                                        q = newStmt2(mb, algebraRef, 
leftjoinRef);
-                               q = pushArgument(mb, q, l);
+//                             if(s->op2->type == st_bat) {
+//                                     sql_table *t = 
(sql_table*)s->op2->op4.cval->t;
+//                                     if(!isArray(t))
+//                                             q = pushArgument(mb, q, l);
+//                             } else
+                                       q = pushArgument(mb, q, l);
                                q = pushArgument(mb, q, r);
                                if(s->op2->type == st_dimension) {
                                        char nme[SMALLBUFSIZ];
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to