Changeset: e938d1bf0b8a for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e938d1bf0b8a Modified Files: geom/monetdb5/geom.c Branch: geo Log Message:
logic of bulk version of contained fixed. result is the cartesian combination of the inputs diffs (77 lines): diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c --- a/geom/monetdb5/geom.c +++ b/geom/monetdb5/geom.c @@ -2450,7 +2450,7 @@ str wkbContains_bat(int* outBAT_id, int* wkb *aWKB = NULL, *bWKB = NULL; bit outBIT; BATiter aBAT_iter, bBAT_iter; - BUN i=0; + BUN p_a=0, p_b=0, q_a=0, q_b=0; //get the descriptor of the BAT if ((aBAT = BATdescriptor(*aBAT_id)) == NULL) { @@ -2462,16 +2462,14 @@ str wkbContains_bat(int* outBAT_id, int* } if ( aBAT->htype != TYPE_void || //header type of aBAT not void - bBAT->htype != TYPE_void || //header type of bBAT not void - aBAT->hseqbase != bBAT->hseqbase || //the idxs of the headers of the BATs are not the same - BATcount(aBAT) != BATcount(bBAT)) { //the number of valid elements in the BATs are not the same + bBAT->htype != TYPE_void) { //header type of bBAT not void BBPreleaseref(aBAT->batCacheid); BBPreleaseref(bBAT->batCacheid); throw(MAL, "batgeom.Contains", "the arguments must have dense and aligned heads"); } - - //create a new BAT for the output - if ((outBAT = BATnew(TYPE_void, ATOMindex("bit"), BATcount(aBAT), TRANSIENT)) == NULL) { + + //create a new BAT for the output (the size of it is the product of the sizes of the two input BATs) + if ((outBAT = BATnew(TYPE_void, ATOMindex("bit"), BATcount(aBAT)*BATcount(bBAT), TRANSIENT)) == NULL) { BBPreleaseref(aBAT->batCacheid); BBPreleaseref(bBAT->batCacheid); throw(MAL, "batgeom.Contains", MAL_MALLOC_FAIL); @@ -2482,23 +2480,27 @@ str wkbContains_bat(int* outBAT_id, int* //iterator over the BATs aBAT_iter = bat_iterator(aBAT); bBAT_iter = bat_iterator(bBAT); - for (i = 0; i < BATcount(aBAT); i++) { - str err = NULL; - - aWKB = (wkb*) BUNtail(aBAT_iter, i + BUNfirst(aBAT)); - bWKB = (wkb*) BUNtail(bBAT_iter, i + BUNfirst(bBAT)); - if ((err = wkbContains(&outBIT, &aWKB, &bWKB)) != MAL_SUCCEED) { //check - str msg; - BBPreleaseref(aBAT->batCacheid); - BBPreleaseref(bBAT->batCacheid); - BBPreleaseref(outBAT->batCacheid); - msg = createException(MAL, "batgeom.Contains", "%s", err); - GDKfree(err); - return msg; + + BATloop(aBAT, p_a, q_a) { //iterate over all valid elements of aBAT + aWKB = (wkb*) BUNtail(aBAT_iter, p_a); //get the geometry + + BATloop(bBAT, p_b, q_b) { //iterate over all valid elements of bBAT + str err = NULL; + bWKB = (wkb*) BUNtail(bBAT_iter, p_b); //get the geometry + + //check first if the bounding boxe of the geometry a contains the bounding box of geometry b + + if ((err = wkbContains(&outBIT, &aWKB, &bWKB)) != MAL_SUCCEED) { //check + str msg; + BBPreleaseref(aBAT->batCacheid); + BBPreleaseref(bBAT->batCacheid); + BBPreleaseref(outBAT->batCacheid); + msg = createException(MAL, "batgeom.Contains", "%s", err); + GDKfree(err); + return msg; + } + BUNappend(outBAT,&outBIT,TRUE); //add the result to the outBAT } - BUNappend(outBAT,&outBIT,TRUE); //add the result to the outBAT - // GDKfree(outBIT); - // outBIT = NULL; } //set some properties of the new BAT _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list