Changeset: 0d9300382c25 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0d9300382c25
Modified Files:
        geom/monetdb5/geom.c
        geom/monetdb5/geom.mal
        monetdb5/optimizer/opt_geospatial.c
        monetdb5/optimizer/opt_pipes.c
Branch: geo
Log Message:

geospatial optimizer fixed to handle as input a geometry and a BAT
functions adpated accordingly


diffs (169 lines):

diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -164,7 +164,7 @@ geom_export str wkbCovers(bit *out, wkb 
 geom_export str wkbCoveredBy(bit *out, wkb **geomWKB_a, wkb **geomWKB_b);
 
 geom_export str wkbContainsFilter_bat(int* aBATfiltered_id, int* 
bBATfiltered_id, int* aBAT_id, int* bBAT_id);
-geom_export str wkbContainsFilter_geom_bat(int* aBATfiltered_id, int* 
bBATfiltered_id, wkb** geomWKB, int* BAToriginal_id);
+geom_export str wkbContainsFilter_geom_bat(wkb** outWKB, int* bBATfiltered_id, 
wkb** geomWKB, int* BAToriginal_id);
 //LocateAlong
 //LocateBetween
 
@@ -3108,8 +3108,8 @@ str wkbContainsFilter_bat(int* aBATfilte
 /**
  * It filters the geometry in the second BAT with respect to the MBR of the 
geometry in the first BAT.
  **/
-str wkbContainsFilter_geom_bat(int* aBATfiltered_id, int* bBATfiltered_id, 
wkb** geomWKB, int* BAToriginal_id) {
-       BAT *aBATfiltered = NULL, *bBATfiltered = NULL, *BAToriginal = NULL;
+str wkbContainsFilter_geom_bat(wkb** outWKB, int* bBATfiltered_id, wkb** 
geomWKB, int* BAToriginal_id) {
+       BAT *bBATfiltered = NULL, *BAToriginal = NULL;
        wkb *bWKB = NULL;
        bit outBIT;
        BATiter BAT_iter;
@@ -3128,19 +3128,13 @@ str wkbContainsFilter_geom_bat(int* aBAT
                throw(MAL, "batgeom.MBRfilter", "The arguments must have dense 
and aligned heads");
        }
 
-       //create the new BATs
-       if ((aBATfiltered = BATnew(TYPE_void, ATOMindex("wkb"), 
BATcount(BAToriginal), TRANSIENT)) == NULL) {
+       //create the new BAT
+       if ((bBATfiltered = BATnew(TYPE_void, ATOMindex("wkb"), 
BATcount(BAToriginal), TRANSIENT)) == NULL) {
                BBPreleaseref(BAToriginal->batCacheid);
                throw(MAL, "batgeom.MBRfilter", MAL_MALLOC_FAIL);
        }
-       if ((bBATfiltered = BATnew(TYPE_void, ATOMindex("wkb"), 
BATcount(BAToriginal), TRANSIENT)) == NULL) {
-               BBPreleaseref(BAToriginal->batCacheid);
-               BBPreleaseref(aBATfiltered->batCacheid);
-               throw(MAL, "batgeom.MBRfilter", MAL_MALLOC_FAIL);
-       }
 
        //set the first idx of the output BATs equal to that of the aBAT
-       BATseqbase(aBATfiltered, BAToriginal->hseqbase);
        BATseqbase(bBATfiltered, BAToriginal->hseqbase);
 
        //iterator over the BAT
@@ -3150,7 +3144,6 @@ str wkbContainsFilter_geom_bat(int* aBAT
        if((err = wkbMBR(&geomMBR, geomWKB)) != MAL_SUCCEED) {
                str msg;
                BBPreleaseref(BAToriginal->batCacheid);
-               BBPreleaseref(aBATfiltered->batCacheid);
                BBPreleaseref(bBATfiltered->batCacheid);
                msg = createException(MAL, "batgeom.wkbFilter", "%s", err);
                GDKfree(err);
@@ -3166,7 +3159,6 @@ str wkbContainsFilter_geom_bat(int* aBAT
                if((err = wkbMBR(&bMBR, &bWKB)) != MAL_SUCCEED) {
                        str msg;
                        BBPreleaseref(BAToriginal->batCacheid);
-                       BBPreleaseref(aBATfiltered->batCacheid);
                        BBPreleaseref(bBATfiltered->batCacheid);
                        msg = createException(MAL, "batgeom.wkbFilter", "%s", 
err);
                        GDKfree(err);
@@ -3178,7 +3170,6 @@ str wkbContainsFilter_geom_bat(int* aBAT
                if((err = mbrContains(&outBIT, &geomMBR, &bMBR)) != 
MAL_SUCCEED) {
                        str msg;
                        BBPreleaseref(BAToriginal->batCacheid);
-                       BBPreleaseref(aBATfiltered->batCacheid);
                        BBPreleaseref(bBATfiltered->batCacheid);
                        msg = createException(MAL, "batgeom.wkbFilter", "%s", 
err);
                        GDKfree(err);
@@ -3187,7 +3178,6 @@ str wkbContainsFilter_geom_bat(int* aBAT
                        return msg;
                }
                if(outBIT) {
-                       BUNappend(aBATfiltered,*geomWKB, TRUE); //add the 
result to the bBAT
                        BUNappend(bBATfiltered,bWKB, TRUE); //add the result to 
the bBAT
                        remainingElements++;
                }
@@ -3196,17 +3186,15 @@ str wkbContainsFilter_geom_bat(int* aBAT
        }
 
        //set some properties of the new BATs
-       BATsetcount(aBATfiltered, remainingElements);
-       BATsettrivprop(aBATfiltered);
-       BATderiveProps(aBATfiltered,FALSE);
        BATsetcount(bBATfiltered, remainingElements);
        BATsettrivprop(bBATfiltered);
        BATderiveProps(bBATfiltered,FALSE);
        
        BBPreleaseref(BAToriginal->batCacheid);
-       BBPkeepref(*aBATfiltered_id = aBATfiltered->batCacheid);
        BBPkeepref(*bBATfiltered_id = bBATfiltered->batCacheid);
        
+       *outWKB = *geomWKB;
+       
        return MAL_SUCCEED;
 
 
diff --git a/geom/monetdb5/geom.mal b/geom/monetdb5/geom.mal
--- a/geom/monetdb5/geom.mal
+++ b/geom/monetdb5/geom.mal
@@ -445,7 +445,7 @@ module batgeom;
 
 command ContainsFilter{unsafe}(a:bat[:oid,:wkb], b:bat[:oid,:wkb]) 
(aFiltered:bat[:oid,:wkb], bFiltered:bat[:oid,:wkb]) address 
wkbContainsFilter_bat
 comment "Filters the points in the bats according to the MBR of the other 
bat.";
-command ContainsFilter{unsafe}(a:wkb, b:bat[:oid,:wkb]) 
(aFiltered:bat[:oid,:wkb], bFiltered:bat[:oid,:wkb]) address 
wkbContainsFilter_geom_bat
+command ContainsFilter{unsafe}(a:wkb, b:bat[:oid,:wkb]) (w:wkb, 
bFiltered:bat[:oid,:wkb]) address wkbContainsFilter_geom_bat
 comment "Filters the points in the bats according to the MBR of the other 
bat.";
 
 #command point(x:bat[:oid,:dbl],y:bat[:oid,:dbl]) :bat[:oid,:wkb]
diff --git a/monetdb5/optimizer/opt_geospatial.c 
b/monetdb5/optimizer/opt_geospatial.c
--- a/monetdb5/optimizer/opt_geospatial.c
+++ b/monetdb5/optimizer/opt_geospatial.c
@@ -30,9 +30,9 @@ int OPTgeospatialImplementation(Client c
 
                                //create the new instruction
                                newInstrPtr = newStmt(mb, "batgeom", 
"ContainsFilter");
-                               //create the return variables of the new 
instruction
-                               aBATreturnId = newVariable(mb, 
GDKstrdup("aBAT_filtered"), newBatType(TYPE_oid, 
getArgType(mb,oldInstrPtr[i],1)));
-                               bBATreturnId = newVariable(mb, 
GDKstrdup("bBAT_filtered"), newBatType(TYPE_oid, 
getArgType(mb,oldInstrPtr[i],2)));
+                               //create the return variables of the new 
instruction (they should be of the same with the input varibles of the old 
instruction)
+                               aBATreturnId = newVariable(mb, 
GDKstrdup("aBAT_filtered"), getArgType(mb,oldInstrPtr[i],1)); 
//newBatType(TYPE_oid, getArgType(mb,oldInstrPtr[i],1)));
+                               bBATreturnId = newVariable(mb, 
GDKstrdup("bBAT_filtered"), getArgType(mb,oldInstrPtr[i],2)); 
//newBatType(TYPE_oid, getArgType(mb,oldInstrPtr[i],2)));
                                //set the return and input arguments of the new 
instruction
                                setReturnArgument(newInstrPtr, aBATreturnId); 
//set the first return argument
                                newInstrPtr = pushReturn(mb, newInstrPtr, 
bBATreturnId); //push a second return argument
diff --git a/monetdb5/optimizer/opt_pipes.c b/monetdb5/optimizer/opt_pipes.c
--- a/monetdb5/optimizer/opt_pipes.c
+++ b/monetdb5/optimizer/opt_pipes.c
@@ -257,12 +257,38 @@ static struct PIPELINES {
         "optimizer.inline();"
         "optimizer.remap();"
         "optimizer.geospatial();"
-        "optimizer.deadcode();"
+        "optimizer.deadcode();"
         "optimizer.multiplex();"
         "optimizer.generator();"
         "optimizer.garbageCollector();",
         "experimental", NULL, NULL, 1},
-
+/*
+       {"geom_pipe",
+        "optimizer.inline();"
+        "optimizer.remap();"
+        "optimizer.costModel();"
+        "optimizer.coercions();"
+        "optimizer.evaluate();"
+        "optimizer.emptySet();"
+        "optimizer.aliases();"
+        "optimizer.geospatial();"
+        "optimizer.pushselect();"
+        "optimizer.mitosis();"
+        "optimizer.mergetable();"
+        "optimizer.deadcode();"
+        "optimizer.commonTerms();"
+        "optimizer.joinPath();"
+        "optimizer.reorder();"
+        "optimizer.deadcode();"
+        "optimizer.reduce();"
+        "optimizer.matpack();"
+        "optimizer.dataflow();"
+        "optimizer.querylog();"
+        "optimizer.multiplex();"
+        "optimizer.generator();"
+        "optimizer.garbageCollector();",
+        "experimental", NULL, NULL, 1},
+*/
 /* sentinel */
        {NULL, NULL, NULL, NULL, NULL, 0}
 };
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to