Changeset: 7e2eb2473440 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7e2eb2473440
Modified Files:
geom/monetdb5/geom.h
geom/monetdb5/geom.mal
geom/monetdb5/geomPoints.c
geom/sql/40_geom.sql
Branch: geo
Log Message:
PBSM removed
diffs (truncated from 762 to 300 lines):
diff --git a/geom/monetdb5/geom.h b/geom/monetdb5/geom.h
--- a/geom/monetdb5/geom.h
+++ b/geom/monetdb5/geom.h
@@ -271,9 +271,5 @@ geom_export str wkbPointsDistance2_geom_
geom_export str wkbFilterWithImprints_geom_bat(bat*, wkb**, bat*, bat*);
geom_export str wkbFilterWithPBSM_geom_bat(bat*, wkb**, bat*, bat*);
-geom_export str wkbFilterWithImprints_geom_bat(bat*, wkb**, bat*, bat*);
-geom_export str wkbFilterWithImprintsAndPBSM_geom_bat(bat*, wkb**, bat*, bat*);
geom_export int isLeft( double P0x, double P0y, double P1x, double P1y, double
P2x, double P2y);
-
-geom_export str pbsmIndex_bat(int *res, int *xBAT_id, int *yBAT_id, double*
xmin, double* ymin, double* xmax, double* ymax, char** filename);
diff --git a/geom/monetdb5/geom.mal b/geom/monetdb5/geom.mal
--- a/geom/monetdb5/geom.mal
+++ b/geom/monetdb5/geom.mal
@@ -443,8 +443,8 @@ geom.prelude();
module batgeom;
-#unsafe prevents mitosis from parallelising it
-command pbsmIndex{unsafe}(x:bat[:oid,:dbl], y:bat[:oid,:dbl], xmin:dbl,
ymin:dbl, xmax:dbl, ymax:dbl, filename:str) :bat[:oid,:int] address
pbsmIndex_bat;
+#unsafe prevents mitosis from parallelising it (no it is not true)
+command pbsmIndex{unsafe}(x:bat[:oid,:dbl], y:bat[:oid,:dbl], xmin:dbl,
ymin:dbl, xmax:dbl, ymax:dbl) :bat[:oid,:int] address pbsmIndex_bat;
#the 1 version of the functions use geos the 2 versions have custom
implementations
diff --git a/geom/monetdb5/geomPoints.c b/geom/monetdb5/geomPoints.c
--- a/geom/monetdb5/geomPoints.c
+++ b/geom/monetdb5/geomPoints.c
@@ -22,6 +22,7 @@
#include "geom.h"
#include "time.h"
+#include "unistd.h"
typedef struct pbsm_ptr {
BUN offset;
@@ -30,6 +31,10 @@ typedef struct pbsm_ptr {
static pbsm_ptr *pbsm_idx = NULL;
static oid *oids = NULL;
+static mbr *limits = NULL;
+
+//hard coded filename
+static char* filename = "../pbsmIndex_20m";
//it gets two BATs with x,y coordinates and returns a new BAT with the points
@@ -374,6 +379,8 @@ static str pnpoly_(int *out, const GEOSG
GDKfree(xPoints);
GDKfree(yPoints);
//fprintf(stderr, "Contains2: IN %u - OUT %u\n", (unsigned int)BATcount(bpx),
(unsigned int)BATcount(bo));
+fprintf(stderr, "Contains2: %u, %u\n", (unsigned int)BATcount(bo), (unsigned
int)bo->hseqbase);
+
return MAL_SUCCEED;
}
@@ -810,137 +817,6 @@ clean:
return ret;
}
-/*
-static BAT* BATMBRfilter(double xmin, double ymin, double xmax, double ymax,
wkb** geomWKB, int srid) {
- BAT *outBAT = NULL, *leftBottomBAT = NULL, *leftTopBAT = NULL,
*rightBottomBAT = NULL, *rightTopBAT = NULL;
- double xmid, ymid;
- wkb* leftBottomPolygonWKB = NULL, *leftTopPolygonWKB = NULL,
*rightBottomPolygonWKB = NULL, *rightTopPolygonWKB = NULL;
- bit leftBottomBit, leftTopBit, rightBottomBit, rightTopBit;
- str err;
- unsigned int candidatesNum = 0;
-
- //termination condition: If range smaller that thr do not split further
- if(xmax-xmin < 3.0 || ymax-ymin < 3.0) {
- fprintf(stderr, "((%f, %f),(%f, %f)): END\n", xmin, ymin, xmax,
ymax);
- return outBAT;
- }
-
- xmid = xmin + (xmax-xmin)/2.0;
- ymid = ymin + (ymax-ymin)/2.0;
-
- //check the four new polygons
- //left botton: ((xmin,ymin), (xmid,ymid))
- fprintf(stderr, "((%f, %f),(%f, %f)): Left Bottom Polygon ((%f,
%f),(%f, %f))\n", xmin, ymin, xmax, ymax, xmin, ymin, xmid, ymid);
- if((err=wkbEnvelopeFromCoordinates(&leftBottomPolygonWKB, &xmin, &ymin,
&xmid, &ymid, &srid)) != MAL_SUCCEED) {
- GDKerror("BATMBRfilter: %s", err);
- GDKfree(err);
- return NULL;
- }
- if((err=wkbIntersects(&leftBottomBit, &leftBottomPolygonWKB, geomWKB))
!= MAL_SUCCEED) {
- GDKerror("BATMBRfilter: %s", err);
- GDKfree(err);
- return NULL;
- }
- if(leftBottomBit) {
-// fprintf(stderr, "((%f, %f),(%f, %f)): Left Bottom Polygon
intersects with geometry\n", xmin, ymin, xmax, ymax);
- leftBottomBAT = BATMBRfilter(xmin, ymin, xmid, ymid, geomWKB,
srid);
- if(leftBottomBAT)
- candidatesNum += BATcount(leftBottomBAT);
- } else fprintf(stderr, "((%f, %f),(%f, %f)): Left Bottom Polygon does
NOT intersect with geometry\n", xmin, ymin, xmax, ymax);
-
- //left top: ((xmin,ymid),(xmid,ymax))
- fprintf(stderr, "((%f, %f),(%f, %f)): Left Top Polygon ((%f, %f),(%f,
%f))\n", xmin, ymin, xmax, ymax, xmin, ymid, xmid, ymax);
- if((err=wkbEnvelopeFromCoordinates(&leftTopPolygonWKB, &xmin, &ymid,
&xmid, &ymax, &srid)) != MAL_SUCCEED) {
- GDKerror("BATMBRfilter: %s", err);
- GDKfree(err);
- return NULL;
- }
- if((err=wkbIntersects(&leftTopBit, &leftTopPolygonWKB, geomWKB)) !=
MAL_SUCCEED) {
- GDKerror("BATMBRfilter: %s", err);
- GDKfree(err);
- return NULL;
- }
- if(leftTopBit) {
-// fprintf(stderr, "((%f, %f),(%f, %f)): Left Top Polygon
intersects with geometry\n", xmin, ymin, xmax, ymax);
- leftTopBAT = BATMBRfilter(xmin, ymid, xmid, ymax, geomWKB,
srid);
- if(leftTopBAT)
- candidatesNum += BATcount(leftTopBAT);
-
- } else fprintf(stderr, "((%f, %f),(%f, %f)): Left Top Polygon does NOT
intersect with geometry\n", xmin, ymin, xmax, ymax);
-
- //right bottom: ((xmid,ymin),(xmax,ymid))
- fprintf(stderr, "((%f, %f),(%f, %f)): Right Bottom Polygon ((%f,
%f),(%f, %f))\n", xmin, ymin, xmax, ymax, xmid, ymin, xmax, ymid);
- if((err=wkbEnvelopeFromCoordinates(&rightBottomPolygonWKB, &xmid,
&ymin, &xmax, &ymid, &srid)) != MAL_SUCCEED) {
- GDKerror("BATMBRfilter: %s", err);
- GDKfree(err);
- return NULL;
- }
- if((err=wkbIntersects(&rightBottomBit, &rightBottomPolygonWKB,
geomWKB)) != MAL_SUCCEED) {
- GDKerror("BATMBRfilter: %s", err);
- GDKfree(err);
- return NULL;
- }
- if(rightBottomBit) {
-// fprintf(stderr, "((%f, %f),(%f, %f)): Right Bottom Polygon
intersects with geometry\n", xmin, ymin, xmax, ymax);
- rightBottomBAT = BATMBRfilter(xmid, ymin, xmax, ymid, geomWKB,
srid);
- if(rightBottomBAT)
- candidatesNum += BATcount(rightBottomBAT);
-
- } else fprintf(stderr, "((%f, %f),(%f, %f)): Right Bottom Polygon does
NOT intersect with geometry\n", xmin, ymin, xmax, ymax);
-
- //right top: ((xmid,ymid),(xmax,ymax))
- fprintf(stderr, "((%f, %f),(%f, %f)): Right Top Polygon ((%f, %f),(%f,
%f))\n", xmin, ymin, xmax, ymax, xmid, ymid, xmax, ymax);
- if((err=wkbEnvelopeFromCoordinates(&rightTopPolygonWKB, &xmid, &ymid,
&xmax, &ymax, &srid)) != MAL_SUCCEED) {
- GDKerror("BATMBRfilter: %s", err);
- GDKfree(err);
- return NULL;
- }
- if((err=wkbIntersects(&rightTopBit, &rightTopPolygonWKB, geomWKB)) !=
MAL_SUCCEED) {
- GDKerror("BATMBRfilter: %s", err);
- GDKfree(err);
- return NULL;
- }
- if(rightTopBit) {
-// fprintf(stderr, "((%f, %f),(%f, %f)): Right Top Polygon
intersects with geometry\n", xmin, ymin, xmax, ymax);
- rightTopBAT = BATMBRfilter(xmid, ymid, xmax, ymax, geomWKB,
srid);
- if(rightTopBAT)
- candidatesNum += BATcount(rightTopBAT);
-
- } else fprintf(stderr, "((%f, %f),(%f, %f)): Right Top Polygon does NOT
intersect with geometry\n", xmin, ymin, xmax, ymax);
-/----/
-
- //collect all the results and return a new BAT
- if ((outBAT = BATnew(TYPE_void, TYPE_oid, candidatesNum, TRANSIENT)) ==
NULL) {
- GDKerror("BATMBRfilter: Could not create new BAT for the
output");
- return NULL;
- }
-
- //set the first idx of the new BAT equal to that of the x BAT (which is
equal to the y BAT)
- BATseqbase(outBAT, geometriesBAT->hseqbase);
-
- //iterator over the BATs
- geometriesBAT_iter = bat_iterator(geometriesBAT);
-
- BATloop(geometriesBAT, p, q) { //iterate over all valid elements
- str err = NULL;
- double val = 0.0;
-
- wkb *geometryWKB = (wkb*) BUNtail(geometriesBAT_iter, p);
- if ((err = wkbDistance(&val, geomWKB, &geometryWKB)) !=
MAL_SUCCEED) {
- BBPreleaseref(outBAT->batCacheid);
- GDKerror("BATDistance: %s", err);
- GDKfree(err);
- return NULL;
- }
- BUNappend(outBAT,&val,TRUE);
- }
-/----/
- return outBAT;
-
-}
-*/
-
-
str wkbFilterWithImprints_geom_bat(bat* candidateOIDsBAT_id, wkb** geomWKB,
bat* xBAT_id, bat* yBAT_id) {
BAT *xBAT=NULL, *yBAT=NULL, *xCandidateOIDsBAT=NULL,
*candidateOIDsBAT=NULL;
mbr* geomMBR;
@@ -1005,555 +881,3 @@ str wkbFilterWithImprints_geom_bat(bat*
BBPkeepref(*candidateOIDsBAT_id = candidateOIDsBAT->batCacheid);
return MAL_SUCCEED;
}
-
-
-/* PBSM */
-
-static char *
-PBSMcomputeindex1(const dbl *x, const dbl *y, BUN n, double minx, double maxx,
double miny, double maxy, oid seqbase) {
- sht *cells;
- BAT *pbsm;
- unsigned long i;
- int shift = sizeof(sht) * 8 / 2;
- sht prevCell, cell;
- unsigned long m = 0, prevO;
-
-
- if((pbsm = BATnew(TYPE_void, TYPE_sht, n, TRANSIENT)) == NULL)
- throw(MAL, "pbsm.createindex", MAL_MALLOC_FAIL);
- cells = (sht*) Tloc(pbsm, BUNfirst(pbsm));
-
- // calculate the pbsm values
- for (i = 0; i < n; i++) {
- unsigned char cellx = ((x[i] - minx)/(maxx - minx))*UCHAR_MAX;
- unsigned char celly = ((y[i] - miny)/(maxy - miny))*UCHAR_MAX;
- cells[i] = ((((unsigned short) cellx) << shift)) | ((unsigned
short) celly);
- }
-
- // order the BAT according to the cell values
- /* set some properties */
- BATsetcount(pbsm,n);
- BATseqbase(pbsm, 0);
- pbsm->hsorted = 1;
- pbsm->hrevsorted = (BATcount(pbsm) <= 1);
- pbsm->tsorted = 0;
- pbsm->trevsorted = 0;
- pbsm->hdense = true;
- pbsm->tdense = false;
- BATseqbase(pbsm, seqbase);
- BATmaterialize(pbsm);
- //BATderiveProps(pbsm, false);
- //BATassertProps(pbsm);
- pbsm = BATorder(BATmirror(pbsm));
- //BATprint(pbsm);
-
- // compress the head
- cells = (sht*) Hloc(pbsm, BUNfirst(pbsm));
- oids = (oid*) Tloc(pbsm, BUNfirst(pbsm));
-
- prevCell = cells[0];
- cell = cells[0];
- m = 0;
- prevO = 0;
- for (i = 0; i < n; i++) {
- cell = cells[i];
-
- if (cell == prevCell) {
- m++;
- } else {
- pbsm_idx[cell - SHRT_MIN].offset = prevO;
- pbsm_idx[cell - SHRT_MIN].count = m;
- prevCell = cell;
- prevO = i;
- m = 1;
- }
- }
- pbsm_idx[cell - SHRT_MIN].offset = prevO;
- pbsm_idx[cell - SHRT_MIN].count = m;
-
- // clean up
- pbsm->T->heap.base = NULL; // need to keep the oids array
- BBPreleaseref(pbsm->batCacheid);
-
- return MAL_SUCCEED;
-}
-
-
-static char *
-PBSMcomputeindex2(const dbl *x, const dbl *y, BUN n, double minx, double maxx,
double miny, double maxy, oid seqbase) {
- unsigned long *tmpCount;
- unsigned long i;
- int shift = sizeof(sht) * 8 / 2;
-
- if ((pbsm_idx = GDKmalloc(USHRT_MAX * sizeof(pbsm_ptr))) == NULL)
- throw(MAL, "pbsm.createindex", MAL_MALLOC_FAIL);
-
- if ((oids = GDKmalloc(n * sizeof(oid))) == NULL) {
- GDKfree(pbsm_idx);
- throw(MAL, "pbsm.createindex", MAL_MALLOC_FAIL);
- }
-
- if ((tmpCount = GDKmalloc(USHRT_MAX * sizeof(unsigned long))) == NULL) {
- GDKfree(pbsm_idx);
- GDKfree(oids);
- throw(MAL, "pbsm.createindex", MAL_MALLOC_FAIL);
- }
-
- for (i = 0; i < USHRT_MAX; i++) {
- pbsm_idx[i].count = 0;
- pbsm_idx[i].offset = 0;
- }
-
- for (i = 0; i < USHRT_MAX; i++) {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list