Hey Imad,No, it does not apply to integers because you are not doing any heap allocation.MarkOn 02 Jan 2017, at 19:03, imad hajj chahine <imad.hajj.chahine@gmail.com> wrote:______________________________Mark,Does the same apply for Integer values, Meaning its better to declare one the int value and used in all the iteration, do I have a performance issue with the following code:strUDFyearlag(int *ret, const date *v1, const date *v2){if (*v1 == date_nil || *v2 == date_nil) {*ret = int_nil;} else {int y1 = 0, y2 = 0;fromdate(*v1, NULL, NULL, &y1);fromdate(*v2, NULL, NULL, &y2);*ret = y2 - y1;}return MAL_SUCCEED;}strUDFBATyearlag(bat *ret, const bat *bid1, const bat *bid2){BAT *b1, *b2, *bn;BATiter bi1, bi2;BUN i,n;b1 = BATdescriptor(*bid1);b2 = BATdescriptor(*bid2);if (b1 == NULL || b2 == NULL) {if (b1)BBPunfix(b1->batCacheid);if (b2)BBPunfix(b2->batCacheid);throw(MAL, "UDF.BATyearlag", "Cannot access descriptor");}n = BATcount(b1);bn = COLnew(b1->hseqbase, TYPE_int, BATcount(b1), TRANSIENT);if (bn == NULL) {BBPunfix(b1->batCacheid);BBPunfix(b2->batCacheid);throw(MAL, "UDF.BATyearlag", "memory allocation failure");}bi1 = bat_iterator(b1);bi2 = bat_iterator(b2);BATloop(b1, i, n) {int y;const date *t1 = (const date *) BUNtail(bi1, i);const date *t2 = (const date *) BUNtail(bi2, i);if (*t1 == date_nil || *t2 == date_nil) {y = int_nil;} elseUDFyearlag(&y, t1, t2);if (BUNappend(bn, &y, 0) != GDK_SUCCEED) {goto bailout;}}BBPkeepref(*ret = bn->batCacheid);BBPunfix(b1->batCacheid);BBPunfix(b2->batCacheid);return MAL_SUCCEED;bailout:BBPunfix(b1->batCacheid);BBPunfix(b2->batCacheid);BBPunfix(bn->batCacheid);throw(MAL, "UDF.BATyearlag", MAL_MALLOC_FAIL);}_________________
users-list mailing list
users-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/users-list
_______________________________________________
users-list mailing list
users-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/users-list