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

geospatial optimiser adds filter when distance(geom, BAT) theta value 
expression is found


diffs (64 lines):

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
@@ -59,7 +59,7 @@ int OPTgeospatialImplementation(Client c
                                
                                        
if(isaBatType(getArgType(mb,oldInstrPtr[i],2))) {
                                                if(inputBAT == 1) {
-                                                       //no Filtering when 
both inputs are BATs because it cannot be parallelised)
+                                                       //no Filtering (for 
now) when both inputs are BATs
                                                        pushInstruction(mb, 
oldInstrPtr[i]);
                                                        continue;
                                                }
@@ -86,6 +86,51 @@ int OPTgeospatialImplementation(Client c
                                
                                        actions+=2; //two changes
                                }
+                       } else if(strcasecmp(getFunctionId(oldInstrPtr[i]), 
"distance") == 0 && strcasecmp(getFunctionId(oldInstrPtr[i+1]), 
"thetasubselect") == 0) {
+                               int inputBAT = 0, geomArg =0;
+                               InstrPtr bufferInstrPtr, filterInstrPtr;
+                               int bufferReturnId, filterReturnId;
+                               
+                               if(isaBatType(getArgType(mb,oldInstrPtr[i],1))) 
{
+                                       inputBAT = 1;
+                                       geomArg = 2;
+                               }
+                               
+                               if(isaBatType(getArgType(mb,oldInstrPtr[i],2))) 
{
+                                       if(inputBAT != 0) {
+                                               //no Filtering (for now) when 
both inputs are BATs
+                                               pushInstruction(mb, 
oldInstrPtr[i]);
+                                               continue;
+                                       }
+                                       inputBAT = 2;
+                                       geomArg = 1;
+                               }
+
+                               //create two new instruction
+                               bufferInstrPtr = newStmt(mb, "geom", "Buffer");
+                               filterInstrPtr = newStmt(mb, "batgeom", 
"Filter");
+                               
+                               //make new return variables
+                               bufferReturnId = newTmpVariable(mb, 
getArgType(mb, oldInstrPtr[i], geomArg)); //Buffer returns a geometry
+                               filterReturnId = newTmpVariable(mb, 
getArgType(mb, oldInstrPtr[i], inputBAT)); //Filter returns a BAT
+
+                               //set the arguments for the Buffer
+                               setReturnArgument(bufferInstrPtr, 
bufferReturnId);
+                               bufferInstrPtr = pushArgument(mb, 
bufferInstrPtr, getArg(oldInstrPtr[i], geomArg));
+                               bufferInstrPtr = pushArgument(mb, 
bufferInstrPtr, getArg(oldInstrPtr[i+1], 3));
+                               
+                               //set the arguments for the Filter
+                               setReturnArgument(filterInstrPtr, 
filterReturnId);
+                               filterInstrPtr = pushArgument(mb, 
filterInstrPtr, bufferReturnId);
+                               filterInstrPtr = pushArgument(mb, 
filterInstrPtr, getArg(oldInstrPtr[i], inputBAT));
+
+                               //replace the BAT arguments of the contains 
function with the BAT of the new instruction (the filtered BAT) 
+                               delArgument(oldInstrPtr[i], inputBAT);
+                               pushInstruction(mb, oldInstrPtr[i]);
+                               setArgument(mb, oldInstrPtr[i], inputBAT, 
filterReturnId);
+                               
+                               actions+=3;
+
                        } else //put back all other instructions from batgeom
                                pushInstruction(mb, oldInstrPtr[i]);
                } else //put all other instructions back
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to