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

geospatial optimiser source files


diffs (95 lines):

diff --git a/monetdb5/optimizer/opt_geospatial.c 
b/monetdb5/optimizer/opt_geospatial.c
new file mode 100644
--- /dev/null
+++ b/monetdb5/optimizer/opt_geospatial.c
@@ -0,0 +1,53 @@
+#include "monetdb_config.h"
+#include "opt_geospatial.h"
+//#include "mal_instruction.h"
+//#include "mal_interpreter.h"
+
+
+int OPTgeospatialImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci) {
+       int i=0, actions = 0;
+       int nextFreeSlot = mb->stop; //up to this there are instructions
+       InstrPtr *oldInstrPtr = mb->stmt; //pointer to the first instruction
+       int slimit = mb->ssize; //what is this?
+       InstrPtr newInstrPtr;
+       int newInstrReturnValue;
+
+       (void) pci;
+       (void) stk;     
+       (void) cntxt;
+
+       //create new mal stack
+       if(newMalBlkStmt(mb, slimit) < 0)
+               return 0;
+       
+
+       //iterate over the instructions and put them back in the stach
+       for(i=0; i<nextFreeSlot; i++) {
+
+               //chech the module and function name
+               if(getModuleId(oldInstrPtr[i]) && 
!strcasecmp(getModuleId(oldInstrPtr[i]),"batgeom"))   {
+                       if(strcasecmp(getFunctionId(oldInstrPtr[i]), 
"contains") == 0) {
+
+                               //create the new instruction
+                               newInstrPtr = newStmt(mb, "batgeom", 
"MBRfilter");
+                               //create the return variable of the new 
instruction
+                               newInstrReturnValue = newVariable(mb, 
GDKstrdup("result"), newBatType(TYPE_oid, getArgType(mb,oldInstrPtr[i],2)));
+                               //set the return and input arguments of the new 
instruction
+                               setReturnArgument(newInstrPtr, 
newInstrReturnValue);
+                               newInstrPtr = pushArgument(mb, newInstrPtr, 
getArg(oldInstrPtr[i],1));
+                               newInstrPtr = pushArgument(mb, newInstrPtr, 
getArg(oldInstrPtr[i],2));
+                       
+                               //replace the second argument of the contains 
function with the results of the new instruction (the filtered results) 
+                               delArgument(oldInstrPtr[i], 2);
+                               pushInstruction(mb, oldInstrPtr[i]);
+                               setArgument(mb, oldInstrPtr[i], 2, 
newInstrReturnValue);
+                               
+                               actions++;
+                       }
+               } else //put all other instructions back
+                       pushInstruction(mb, oldInstrPtr[i]);
+       }
+       
+       GDKfree(oldInstrPtr);
+       return actions;
+}
diff --git a/monetdb5/optimizer/opt_geospatial.h 
b/monetdb5/optimizer/opt_geospatial.h
new file mode 100644
--- /dev/null
+++ b/monetdb5/optimizer/opt_geospatial.h
@@ -0,0 +1,32 @@
+/*
+ * The contents of this file are subject to the MonetDB Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.monetdb.org/Legal/MonetDBLicense
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the MonetDB Database System.
+ *
+ * The Initial Developer of the Original Code is CWI.
+ * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+ * Copyright August 2008-2014 MonetDB B.V.
+ * All Rights Reserved.
+ */
+
+#ifndef _OPT_GEOM_
+#define _OPT_GEOM_
+#include "opt_prelude.h"
+#include "opt_support.h"
+#include "mal_interpreter.h"
+#include "mal_instruction.h"
+#include "mal_function.h"
+
+opt_export int OPTgeospatialImplementation(Client cntxt, MalBlkPtr mb, 
MalStkPtr stk, InstrPtr pci);
+
+#define OPTDEBUGgeospatial  if ( optDebug & (1 <<DEBUG_OPT_GEOSPATIAL) )
+
+#endif
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to