Changeset: 454c4af4d6af for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/454c4af4d6af
Modified Files:
monetdb5/modules/kernel/algebra.c
monetdb5/optimizer/opt_prelude.c
monetdb5/optimizer/opt_prelude.h
Branch: groupjoin
Log Message:
add outercrossproduct add mal wrappers for outercrossproduct
diffs (108 lines):
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
@@ -496,7 +496,7 @@ ALGouterselect(bat *r1, bat *r2, const b
oid c = l->hseqbase;
for (BUN n = 0; n < nr; n++, c++) {
ri1[q] = c;
- ri2[q] = (ri[n]!=bit_nil && *pi == TRUE)?TRUE:bit_nil;
+ ri2[q] = (ri[n]!=bit_nil && pi[n] == TRUE)?TRUE:bit_nil;
q++;
}
} else {
@@ -514,9 +514,9 @@ ALGouterselect(bat *r1, bat *r2, const b
used = false;
cur = li[n];
}
- if (*ri == bit_nil || *pi == TRUE) {
+ if (ri[n] == bit_nil || pi[n] == TRUE) {
ri1[q] = c;
- ri2[q] = *ri == bit_nil?bit_nil:TRUE;
+ ri2[q] = (ri[n] == bit_nil)?bit_nil:TRUE;
cur = li[n];
used = true;
q++;
@@ -1105,6 +1105,45 @@ ALGcrossproduct4(bat *l, const bat *left
}
static str
+ALGoutercrossproduct3(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;
+
+ L = BATdescriptor(*left);
+ R = BATdescriptor(*right);
+ if (L == NULL || R == NULL) {
+ BBPreclaim(L);
+ BBPreclaim(R);
+ throw(MAL, "algebra.crossproduct", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
+ }
+ if ((slid && !is_bat_nil(*slid) && (sl = BATdescriptor(*slid)) == NULL)
||
+ (srid && !is_bat_nil(*srid) && (sr = BATdescriptor(*srid)) ==
NULL)) {
+ BBPunfix(L->batCacheid);
+ BBPunfix(R->batCacheid);
+ BBPreclaim(sl);
+ /* sr == NULL, so no need to unfix */
+ throw(MAL, "algebra.crossproduct", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
+ }
+ ret = BAToutercross(&bn1, r ? &bn2 : NULL, L, R, sl, sr,
+ max_one && !is_bit_nil(*max_one) &&
*max_one);
+ BBPunfix(L->batCacheid);
+ BBPunfix(R->batCacheid);
+ BBPreclaim(sl);
+ BBPreclaim(sr);
+ if (ret != GDK_SUCCEED)
+ throw(MAL, "algebra.crossproduct", GDK_EXCEPTION);
+ *l = bn1->batCacheid;
+ BBPkeepref(bn1);
+ if (r) {
+ *r = bn2->batCacheid;
+ BBPkeepref(bn2);
+ }
+ return MAL_SUCCEED;
+}
+
+static str
ALGprojection2(bat *result, const bat *lid, const bat *r1id, const bat *r2id)
{
BAT *l, *r1, *r2 = NULL, *bn;
@@ -1709,6 +1748,7 @@ mel_func algebra_init_funcs[] = {
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", "outercrossproduct", ALGoutercrossproduct3, false,
"Compute the outer 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", "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))),
diff --git a/monetdb5/optimizer/opt_prelude.c b/monetdb5/optimizer/opt_prelude.c
--- a/monetdb5/optimizer/opt_prelude.c
+++ b/monetdb5/optimizer/opt_prelude.c
@@ -180,6 +180,7 @@ const char *notRef;
const char *not_uniqueRef;
const char *nth_valueRef;
const char *ntileRef;
+const char *outercrossRef;
const char *outerjoinRef;
const char *outerselectRef;
const char *packIncrementRef;
@@ -438,6 +439,7 @@ void optimizerInit(void)
not_uniqueRef= putName("not_unique");
nth_valueRef = putName("nth_value");
ntileRef = putName("ntile");
+ outercrossRef = putName("outercrossproduct");
outerjoinRef = putName("outerjoin");
outerselectRef = putName("outerselect");
packIncrementRef = putName("packIncrement");
diff --git a/monetdb5/optimizer/opt_prelude.h b/monetdb5/optimizer/opt_prelude.h
--- a/monetdb5/optimizer/opt_prelude.h
+++ b/monetdb5/optimizer/opt_prelude.h
@@ -178,6 +178,7 @@ mal_export const char *notRef;
mal_export const char *not_uniqueRef;
mal_export const char *nth_valueRef;
mal_export const char *ntileRef;
+mal_export const char *outercrossRef;
mal_export const char *outerjoinRef;
mal_export const char *outerselectRef;
mal_export const char *packIncrementRef;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]