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

MAL plan and signatures needed when executing query select * from a where x=2*y


diffs (truncated from 2109 to 300 lines):

diff --git a/gdk/gdk_arrays.h b/gdk/gdk_arrays.h
--- a/gdk/gdk_arrays.h
+++ b/gdk/gdk_arrays.h
@@ -13,19 +13,6 @@ typedef struct dimensionAnalyticStruct {
        unsigned int elsNum;
 } gdk_analytic_dimension;
 
-/*
-typedef struct dim_node {
-    struct dim_node *next;
-    gdk_dimension *data;
-} dim_node;
-
-typedef struct cells {
-    dim_node *h;
-    dim_node *t;
-    int dimsNum;
-} gdk_cells;
-*/
-
 //As long as the dimension is not projected the following info is enough
 typedef struct dimensionStruct {
        unsigned int min; //initialy this is set to 0
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
@@ -289,6 +289,23 @@ str ALGdimensionSubselect1(ptr *dimsRes,
        return ALGdimensionSubselect2(dimsRes, oidsRes, dim, dims, NULL, NULL, 
low, high, li, hi, anti);
 }
 
+str ALGdimensionSubselect3(ptr *dimsRes, bat *oidsResi, const ptr *array, 
const bat *vals,
+                            const void *low, const void *high, const bit *li, 
const bit *hi, const bit *anti) {
+
+               (void)*dimsRes;
+               (void)*oidsResi;
+               (void)*array; 
+               (void)*vals;
+               (void)*(int*)low;
+               (void)*(int*)high; 
+               (void)*li; 
+               (void)*hi;
+               (void)*anti;
+
+               return MAL_SUCCEED;
+}
+
+
 str ALGdimensionThetasubselect2(ptr *dimsRes, bat *oidsRes, const ptr *dim, 
const ptr* dims, const ptr *dimsCands, const bat *oidsCands, const void *val, 
const char **opp) {
        bit li = 0;
        bit hi = 0;
@@ -830,19 +847,7 @@ str ALGnonDimensionSubselect2(ptr *dimsR
                        mbrOut->dims[d]->min = currentOid < 
mbrOut->dims[d]->min ? currentOid : mbrOut->dims[d]->min;
                        mbrOut->dims[d]->max = currentOid > 
mbrOut->dims[d]->max ? currentOid : mbrOut->dims[d]->max;
                }
-#if 0
-               if(mbrIn) {
-                       /* compare the mbr_in and mbr_out and keep the smallest 
one */
-                       for(d=0; d<mbrOut->dimsNum; d++) {
-                               mbrOut->dims[d]->min = mbrIn->dims[d]->min > 
mbrOut->dims[d]->min ? mbrIn->dims[d]->min : mbrOut->dims[d]->min;
-                               mbrOut->dims[d]->max = mbrIn->dims[d]->max < 
mbrOut->dims[d]->max ? mbrIn->dims[d]->max : mbrOut->dims[d]->max;
-                               mbrOut->dims[d]->elsNum = 
floor((mbrOut->dims[d]->max-mbrOut->dims[d]->min)/mbrOut->dims[d]->step) + 1;
-                       }
-               } else {
-                       for(d=0; d<mbrOut->dimsNum; d++)
-                               mbrOut->dims[d]->elsNum = 
floor((mbrOut->dims[d]->max-mbrOut->dims[d]->min)/mbrOut->dims[d]->step) + 1;
-               }
-#endif
+
                for(d=0; d<mbrOut->dimsNum; d++)
                        mbrOut->dims[d]->elsNum = 
floor((mbrOut->dims[d]->max-mbrOut->dims[d]->min)/mbrOut->dims[d]->step) + 1;
 
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
@@ -21,6 +21,8 @@ algebra_export str ALGdimensionSubselect
                             const void *low, const void *high, const bit *li, 
const bit *hi, const bit *anti);
 algebra_export str ALGdimensionSubselect1(ptr *dimsRes, bat *oidsRes, const 
ptr *dim, const ptr* dims, 
                             const void *low, const void *high, const bit *li, 
const bit *hi, const bit *anti);
+algebra_export str ALGdimensionSubselect3(ptr *dimsRes, bat *oidsResi, const 
ptr *array, const bat *vals,
+                                                       const void *low, const 
void *high, const bit *li, const bit *hi, const bit *anti);
 
 algebra_export str ALGdimensionThetasubselect2(ptr *dimsRes, bat *oidsRes, 
const ptr *dim, const ptr* dims, const ptr *dimsCand, const bat *oidsCands,
                                                                                
        const void *val, const char **op);
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
@@ -27,6 +27,11 @@ command algebra.subselect(dim:ptr, dims:
 address ALGdimensionSubselect2;
 command algebra.thetasubselect(dim:ptr, dims:ptr, candDims:ptr, 
candBAT:bat[:oid,:oid], val:any, op:str) (:ptr, :bat[:oid,:oid])
 address ALGdimensionThetasubselect2;
+#when two dimensions have been compared to each other (e.g. =, >=, etc.) the 
result is a ptr with the array of the dimensions
+#a bat[:oid,:bit] that shows which cells satisfy the condition. This subselect 
returns the mbr of the cells that satisfy the 
+#condition and a bat with the exact oids that satisfy the condition
+command algebra.subselect(dims:ptr, vals:bat[:oid,:bit], low:bit, high:bit, 
li:bit, hi:bit, anti:bit) (:ptr,:bat[:oid,:oid])
+address ALGdimensionSubselect3;
 
 #subselection in non-dimensions
 command algebra.subselect(vals:bat[:oid,:any], dims:ptr, low:any, high:any, 
li:bit, hi:bit, anti:bit) (:ptr, :bat[:oid,:oid])
@@ -40,7 +45,6 @@ address ALGnonDimensionSubselect2;
 command algebra.thetasubselect(vals:bat[:oid,:any], dims:ptr, candDims:ptr, 
candBAT:bat[:oid,:oid], val:any, op:str) (:ptr, :bat[:oid,:oid])
 address ALGnonDimensionThetasubselect2;
 
-
 #projects a dimension
 command algebra.projectArray(dim:ptr, dims:ptr) :bat[:oid,:any]
 address ALGprojectDimension;
diff --git a/monetdb5/modules/mal/calc_arrays.c 
b/monetdb5/modules/mal/calc_arrays.c
--- a/monetdb5/modules/mal/calc_arrays.c
+++ b/monetdb5/modules/mal/calc_arrays.c
@@ -1,19 +1,87 @@
 #include "monetdb_config.h"
 #include "gdk.h"
+#include "gdk_arrays.h"
 #include "math.h"
 #include "mal_exception.h"
 #include "mal_interpreter.h"
 
-
-
 #include "calc_arrays.h"
 
-str CMDconvertDimension_lng(ptr *dimConverted, ptr* dims_out, const ptr *dim, 
const ptr* dims) {
-       (void)*dimConverted;
-       (void)*dim;
-       (void)*dims_out;
-       (void)*dims;
+str CMDdimensionCONVERT(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci) {
+    char buf[20];
+       ptr *dimConverted = getArgReference_ptr(stk, pci, 0);
+       ptr *array_out = getArgReference_ptr(stk, pci, 1);
+       ptr *dimOriginal = getArgReference_ptr(stk, pci, 2);
+       ptr *array_in = getArgReference_ptr(stk, pci, 3);
 
-       return MAL_SUCCEED;
+       gdk_analytic_dimension *dim_out = NULL;
+       gdk_analytic_dimension *dim_in = (gdk_analytic_dimension*)*dimOriginal;
+
+       //the array is not affected by the convertion
+       //I just need to pass it along
+       *array_out = *array_in;
+
+    (void) cntxt;
+    (void) mb;
+
+
+
+       (void)*buf;
+       (void)*dim_in;
+       (void)*dim_out; 
+       /*
+    if (VARconvert(&stk->stk[getArg(pci, 0)], &stk->stk[getArg(pci, 1)], 1) != 
GDK_SUCCEED) {
+        snprintf(buf, sizeof(buf), "%s.%s", pci->modname, pci->fcnname);
+        return mythrow(MAL, buf, OPERATION_FAILED);
+    }*/
+
+       *dimConverted = dim_out;
+
+    return MAL_SUCCEED;
 }
 
+
+str CMDdimensionMULsignal(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci) {
+       ptr *dimConverted = getArgReference_ptr(stk, pci, 0);
+       ptr *array_out = getArgReference_ptr(stk, pci, 1);
+       void *val = getArgReference(stk, pci, 2);
+       ptr *dimOriginal = getArgReference_ptr(stk, pci, 3);
+       ptr *array_in = getArgReference_ptr(stk, pci, 4);
+
+       gdk_analytic_dimension *dim_out = NULL;
+       gdk_analytic_dimension *dim_in = (gdk_analytic_dimension*)*dimOriginal;
+
+       //the array is not affected by the convertion
+       //I just need to pass it along
+       *array_out = *array_in;
+
+    (void) cntxt;
+    (void) mb;
+
+       (void)*(int*)val;
+       (void)*dim_in;
+       (void)*dim_out;
+
+/*
+    if (VARcalcmul(&stk->stk[getArg(pci, 0)], &stk->stk[getArg(pci, 1)], 
&stk->stk[getArg(pci, 2)], 1) != GDK_SUCCEED)
+        return mythrow(MAL, "calc.*", OPERATION_FAILED);
+*/ 
+       
+       *dimConverted = dim_out;
+   return MAL_SUCCEED;
+}
+
+str CMDdimensionEQ(ptr* dimsRes, bat* oidsRes, const ptr* dim1, const ptr* 
dims1, const ptr* dim2, const ptr* dims2) {
+       (void)*dimsRes;
+       (void)*oidsRes;
+       (void)*dim1;
+       (void)*dims1;
+       (void)*dim2;
+       (void)*dims2;
+/*
+    if (VARcalceq(&stk->stk[getArg(pci, 0)], &stk->stk[getArg(pci, 1)], 
&stk->stk[getArg(pci, 2)]) != GDK_SUCCEED)
+        return mythrow(MAL, "calc.==", OPERATION_FAILED);
+*/
+    return MAL_SUCCEED;
+}
+
diff --git a/monetdb5/modules/mal/calc_arrays.h 
b/monetdb5/modules/mal/calc_arrays.h
--- a/monetdb5/modules/mal/calc_arrays.h
+++ b/monetdb5/modules/mal/calc_arrays.h
@@ -1,14 +1,9 @@
 #ifndef _CALC_ARRAYS_H
 #define _CALC_ARRAYS_H
 
-#ifdef WIN32
-#define batcalc_export extern __declspec(dllexport)
-#else
-#define batcalc_export extern
-#endif
 
-
-str CMDconvertDimension_lng(ptr *dimConverted, ptr *dims_out, const ptr *dim, 
const ptr *dims);
-
+str CMDdimensionCONVERT(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
+str CMDdimensionMULsignal(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
+str CMDdimensionEQ(ptr* dimsRes, bat* oidsRes, const ptr* dim1, const ptr* 
dims1, const ptr* dim2, const ptr* dims2);
 
 #endif /*_CALC_ARRAYS_H*/
diff --git a/monetdb5/modules/mal/calc_arrays.mal 
b/monetdb5/modules/mal/calc_arrays.mal
--- a/monetdb5/modules/mal/calc_arrays.mal
+++ b/monetdb5/modules/mal/calc_arrays.mal
@@ -1,923 +1,925 @@
-module calc;
-
-function not(dim:ptr, dims:ptr) (:ptr, :ptr) address CMDdimensionsNOT
-address CMDdimensionsNOT
-comment "Bitwise not of the dimension values";
-
-function sign(dim:ptr, dims:ptr) (:ptr, :ptr) address CMDdimensionSIGN
-address CMDdimensionSIGN
-comment "Unary sign (-1,0,1) of the dimension values";
-
-function abs(dim:ptr, dims:ptr) (:ptr, :ptr)
-address CMDdimensionABS
-comment "Unary absolute value of dimension values";
-
-funcion -(dim:ptr, dims:ptr) (:ptr, :ptr)
-address CMDdimensionNEG
-comment "Unary negation of the dimension values";
-
-function ++(dim:ptr, dims:ptr) (:ptr, :ptr)
-address CMDdimensionINCRsignal
-comment "Unary dimension values + 1";
-
-function --(dim:ptr, dims:ptr) (:ptr, :ptr)
-address CMDdimensionDECRsignal
-comment "Unary dimension values - 1";
-
-#+
-pattern +(v:bte, dim:ptr, dims:ptr) (:ptr, :ptr) address CMDdimensionADDsignal
-comment "Return V + dimension values, guarantee no overflow by returning 
larger type";
-pattern +(v:sht, dim:ptr, dims:ptr) (:ptr, :ptr) address CMDdimensionADDsignal
-comment "Return V + dimension vallues, guarantee no overflow by returning 
larger type";
-pattern +(v:int, dim:ptr, dims:ptr) (:ptr, :ptr) address CMDdimensionADDsignal
-comment "Return V + dimension values, guarantee no overflow by returning 
larger type";
-pattern +(v:wrd, dim:ptr, dims:ptr) (:ptr, :ptr) address CMDdimensionADDsignal
-comment "Return V + dimension values, guarantee no overflow by returning 
larger type";
-pattern +(v:lng, dim:ptr, dims:ptr) (:ptr, :ptr) address CMDdimensionADDsignal
-comment "Return V + dimension values, guarantee no overflow by returning 
larger type";
-pattern +(v:flt, dim:ptr, dims:ptr) (:ptr, :ptr) address CMDdimensionADDsignal
-comment "Return V + dimension values, guarantee no overflow by returning 
larger type";
-
-#-
-pattern -(v:bte, dim:ptr, dims:ptr) (:ptr, :ptr) address CMDdimensionSUBsignal
-comment "Return V - dimension values, guarantee no overflow by returning 
larger type";
-pattern -(v:sht, dim:ptr, dims:ptr) (:ptr, :ptr) address CMDdimensionSUBsignal
-comment "Return V - dimension values, guarantee no overflow by returning 
larger type";
-pattern -(v:int, dim:ptr, dims:ptr) (:ptr, :ptr) address CMDdimensionSUBsignal
-comment "Return V - dimension values, guarantee no overflow by returning 
larger type";
-pattern -(v:wrd, dim:ptr, dims:ptr) (:ptr, :ptr) address CMDdimensionSUBsignal
-comment "Return V - dimension values, guarantee no overflow by returning 
larger type";
-pattern -(v:lng, dim:ptr, dims:ptr) (:ptr, :ptr) address CMDdimensionSUBsignal
-comment "Return V - dimension values, guarantee no overflow by returning 
larger type";
-pattern -(v:flt, dim:ptr, dims:ptr) (:ptr, :ptr) address CMDdimensionSUBsignal
-comment "Return V - dimension values, guarantee no overflow by returning 
larger type";
+#module calc;
+#
+#function not(dim:ptr, dims:ptr) (:ptr, :ptr) address CMDdimensionsNOT
+#address CMDdimensionsNOT
+#comment "Bitwise not of the dimension values";
+#
+#function sign(dim:ptr, dims:ptr) (:ptr, :ptr) address CMDdimensionSIGN
+#address CMDdimensionSIGN
+#comment "Unary sign (-1,0,1) of the dimension values";
+#
+#function abs(dim:ptr, dims:ptr) (:ptr, :ptr)
+#address CMDdimensionABS
+#comment "Unary absolute value of dimension values";
+#
+#funcion -(dim:ptr, dims:ptr) (:ptr, :ptr)
+#address CMDdimensionNEG
+#comment "Unary negation of the dimension values";
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to