Changeset: edbda3ed63d5 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=edbda3ed63d5
Modified Files:
        gdk/gdk_arrays.c
        monetdb5/modules/kernel/arrays.c
Branch: arrays
Log Message:

copy the array when creating candidates for the first time
+ keep candidate pointers the same for the rest of the execution
+ elsNUm = max+1 when working with cands


diffs (88 lines):

diff --git a/gdk/gdk_arrays.c b/gdk/gdk_arrays.c
--- a/gdk/gdk_arrays.c
+++ b/gdk/gdk_arrays.c
@@ -46,10 +46,10 @@ createAnalyticDim(flt);
 #define createDim(TPE) \
 gdk_dimension* createDimension_##TPE(TPE min, TPE max, TPE step) { \
        gdk_dimension *dim = GDKmalloc(sizeof(gdk_dimension)); \
-       dim->elsNum = floor((max - min )/ step)+1; \
        dim->min = 0; \
-    dim->max = dim->elsNum; \
+    dim->max = floor((max - min ) / step); \
        dim->step = 1; \
+       dim->elsNum = dim->max +1; \
        return dim; \
 }
 
@@ -79,8 +79,9 @@ gdk_array* arrayCopy(gdk_array *array) {
        gdk_array *array_copy = arrayNew(array->dimsNum);
        if(!array_copy)
                return NULL;
-       for(i=0; i<array_copy->dimsNum; i++)
-               array_copy[i] = array[i];
+       for(i=0; i<array_copy->dimsNum; i++) {
+               array_copy->dims[i] = createDimension_oid(array->dims[i]->min, 
array->dims[i]->max, array->dims[i]->step);
+       }
 
        return array_copy;
 }
@@ -429,7 +430,7 @@ BAT* projectDimension(gdk_dimension *oid
 #endif
             break;
         default:
-            fprintf(stderr, "createDimension_NEW: dimension type not 
handled\n");
+            fprintf(stderr, "projectDimension: dimension type not handled\n");
             return NULL;
     }
 
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
@@ -93,7 +93,7 @@ static str readCands(gdk_array** dimCand
 
        //if there are no candidates then everything is a candidate
        if(!dimCands && !oidCands) {
-               dimCands_in = array;
+               dimCands_in = arrayCopy(array);
                //create an empy candidates BAT
                 if((candidatesBAT_in = BATnew(TYPE_void, TYPE_oid, 0, 
TRANSIENT)) == NULL)
             throw(MAL, "algebra.subselect", GDK_EXCEPTION);
@@ -133,7 +133,7 @@ static gdk_dimension* updateCandidateDim
        /*the biggest of the mins and the smallest of the maximums */
        dim->min = dim->min > min ? dim->min : min;
        dim->max = dim->max < max ? dim->max : max;
-
+       dim->elsNum = floor((dim->max - dim->min)/dim->step)+1;
 //TODO: Take care of cases were a dimension has step <>1 as a result of 
multiple selections on it
        
        //the dimensions that are merged should have the same order
@@ -311,6 +311,9 @@ static bool updateCandidateResults(gdk_a
                                                                        
unsigned short dimNum, unsigned int min, unsigned int max) {
        gdk_dimension *dimCand_out, *dimCand_in = dimCands_in->dims[dimNum];
        
+       //the dimensions do not change
+       *dimCands_out = dimCands_in;
+
        if(!dimCand_in) {
                //the dimension is in the BAT
                //express the results in BAT and merge
@@ -334,15 +337,14 @@ static bool updateCandidateResults(gdk_a
                BATderiveProps(dimBAT, FALSE);    
                
                *candidatesBAT_out = joinBATs(candidatesBAT_in, dimBAT, array, 
dimNum);
-
-               //the dimensions do not change
-               *dimCands_out = dimCands_in;
-
+       
                return 1;
 
        }       
 
-       //merge the dimension in the candidates with the result of this 
operation
+       //update the range of the dimCand. It performs the operation on the 
pointer
+       //of the dimCand so there is no need to update the dimCands_out
+       //the result is immediately visible
        dimCand_out = updateCandidateDimensionRange(dimCand_in, min, max);
        if(!dimCand_out) {
                //cannot produce candidate. there are non-overlapping ranges
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to