Changeset: 480b608411ce for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=480b608411ce Modified Files: clients/Tests/MAL-signatures.stable.out clients/Tests/MAL-signatures.stable.out.int128 monetdb5/modules/kernel/algebra.c Branch: default Log Message:
Add algebra.crossproduct with candidate lists. diffs (104 lines): diff --git a/clients/Tests/MAL-signatures.stable.out b/clients/Tests/MAL-signatures.stable.out --- a/clients/Tests/MAL-signatures.stable.out +++ b/clients/Tests/MAL-signatures.stable.out @@ -626,6 +626,8 @@ stdout of test 'MAL-signatures` in direc [ "algebra", "copy", "command algebra.copy(X_1:bat[:any_1]):bat[:any_1] ", "ALGcopy;", "" ] [ "algebra", "crossproduct", "command algebra.crossproduct(X_1:bat[:any_1], X_2:bat[:any_2], X_3:bit):bat[:oid] ", "ALGcrossproduct1;", "" ] [ "algebra", "crossproduct", "command algebra.crossproduct(X_2:bat[:any_1], X_3:bat[:any_2], X_4:bit) (X_0:bat[:oid], X_1:bat[:oid]) ", "ALGcrossproduct2;", "" ] +[ "algebra", "crossproduct", "command algebra.crossproduct(X_2:bat[:any_1], X_3:bat[:any_2], X_4:bat[:oid], X_5:bat[:oid], X_6:bit) (X_0:bat[:oid], X_1:bat[:oid]) ", "ALGcrossproduct3;", "" ] +[ "algebra", "crossproduct", "command algebra.crossproduct(X_1:bat[:any_1], X_2:bat[:any_2], X_3:bat[:oid], X_4:bat[:oid], X_5:bit):bat[:oid] ", "ALGcrossproduct4;", "" ] [ "algebra", "difference", "command algebra.difference(X_1:bat[:any_1], X_2:bat[:any_1], X_3:bat[:oid], X_4:bat[:oid], X_5:bit, X_6:bit, X_7:lng):bat[:oid] ", "ALGdifference;", "" ] [ "algebra", "exist", "command algebra.exist(X_1:bat[:any_1], X_2:any_1):bit ", "ALGexist;", "" ] [ "algebra", "fetch", "command algebra.fetch(X_1:bat[:any_1], X_2:oid):any_1 ", "ALGfetchoid;", "" ] diff --git a/clients/Tests/MAL-signatures.stable.out.int128 b/clients/Tests/MAL-signatures.stable.out.int128 --- a/clients/Tests/MAL-signatures.stable.out.int128 +++ b/clients/Tests/MAL-signatures.stable.out.int128 @@ -743,6 +743,8 @@ stdout of test 'MAL-signatures` in direc [ "algebra", "copy", "command algebra.copy(X_1:bat[:any_1]):bat[:any_1] ", "ALGcopy;", "" ] [ "algebra", "crossproduct", "command algebra.crossproduct(X_1:bat[:any_1], X_2:bat[:any_2], X_3:bit):bat[:oid] ", "ALGcrossproduct1;", "" ] [ "algebra", "crossproduct", "command algebra.crossproduct(X_2:bat[:any_1], X_3:bat[:any_2], X_4:bit) (X_0:bat[:oid], X_1:bat[:oid]) ", "ALGcrossproduct2;", "" ] +[ "algebra", "crossproduct", "command algebra.crossproduct(X_2:bat[:any_1], X_3:bat[:any_2], X_4:bat[:oid], X_5:bat[:oid], X_6:bit) (X_0:bat[:oid], X_1:bat[:oid]) ", "ALGcrossproduct3;", "" ] +[ "algebra", "crossproduct", "command algebra.crossproduct(X_1:bat[:any_1], X_2:bat[:any_2], X_3:bat[:oid], X_4:bat[:oid], X_5:bit):bat[:oid] ", "ALGcrossproduct4;", "" ] [ "algebra", "difference", "command algebra.difference(X_1:bat[:any_1], X_2:bat[:any_1], X_3:bat[:oid], X_4:bat[:oid], X_5:bit, X_6:bit, X_7:lng):bat[:oid] ", "ALGdifference;", "" ] [ "algebra", "exist", "command algebra.exist(X_1:bat[:any_1], X_2:any_1):bit ", "ALGexist;", "" ] [ "algebra", "fetch", "command algebra.fetch(X_1:bat[:any_1], X_2:oid):any_1 ", "ALGfetchoid;", "" ] diff --git a/monetdb5/modules/kernel/algebra.c b/monetdb5/modules/kernel/algebra.c --- a/monetdb5/modules/kernel/algebra.c +++ b/monetdb5/modules/kernel/algebra.c @@ -774,9 +774,10 @@ ALGunique(bat *result, const bat *bid, c } static str -ALGcrossproduct(bat *l, bat *r, const bat *left, const bat *right, const bit *max_one) +ALGcrossproduct(bat *l, bat *r, const bat *left, const bat *right, const bat *slid, const bat *srid, const bit *max_one) { BAT *L, *R, *bn1, *bn2 = NULL; + BAT *sl = NULL, *sr = NULL; gdk_return ret; if ((L = BATdescriptor(*left)) == NULL) { @@ -786,10 +787,26 @@ ALGcrossproduct(bat *l, bat *r, const ba BBPunfix(L->batCacheid); throw(MAL, "algebra.crossproduct", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); } - ret = BATsubcross(&bn1, r ? &bn2 : NULL, L, R, NULL, NULL, + if (slid && !is_bat_nil(*slid) && (sl = BATdescriptor(*slid)) == NULL) { + BBPunfix(L->batCacheid); + BBPunfix(R->batCacheid); + throw(MAL, "algebra.crossproduct", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); + } + if (srid && !is_bat_nil(*srid) && (sr = BATdescriptor(*srid)) == NULL) { + BBPunfix(L->batCacheid); + BBPunfix(R->batCacheid); + if (sl) + BBPunfix(sl->batCacheid); + throw(MAL, "algebra.crossproduct", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); + } + ret = BATsubcross(&bn1, r ? &bn2 : NULL, L, R, sl, sr, max_one && !is_bit_nil(*max_one) && *max_one); BBPunfix(L->batCacheid); BBPunfix(R->batCacheid); + if (sl) + BBPunfix(sl->batCacheid); + if (sr) + BBPunfix(sr->batCacheid); if (ret != GDK_SUCCEED) throw(MAL, "algebra.crossproduct", GDK_EXCEPTION); BBPkeepref(*l = bn1->batCacheid); @@ -801,13 +818,25 @@ ALGcrossproduct(bat *l, bat *r, const ba static str ALGcrossproduct1(bat *l, const bat *left, const bat *right, const bit *max_one) { - return ALGcrossproduct(l, NULL, left, right, max_one); + return ALGcrossproduct(l, NULL, left, right, NULL, NULL, max_one); } static str ALGcrossproduct2(bat *l, bat *r, const bat *left, const bat *right, const bit *max_one) { - return ALGcrossproduct(l, r, left, right, max_one); + return ALGcrossproduct(l, r, left, right, NULL, NULL, max_one); +} + +static str +ALGcrossproduct3(bat *l, bat *r, const bat *left, const bat *right, const bat *sl, const bat *sr, const bit *max_one) +{ + return ALGcrossproduct(l, r, left, right, sl, sr, max_one); +} + +static str +ALGcrossproduct4(bat *l, const bat *left, const bat *right, const bat *sl, const bat *sr, const bit *max_one) +{ + return ALGcrossproduct(l, NULL, left, right, sl, sr, max_one); } static str @@ -1411,6 +1440,8 @@ mel_func algebra_init_funcs[] = { command("algebra", "unique", ALGunique, false, "Select all unique values from the tail of the first input.\nInput is a dense-headed BAT, the second input is a\ndense-headed BAT with sorted tail, output is a dense-headed\nBAT with in the tail the head value of the input BAT that was\nselected. The output BAT is sorted on the tail value. The\nsecond input BAT is a list of candidates.", args(1,3, batarg("",oid),batargany("b",1),batarg("s",oid))), command("algebra", "crossproduct", ALGcrossproduct2, false, "Returns 2 columns with all BUNs, consisting of the head-oids\nfrom 'left' and 'right' for which there are BUNs in 'left'\nand 'right' with equal tails", args(2,5, batarg("l",oid),batarg("r",oid),batargany("left",1),batargany("right",2),arg("max_one",bit))), command("algebra", "crossproduct", ALGcrossproduct1, false, "Compute the cross product of both input bats; but only produce left output", args(1,4, batarg("",oid),batargany("left",1),batargany("right",2),arg("max_one",bit))), + command("algebra", "crossproduct", ALGcrossproduct3, false, "Compute the cross product of both input bats", args(2,7, batarg("l",oid),batarg("r",oid),batargany("left",1),batargany("right",2),batarg("sl",oid),batarg("sr",oid),arg("max_one",bit))), + command("algebra", "crossproduct", ALGcrossproduct4, false, "Compute the cross product of both input bats; but only produce left output", args(1,6, batarg("",oid),batargany("left",1),batargany("right",2),batarg("sl",oid),batarg("sr",oid),arg("max_one",bit))), command("algebra", "join", ALGjoin, false, "Join", args(2,8, batarg("",oid),batarg("",oid),batargany("l",1),batargany("r",1),batarg("sl",oid),batarg("sr",oid),arg("nil_matches",bit),arg("estimate",lng))), command("algebra", "join", ALGjoin1, false, "Join; only produce left output", args(1,7, batarg("",oid),batargany("l",1),batargany("r",1),batarg("sl",oid),batarg("sr",oid),arg("nil_matches",bit),arg("estimate",lng))), command("algebra", "leftjoin", ALGleftjoin, false, "Left join with candidate lists", args(2,8, batarg("",oid),batarg("",oid),batargany("l",1),batargany("r",1),batarg("sl",oid),batarg("sr",oid),arg("nil_matches",bit),arg("estimate",lng))), _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list