Changeset: 7f89e45474bd for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/7f89e45474bd
Modified Files:
        gdk/gdk_rtree.c
        geom/monetdb5/geomBulk.c
Branch: geo-update
Log Message:

Improves RTree search candidates array handling


diffs (53 lines):

diff --git a/gdk/gdk_rtree.c b/gdk/gdk_rtree.c
--- a/gdk/gdk_rtree.c
+++ b/gdk/gdk_rtree.c
@@ -302,7 +302,7 @@ static int
 f (rtree_id_t id, void *context) {
        struct results_rtree *results_rtree = (struct results_rtree *) context;
        results_rtree->candidates[results_rtree->results_next++] = (BUN) id;
-       results_rtree->results_left -= 1;
+       --results_rtree->results_left;
        return results_rtree->results_left <= 0;
 }
 
@@ -330,21 +330,26 @@ RTREEsearch(BAT *b, mbr_t *inMBR, int re
        if (rtree != NULL) {
                //Increase ref, we're gonna use the index
                RTREEincref(pb);
-               BUN *candidates = GDKmalloc(result_limit*sizeof(BUN));
-               memset(candidates,BUN_NONE,result_limit*sizeof(BUN));
+               BUN *candidates = GDKmalloc((result_limit + 1) * SIZEOF_BUN);
+               memset(candidates, 0, (result_limit + 1) * SIZEOF_BUN);
 
                rtree_coord_t rect[4];
                rect[0] = inMBR->xmin;
                rect[1] = inMBR->ymin;
                rect[2] = inMBR->xmax;
                rect[3] = inMBR->ymax;
+
                struct results_rtree results;
                results.results_next = 0;
                results.results_left = result_limit;
                results.candidates = candidates;
+
                rtree_search(rtree, (const rtree_coord_t*) rect, f, &results);
+               candidates[result_limit - results.results_left] = BUN_NONE;
+
                //Finished using the index, decrease ref
                RTREEdecref(pb);
+
                return candidates;
        } else
                return NULL;
diff --git a/geom/monetdb5/geomBulk.c b/geom/monetdb5/geomBulk.c
--- a/geom/monetdb5/geomBulk.c
+++ b/geom/monetdb5/geomBulk.c
@@ -56,7 +56,7 @@ filterSelectRTree(bat* outid, const bat 
        //Cycle through rtree candidates
        //If there is a original candidate list, make sure the rtree cand is in 
there
        //Then do the actual calculation for the predicate using the GEOS 
function
-       for (int i = 0; results_rtree[i] != 18446744073709551615U && i < (int) 
b->batCount; i++) {
+       for (int i = 0; results_rtree[i] != BUN_NONE && i < (int) b->batCount; 
i++) {
                oid cand = results_rtree[i];
                //If we have a candidate list that is not dense, we need to 
check if the rtree candidate is also on the original candidate list
                if (ci.tpe != cand_dense) {
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to