Changeset: 043e4c32271e for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=043e4c32271e
Added Files:
        geom/monetdb5/31_grid.mal
        geom/monetdb5/grid.c
        geom/monetdb5/grid.h
        geom/monetdb5/grid.mal
        geom/sql/41_grid.sql
Modified Files:
        geom/monetdb5/Makefile.ag
        geom/sql/40_geom.sql
        geom/sql/Makefile.ag
Branch: grid
Log Message:

Added a skeleton for implementing a grid index in the form of a filter function


diffs (205 lines):

diff --git a/geom/monetdb5/31_grid.mal b/geom/monetdb5/31_grid.mal
new file mode 100644
--- /dev/null
+++ b/geom/monetdb5/31_grid.mal
@@ -0,0 +1,9 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0.  If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
+
+# This loads the MonetDB/GIS module
+library geom;
+include grid;
diff --git a/geom/monetdb5/Makefile.ag b/geom/monetdb5/Makefile.ag
--- a/geom/monetdb5/Makefile.ag
+++ b/geom/monetdb5/Makefile.ag
@@ -15,7 +15,7 @@ INCLUDES = ../lib \
 lib__geom = {
        MODULE
        DIR = libdir/monetdb5
-       SOURCES = geom.h geom.c geomBulk.c geom_upgrade.c
+       SOURCES = geom.h geom.c geomBulk.c geom_upgrade.c grid.h grid.c
        LIBS = ../lib/libgeom \
                   ../../gdk/libbat \
               ../../common/stream/libstream \
@@ -35,4 +35,16 @@ headers_autoload = {
        SOURCES = 30_geom.mal
 }
 
-EXTRA_DIST = 30_geom.mal geom.mal
+headers_mal_grid = {
+       HEADERS = mal
+       DIR = libdir/monetdb5
+       SOURCES = grid.mal
+}
+
+headers_autoload_grid = {
+       HEADERS = mal
+       DIR = libdir/monetdb5/autoload
+       SOURCES = 31_grid.mal
+}
+
+EXTRA_DIST = 30_geom.mal geom.mal 31_grid.mal grid.mal
diff --git a/geom/monetdb5/grid.c b/geom/monetdb5/grid.c
new file mode 100644
--- /dev/null
+++ b/geom/monetdb5/grid.c
@@ -0,0 +1,60 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
+ */
+
+/*
+ * @a Kostis Kyzirakos, Foteini Alvanaki
+ * @* A grid based index
+ */
+
+#include "grid.h"
+
+str
+GRIDdistance(bit * res, lng * x1, lng * y1, lng * x2, lng * y2, int * distance)
+{
+       (void)res;
+       (void)x1;
+       (void)y1;
+       (void)x2;
+       (void)y2;
+       (void)distance;
+
+       return MAL_SUCCEED;
+}
+
+str
+GRIDdistancesubselect(bat * res, bat * x1, bat * y1, bat * cand1, lng * x2, 
lng * y2, int * distance, bit * anti)
+{
+       (void)res;
+       (void)x1;
+       (void)y1;
+       (void)cand1;
+       (void)x2;
+       (void)y2;
+       (void)distance;
+       (void)anti;
+
+       return MAL_SUCCEED;
+}
+
+str
+GRIDdistancesubjoin(bat *res1, bat * res2,bat * x1, bat * y1, bat * x2, bat * 
y2, int * distance, bat * s1, bat * s2, bit * nil, lng * estimate)
+{
+       (void)res1;
+       (void)res2;
+       (void)x1;
+       (void)y1;
+       (void)x2;
+       (void)y2;
+       (void)s1;
+       (void)s2;
+       (void)distance;
+       (void)nil;
+       (void)estimate;
+
+       return MAL_SUCCEED;
+}
diff --git a/geom/monetdb5/grid.h b/geom/monetdb5/grid.h
new file mode 100644
--- /dev/null
+++ b/geom/monetdb5/grid.h
@@ -0,0 +1,29 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
+ */
+
+/*
+ * @a Kostis Kyzirakos, Foteini Alvanaki
+ */
+
+#include <monetdb_config.h>
+#include <geom.h>
+
+#ifdef WIN32
+#ifndef LIBGEOM
+#define geom_export extern __declspec(dllimport)
+#else
+#define geom_export extern __declspec(dllexport)
+#endif
+#else
+#define geom_export extern
+#endif
+
+
+geom_export str GRIDdistance(bit * res, lng * x1, lng * y1, lng * x2, lng * 
y2, int * distance);
+geom_export str GRIDdistancesubselect(bat * res, bat * x1, bat * y1, bat * 
cand1, lng * x2, lng * y2, int * distance, bit * anti);
+geom_export str GRIDdistancesubjoin(bat *res1, bat * res2,bat * x1, bat * y1, 
bat * x2, bat * y2, int * distance, bat * s1, bat * s2, bit * nil, lng * 
estimate);
diff --git a/geom/monetdb5/grid.mal b/geom/monetdb5/grid.mal
new file mode 100644
--- /dev/null
+++ b/geom/monetdb5/grid.mal
@@ -0,0 +1,20 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0.  If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
+
+module grid;
+
+command grid.distance(x1:lng, y1:lng, x2:lng, y2:lng, d:int) :bit
+address GRIDdistance
+comment "Return true when the cartesian distance between two points is less 
than the specified distance";
+
+command grid.distancesubselect(x1:bat[:lng], y1:bat[:lng], cand1:bat[:oid], 
x2:lng, y2:lng, d:int, anti:bit):bat[:oid]
+address GRIDdistancesubselect
+comment "Return the OIDs of points that are close to the specified point";
+
+command grid.distancesubjoin(x1:bat[:lng], y1:bat[:lng], x2:bat[:lng], 
y2:bat[:lng], d:int, s1:bat[:oid], s2:bat[:oid], nil_matches:bit, 
estimate:lng)(r1:bat[:oid],r2:bat[:oid])
+address GRIDdistancesubjoin
+comment "Returns the point pairs that with distance less than the specified 
distance";
+
diff --git a/geom/sql/40_geom.sql b/geom/sql/40_geom.sql
--- a/geom/sql/40_geom.sql
+++ b/geom/sql/40_geom.sql
@@ -4456,3 +4456,4 @@ CREATE FUNCTION ST_DumpPoints(geom Geome
 ---------------------------- Miscellaneous ------------------------------
 -------------------------------------------------------------------------
 CREATE FUNCTION Contains(a Geometry, x double, y double) RETURNS BOOLEAN 
external name geom."Contains";
+
diff --git a/geom/sql/41_grid.sql b/geom/sql/41_grid.sql
new file mode 100644
--- /dev/null
+++ b/geom/sql/41_grid.sql
@@ -0,0 +1,10 @@
+-- This Source Code Form is subject to the terms of the Mozilla Public
+-- License, v. 2.0.  If a copy of the MPL was not distributed with this
+-- file, You can obtain one at http://mozilla.org/MPL/2.0/.
+--
+-- Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
+
+-------------------------------------------------------------------------
+----------------------- GRID related functions --------------------------
+-------------------------------------------------------------------------
+CREATE FILTER FUNCTION distance(x1 bigint, y1 bigint, x2 bigint, y2 bigint, 
distance int) EXTERNAL NAME grid.distance;
diff --git a/geom/sql/Makefile.ag b/geom/sql/Makefile.ag
--- a/geom/sql/Makefile.ag
+++ b/geom/sql/Makefile.ag
@@ -10,4 +10,10 @@ headers_sql = {
        SOURCES = 40_geom.sql
 }
 
+headers_sql_grid = {
+       HEADERS = sql
+       DIR = libdir/monetdb5/createdb
+       SOURCES = 41_grid.sql
+}
+
 EXTRA_DIST_DIR = Tests
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to