Changeset: 65c0ab55f4a8 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=65c0ab55f4a8 Modified Files: monetdb5/modules/kernel/arrays.c monetdb5/modules/kernel/arrays.mal sql/backends/monet5/sql_gencode.c Branch: arrays Log Message:
it turns out we need the join with the tids because at this point the nondimensional column is materalised So I put it back diffs (254 lines): 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 @@ -13,7 +13,7 @@ static unsigned int jumpSize(gdk_array * return skip; } -static int arrayCellsNum(gdk_array *array) { +static wrd arrayCellsNum(gdk_array *array) { return jumpSize(array, array->dimsNum); } @@ -135,7 +135,7 @@ str ALGdimensionSubselect2(ptr *dimsRes, int type; const void* nil; - BAT *oidsResBAT = newempty("leftfetchjoin"); //nothing returned in the oids + BAT *oidsResBAT = newempty("subselect"); //nothing returned in the oids BBPkeepref(*oidsRes = oidsResBAT->batCacheid); /*ingnore oidsCands. When projecting a dimension only the dimsCands are of interest */ @@ -410,7 +410,6 @@ str ALGnonDimensionLeftfetchjoin1(bat* r gdk_array *dimCands_in = (gdk_array*)*dimsCands; gdk_array *array = (gdk_array*)*dims; - if(!dimCands_in) { //empty if(!(resBAT = newempty("nonDimensionLeftfetchjoin1"))) throw(MAL, "algebra.leftfetchjoin", "Problem allocating new BAT"); @@ -463,39 +462,38 @@ str ALGnonDimensionLeftfetchjoin1(bat* r } str ALGnonDimensionLeftfetchjoin2(bat* result, ptr *dimsRes, const bat *tids, const bat *vals, const ptr *dims) { - BAT *materialisedBAT = NULL; - BAT *nonDimensionalBAT = NULL; - BUN totalCellsNum, neededCellsNum; + BAT *materialisedBAT = NULL; + BAT *nonDimensionalBAT = NULL; + BUN totalCellsNum, neededCellsNum; - gdk_array *array = (gdk_array*)*dims; + gdk_array *array = (gdk_array*)*dims; - if ((nonDimensionalBAT = BATdescriptor(*vals)) == NULL) { + if ((nonDimensionalBAT = BATdescriptor(*vals)) == NULL) { throw(MAL, "algebra.leftfecthjoin", RUNTIME_OBJECT_MISSING); } - (void)*tids; //ignore the tids + (void)*tids; //ignore the tids - totalCellsNum = arrayCellsNum(array); - neededCellsNum = totalCellsNum - BATcount(nonDimensionalBAT); - - /*TODO: fix this so that I can have the real default value of the column */ - materialisedBAT = materialise_nonDimensional_column(ATOMtype(BATttype(nonDimensionalBAT)), neededCellsNum, NULL); - if(!materialisedBAT) { - BBPunfix(nonDimensionalBAT->batCacheid); - throw(MAL, "algebra.leftfetchjoin", "Problem materialising non-dimensional column"); - } + totalCellsNum = arrayCellsNum(array); + neededCellsNum = totalCellsNum - BATcount(nonDimensionalBAT); + /*TODO: fix this so that I can have the real default value of the column */ + materialisedBAT = materialise_nonDimensional_column(ATOMtype(BATttype(nonDimensionalBAT)), neededCellsNum, NULL); + if(!materialisedBAT) { + BBPunfix(nonDimensionalBAT->batCacheid); + throw(MAL, "algebra.leftfetchjoin", "Problem materialising non-dimensional column"); + } - /*append the missing values to the BAT */ - BATappend(nonDimensionalBAT, materialisedBAT, TRUE); - BATsetcount(nonDimensionalBAT, totalCellsNum); - - BBPunfix(materialisedBAT->batCacheid); - BBPkeepref(*result = nonDimensionalBAT->batCacheid); - //sent this to the output so that we do not lose it afterwards - *dimsRes = *dims; - - return MAL_SUCCEED; + /*append the missing values to the BAT */ + BATappend(nonDimensionalBAT, materialisedBAT, TRUE); + BATsetcount(nonDimensionalBAT, totalCellsNum); + + BBPunfix(materialisedBAT->batCacheid); + BBPkeepref(*result = nonDimensionalBAT->batCacheid); + + //sent this to the output so that we do not lose it afterwards + *dimsRes = *dims; + return MAL_SUCCEED; } #if 0 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 @@ -38,21 +38,6 @@ command algebra.thetasubselect(vals:bat[ address ALGnonDimensionThetasubselect2; - -#command algebra.mbrsubselect(dims:ptr, dim:ptr, s:bat[:oid, :oid], c:bat[:oid, :oid]) :bat[:oid,:oid] -#address ALGmbrsubselect; -#command algebra.mbrsubselect(dims:ptr, dim:ptr, s:bat[:oid, :oid]) :bat[:oid,:oid] -#address ALGmbrsubselect2; -#command algebra.mbrproject(b:bat[:oid,:any], s:bat[:oid, :oid], r:bat[:oid, :oid]) :bat[:oid,:any] -#address ALGmbrproject; - -##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(dims:ptr, valsBat:bat[:oid,:any], low:any, high:any, li:bit, hi:bit, anti:bit) (:ptr, :bat[:oid, :oid]) -#address ALGnonDimensionSubselect1; -#command algebra.subselect(dims:ptr, 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; - #Creates a BAT that contains all cells that satisfied a series of selections on dimensions command algebra.cellsProject(candDims:ptr, candBAT:bat[:oid,:oid]) :bat[:oid,:oid] address ALGproject; 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 @@ -784,7 +784,6 @@ static int find_uselect(stmt *s){ return s->nr; return find_uselect(s->op3); } -#endif static bool isTid(stmt *s) { if(!s) return false; if(s->type == st_tid) return true; @@ -792,6 +791,7 @@ static bool isTid(stmt *s) { return false; } +#endif /* * @- * The big code generation switch. @@ -802,6 +802,10 @@ static int InstrPtr q = NULL; node *n; + /* used for handling arrays */ + char nme[SMALLBUFSIZ]; + int arraySecondVar = -1; + if (s) { if (s->nr > 0) return s->nr; /* stmt already handled */ @@ -1239,7 +1243,6 @@ static int #if 0 { int l, r=-1, uval=-1, sub=-1; - char nme[SMALLBUFSIZ]; if ((l = _dumpstmt(sql, mb, s->op1)) < 0) return -1; @@ -1330,9 +1333,6 @@ static int int l, r, sub, anti; node *n; - char nme[SMALLBUFSIZ]; - int arraySecondVar = -1; - if ((l = _dumpstmt(sql, mb, s->op1)) < 0) return -1; if ((r = _dumpstmt(sql, mb, s->op2)) < 0) @@ -1556,9 +1556,6 @@ static int char *cmd = (s->type == st_uselect2) ? subselectRef : subrangejoinRef; int sub = -1; - char nme[SMALLBUFSIZ]; - int arraySecondVar = -1; - if (l < 0) return -1; if (s->op4.stval && @@ -1785,10 +1782,7 @@ static int int cmp = s->flag; int left = (cmp == cmp_left); char *sjt = "subjoin"; - - char nme[SMALLBUFSIZ]; - int arraySecondVar = -1; - + if (left) { cmp = cmp_equal; sjt = "subleftjoin"; @@ -1804,27 +1798,8 @@ static int if (cmp == cmp_project || cmp == cmp_reorder_project) { int ins; - /* check if we have two input variables in the left argument (case: dim join tid)*/ - snprintf(nme, SMALLBUFSIZ, "Y_%d", l); - if(findVariable(mb, nme) >= 0 && isTid(s->op2)) { - /*it is an array related join with a tid - * send the right input to the output - * i.e tids does not do something useful*/ - s->nr = l; - return s->nr; - }/* check if we have two input variables in the right argument (case: tid join bat)*/ - snprintf(nme, SMALLBUFSIZ, "Y_%d", r); - if(findVariable(mb, nme) >= 0 && isTid(s->op1)) { - /*it is an array related join with a tid - * send the right input to the output - * i.e tids does not do something useful*/ - s->nr = r; - return s->nr; - } - /* delta bat */ if (s->op3) { - char nme[SMALLBUFSIZ]; int uval = -1; snprintf(nme, SMALLBUFSIZ, "r1_%d", r); @@ -1849,6 +1824,9 @@ static int else q = newStmt2(mb, algebraRef, leftjoinRef); + if(s->op1->type == st_tid && s->op2->type == st_bat && isArray(s->op2->op4.cval->t)) + q = pushReturn(mb, q, newTmpVariable(mb, TYPE_ptr)); + q = pushArgument(mb, q, l); snprintf(nme, SMALLBUFSIZ, "Y_%d", l); if((arraySecondVar = findVariable(mb, nme)) >= 0) @@ -2003,7 +1981,6 @@ static int if (s->flag) s->nr = s->op1->op2->nr; } else if (s->flag) { - char nme[SMALLBUFSIZ]; int v = -1; snprintf(nme, SMALLBUFSIZ, "r%d_%d", s->flag, l); @@ -2247,9 +2224,9 @@ static int q = pushStr(mb, q, s->op4.aggrval->aggr->query); } - if (s->op1->type != st_list) { + if (s->op1->type != st_list) q = pushArgument(mb, q, l); - } else { + else { for (i=0, n = s->op1->op4.lval->h; n; n = n->next, i++) { stmt *op = n->data; @@ -2768,7 +2745,6 @@ static int } break; /* REMOVED IT case st_cells: { int l; - char nme[SMALLBUFSIZ]; int uval = -1; if ((l = _dumpstmt(sql, mb, s->op1)) < 0) _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list