Changeset: af72035e7589 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=af72035e7589
Modified Files:
clients/Tests/MAL-signatures_all.stable.out
clients/Tests/MAL-signatures_fits_geom.stable.out
clients/Tests/MAL-signatures_geom.stable.out
clients/Tests/MAL-signatures_none.stable.out
clients/Tests/exports.stable.out
monetdb5/modules/kernel/algebra.c
monetdb5/modules/kernel/algebra.h
monetdb5/modules/kernel/algebra.mal
Branch: Oct2014
Log Message:
Implemented algebra.subbandjoin and algebra.subrangejoin interfaces.
The underlying code (BATsubbandjoin and BATsubrangejoin) already exist
for a long time.
diffs (293 lines):
diff --git a/clients/Tests/MAL-signatures_all.stable.out
b/clients/Tests/MAL-signatures_all.stable.out
--- a/clients/Tests/MAL-signatures_all.stable.out
+++ b/clients/Tests/MAL-signatures_all.stable.out
@@ -2611,6 +2611,14 @@ pattern algebra.semijoinPath(l:bat[:any,
address ALGjoinPath;
comment Routine to handle join paths. The type analysis is rather tricky.
+command
algebra.subrangejoin(l:bat[:oid,:any_1],r1:bat[:oid,:any_1],r2:bat[:oid,:any_1],sl:bat[:oid,:oid],sr:bat[:oid,:oid],li:bit,hi:bit,estimate:lng)
(X_9:bat[:oid,:oid],X_10:bat[:oid,:oid])
+address ALGsubrangejoin;
+comment Range join: values in l and r1/r2 match if r1 <[=] l <[=] r2
+
+command
algebra.subbandjoin(l:bat[:oid,:any_1],r:bat[:oid,:any_1],sl:bat[:oid,:oid],sr:bat[:oid,:oid],c1:any_1,c2:any_1,li:bit,hi:bit,estimate:lng)
(X_10:bat[:oid,:oid],X_11:bat[:oid,:oid])
+address ALGsubbandjoin;
+comment Band join: values in l and r match if r - c1 <[=] l <[=] r + c2
+
command
algebra.subthetajoin(l:bat[:oid,:any_1],r:bat[:oid,:any_1],sl:bat[:oid,:oid],sr:bat[:oid,:oid],op:int,nil_matches:bit,estimate:lng)
(X_8:bat[:oid,:oid],X_9:bat[:oid,:oid])
address ALGsubthetajoin;
comment Theta join with candidate lists
diff --git a/clients/Tests/MAL-signatures_fits_geom.stable.out
b/clients/Tests/MAL-signatures_fits_geom.stable.out
--- a/clients/Tests/MAL-signatures_fits_geom.stable.out
+++ b/clients/Tests/MAL-signatures_fits_geom.stable.out
@@ -2612,6 +2612,14 @@ pattern algebra.semijoinPath(l:bat[:any,
address ALGjoinPath;
comment Routine to handle join paths. The type analysis is rather tricky.
+command
algebra.subrangejoin(l:bat[:oid,:any_1],r1:bat[:oid,:any_1],r2:bat[:oid,:any_1],sl:bat[:oid,:oid],sr:bat[:oid,:oid],li:bit,hi:bit,estimate:lng)
(X_9:bat[:oid,:oid],X_10:bat[:oid,:oid])
+address ALGsubrangejoin;
+comment Range join: values in l and r1/r2 match if r1 <[=] l <[=] r2
+
+command
algebra.subbandjoin(l:bat[:oid,:any_1],r:bat[:oid,:any_1],sl:bat[:oid,:oid],sr:bat[:oid,:oid],c1:any_1,c2:any_1,li:bit,hi:bit,estimate:lng)
(X_10:bat[:oid,:oid],X_11:bat[:oid,:oid])
+address ALGsubbandjoin;
+comment Band join: values in l and r match if r - c1 <[=] l <[=] r + c2
+
command
algebra.subthetajoin(l:bat[:oid,:any_1],r:bat[:oid,:any_1],sl:bat[:oid,:oid],sr:bat[:oid,:oid],op:int,nil_matches:bit,estimate:lng)
(X_8:bat[:oid,:oid],X_9:bat[:oid,:oid])
address ALGsubthetajoin;
comment Theta join with candidate lists
diff --git a/clients/Tests/MAL-signatures_geom.stable.out
b/clients/Tests/MAL-signatures_geom.stable.out
--- a/clients/Tests/MAL-signatures_geom.stable.out
+++ b/clients/Tests/MAL-signatures_geom.stable.out
@@ -2612,6 +2612,14 @@ pattern algebra.semijoinPath(l:bat[:any,
address ALGjoinPath;
comment Routine to handle join paths. The type analysis is rather tricky.
+command
algebra.subrangejoin(l:bat[:oid,:any_1],r1:bat[:oid,:any_1],r2:bat[:oid,:any_1],sl:bat[:oid,:oid],sr:bat[:oid,:oid],li:bit,hi:bit,estimate:lng)
(X_9:bat[:oid,:oid],X_10:bat[:oid,:oid])
+address ALGsubrangejoin;
+comment Range join: values in l and r1/r2 match if r1 <[=] l <[=] r2
+
+command
algebra.subbandjoin(l:bat[:oid,:any_1],r:bat[:oid,:any_1],sl:bat[:oid,:oid],sr:bat[:oid,:oid],c1:any_1,c2:any_1,li:bit,hi:bit,estimate:lng)
(X_10:bat[:oid,:oid],X_11:bat[:oid,:oid])
+address ALGsubbandjoin;
+comment Band join: values in l and r match if r - c1 <[=] l <[=] r + c2
+
command
algebra.subthetajoin(l:bat[:oid,:any_1],r:bat[:oid,:any_1],sl:bat[:oid,:oid],sr:bat[:oid,:oid],op:int,nil_matches:bit,estimate:lng)
(X_8:bat[:oid,:oid],X_9:bat[:oid,:oid])
address ALGsubthetajoin;
comment Theta join with candidate lists
diff --git a/clients/Tests/MAL-signatures_none.stable.out
b/clients/Tests/MAL-signatures_none.stable.out
--- a/clients/Tests/MAL-signatures_none.stable.out
+++ b/clients/Tests/MAL-signatures_none.stable.out
@@ -2611,6 +2611,14 @@ pattern algebra.semijoinPath(l:bat[:any,
address ALGjoinPath;
comment Routine to handle join paths. The type analysis is rather tricky.
+command
algebra.subrangejoin(l:bat[:oid,:any_1],r1:bat[:oid,:any_1],r2:bat[:oid,:any_1],sl:bat[:oid,:oid],sr:bat[:oid,:oid],li:bit,hi:bit,estimate:lng)
(X_9:bat[:oid,:oid],X_10:bat[:oid,:oid])
+address ALGsubrangejoin;
+comment Range join: values in l and r1/r2 match if r1 <[=] l <[=] r2
+
+command
algebra.subbandjoin(l:bat[:oid,:any_1],r:bat[:oid,:any_1],sl:bat[:oid,:oid],sr:bat[:oid,:oid],c1:any_1,c2:any_1,li:bit,hi:bit,estimate:lng)
(X_10:bat[:oid,:oid],X_11:bat[:oid,:oid])
+address ALGsubbandjoin;
+comment Band join: values in l and r match if r - c1 <[=] l <[=] r + c2
+
command
algebra.subthetajoin(l:bat[:oid,:any_1],r:bat[:oid,:any_1],sl:bat[:oid,:oid],sr:bat[:oid,:oid],op:int,nil_matches:bit,estimate:lng)
(X_8:bat[:oid,:oid],X_9:bat[:oid,:oid])
address ALGsubthetajoin;
comment Theta join with candidate lists
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -786,9 +786,11 @@ str ALGssort(int *result, int *bid);
str ALGssort_rev(int *result, int *bid);
str ALGstdev(dbl *res, int *bid);
str ALGstdevp(dbl *res, int *bid);
-str ALGsubjoin(bat *r1, bat *r2, bat *l, bat *r, bat *sl, bat *sr, bit
*nil_matches, lng *estimate);
-str ALGsubleftjoin(bat *r1, bat *r2, bat *l, bat *r, bat *sl, bat *sr, bit
*nil_matches, lng *estimate);
-str ALGsubouterjoin(bat *r1, bat *r2, bat *l, bat *r, bat *sl, bat *sr, bit
*nil_matches, lng *estimate);
+str ALGsubbandjoin(bat *r1, bat *r2, bat *lid, bat *rid, bat *slid, bat *srid,
const void *low, const void *high, const bit *li, const bit *hi, const lng
*estimate);
+str ALGsubjoin(bat *r1, bat *r2, bat *l, bat *r, bat *sl, bat *sr, const bit
*nil_matches, const lng *estimate);
+str ALGsubleftjoin(bat *r1, bat *r2, bat *l, bat *r, bat *sl, bat *sr, const
bit *nil_matches, const lng *estimate);
+str ALGsubouterjoin(bat *r1, bat *r2, bat *l, bat *r, bat *sl, bat *sr, const
bit *nil_matches, const lng *estimate);
+str ALGsubrangejoin(bat *r1, bat *r2, bat *lid, bat *rlid, bat *rhid, bat
*slid, bat *srid, const bit *li, const bit *hi, const lng *estimate);
str ALGsubselect1(bat *result, bat *bid, const void *low, const void *high,
const bit *li, const bit *hi, const bit *anti);
str ALGsubselect2(bat *result, bat *bid, bat *sid, const void *low, const void
*high, const bit *li, const bit *hi, const bit *anti);
str ALGsubslice_wrd(int *ret, bat *bid, wrd *start, wrd *end);
@@ -801,7 +803,7 @@ str ALGsubsort23(bat *result, bat *norde
str ALGsubsort31(bat *result, bat *bid, bat *order, bat *group, bit *reverse,
bit *stable);
str ALGsubsort32(bat *result, bat *norder, bat *bid, bat *order, bat *group,
bit *reverse, bit *stable);
str ALGsubsort33(bat *result, bat *norder, bat *ngroup, bat *bid, bat *order,
bat *group, bit *reverse, bit *stable);
-str ALGsubthetajoin(bat *r1, bat *r2, bat *l, bat *r, bat *sl, bat *sr, int
*op, bit *nil_matches, lng *estimate);
+str ALGsubthetajoin(bat *r1, bat *r2, bat *l, bat *r, bat *sl, bat *sr, int
*op, const bit *nil_matches, const lng *estimate);
str ALGsubunique1(bat *result, bat *bid);
str ALGsubunique2(bat *result, bat *bid, bat *sid);
str ALGtdiff(int *result, int *lid, int *rid);
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
@@ -684,16 +684,26 @@ ALGrangejoin(int *result, int *lid, int
}
static str
-do_join(bat *r1, bat *r2, bat *lid, bat *rid, bat *slid, bat *srid,
- int op, bit *nil_matches, lng *estimate,
- gdk_return (*joinfunc)(BAT **, BAT **, BAT *, BAT *, BAT *, BAT
*, int, BUN),
- gdk_return (*thetafunc)(BAT **, BAT **, BAT *, BAT *, BAT *,
BAT *, int, int, BUN),
+do_join(bat *r1, bat *r2, bat *lid, bat *rid, bat *r2id, bat *slid, bat *srid,
+ int op, const void *c1, const void *c2, int li, int hi,
+ const bit *nil_matches, const lng *estimate,
+ gdk_return (*joinfunc)(BAT **, BAT **, BAT *, BAT *, BAT *, BAT
*,
+ int, BUN),
+ gdk_return (*thetafunc)(BAT **, BAT **, BAT *, BAT *, BAT *,
BAT *,
+ int, int, BUN),
+ gdk_return (*bandfunc)(BAT **, BAT **, BAT *, BAT *, BAT *, BAT
*,
+ const void *, const
void *, int, int, BUN),
+ gdk_return (*rangefunc)(BAT **, BAT **, BAT *, BAT *, BAT *,
+ BAT *, BAT *,
int, int, BUN),
const char *funcname)
{
- BAT *left = NULL, *right = NULL, *candleft = NULL, *candright = NULL;
+ BAT *left = NULL, *right = NULL, *right2 = NULL;
+ BAT *candleft = NULL, *candright = NULL;
BAT *result1, *result2;
BUN est;
+ assert(r2id == NULL || rangefunc != NULL);
+
if ((left = BATdescriptor(*lid)) == NULL)
goto fail;
if ((right = BATdescriptor(*rid)) == NULL)
@@ -709,11 +719,25 @@ do_join(bat *r1, bat *r2, bat *lid, bat
if (thetafunc) {
assert(joinfunc == NULL);
+ assert(bandfunc == NULL);
+ assert(rangefunc == NULL);
if ((*thetafunc)(&result1, &result2, left, right, candleft,
candright, op, *nil_matches, est) == GDK_FAIL)
goto fail;
- } else {
+ } else if (joinfunc) {
+ assert(bandfunc == NULL);
+ assert(rangefunc == NULL);
if ((*joinfunc)(&result1, &result2, left, right, candleft,
candright, *nil_matches, est) == GDK_FAIL)
goto fail;
+ } else if (bandfunc) {
+ assert(rangefunc == NULL);
+ if ((*bandfunc)(&result1, &result2, left, right, candleft,
candright, c1, c2, li, hi, est) == GDK_FAIL)
+ goto fail;
+ } else {
+ if ((right2 = BATdescriptor(*r2id)) == NULL)
+ goto fail;
+ if ((*rangefunc)(&result1, &result2, left, right, right2,
candleft, candright, li, hi, est) == GDK_FAIL)
+ goto fail;
+ BBPreleaseref(right2->batCacheid);
}
*r1 = result1->batCacheid;
*r2 = result2->batCacheid;
@@ -732,6 +756,8 @@ do_join(bat *r1, bat *r2, bat *lid, bat
BBPreclaim(left);
if (right)
BBPreclaim(right);
+ if (right2)
+ BBPreclaim(right2);
if (candleft)
BBPreclaim(candleft);
if (candright)
@@ -740,31 +766,57 @@ do_join(bat *r1, bat *r2, bat *lid, bat
}
str
-ALGsubjoin(bat *r1, bat *r2, bat *lid, bat *rid, bat *slid, bat *srid, bit
*nil_matches, lng *estimate)
+ALGsubjoin(bat *r1, bat *r2, bat *lid, bat *rid, bat *slid, bat *srid,
+ const bit *nil_matches, const lng *estimate)
{
- return do_join(r1, r2, lid, rid, slid, srid, 0, nil_matches, estimate,
- BATsubjoin, NULL, "algebra.subjoin");
+ return do_join(r1, r2, lid, rid, NULL, slid, srid, 0, NULL, NULL, 0, 0,
+ nil_matches, estimate,
+ BATsubjoin, NULL, NULL, NULL,
"algebra.subjoin");
}
str
-ALGsubleftjoin(bat *r1, bat *r2, bat *lid, bat *rid, bat *slid, bat *srid, bit
*nil_matches, lng *estimate)
+ALGsubleftjoin(bat *r1, bat *r2, bat *lid, bat *rid, bat *slid, bat *srid,
+ const bit *nil_matches, const lng *estimate)
{
- return do_join(r1, r2, lid, rid, slid, srid, 0, nil_matches, estimate,
- BATsubleftjoin, NULL, "algebra.subleftjoin");
+ return do_join(r1, r2, lid, rid, NULL, slid, srid, 0, NULL, NULL, 0, 0,
+ nil_matches, estimate,
+ BATsubleftjoin, NULL, NULL, NULL,
"algebra.subleftjoin");
}
str
-ALGsubouterjoin(bat *r1, bat *r2, bat *lid, bat *rid, bat *slid, bat *srid,
bit *nil_matches, lng *estimate)
+ALGsubouterjoin(bat *r1, bat *r2, bat *lid, bat *rid, bat *slid, bat *srid,
+ const bit *nil_matches, const lng *estimate)
{
- return do_join(r1, r2, lid, rid, slid, srid, 0, nil_matches, estimate,
- BATsubouterjoin, NULL,
"algebra.subouterjoin");
+ return do_join(r1, r2, lid, rid, NULL, slid, srid, 0, NULL, NULL, 0, 0,
+ nil_matches, estimate,
+ BATsubouterjoin, NULL, NULL, NULL,
"algebra.subouterjoin");
}
str
-ALGsubthetajoin(bat *r1, bat *r2, bat *lid, bat *rid, bat *slid, bat *srid,
int *op, bit *nil_matches, lng *estimate)
+ALGsubthetajoin(bat *r1, bat *r2, bat *lid, bat *rid, bat *slid, bat *srid,
+ int *op, const bit *nil_matches, const lng
*estimate)
{
- return do_join(r1, r2, lid, rid, slid, srid, *op, nil_matches, estimate,
- NULL, BATsubthetajoin,
"algebra.subthetajoin");
+ return do_join(r1, r2, lid, rid, NULL, slid, srid, *op, NULL, NULL, 0,
0,
+ nil_matches, estimate,
+ NULL, BATsubthetajoin, NULL, NULL,
"algebra.subthetajoin");
+}
+
+str
+ALGsubbandjoin(bat *r1, bat *r2, bat *lid, bat *rid, bat *slid, bat *srid,
+ const void *c1, const void *c2, const bit *li, const
bit *hi,
+ const lng *estimate)
+{
+ return do_join(r1, r2, lid, rid, NULL, slid, srid, 0, c1, c2, *li, *hi,
+ NULL, estimate,
+ NULL, NULL, BATsubbandjoin, NULL,
"algebra.subbandjoin");
+}
+
+str
+ALGsubrangejoin(bat *r1, bat *r2, bat *lid, bat *rlid, bat *rhid, bat *slid,
bat *srid, const bit *li, const bit *hi, const lng *estimate)
+{
+ return do_join(r1, r2, lid, rlid, rhid, slid, srid, 0, NULL, NULL, *li,
*hi,
+ NULL, estimate,
+ NULL, NULL, NULL, BATsubrangejoin,
"algebra.subrangejoin");
}
/* algebra.firstn(b:bat[:oid,:any],
diff --git a/monetdb5/modules/kernel/algebra.h
b/monetdb5/modules/kernel/algebra.h
--- a/monetdb5/modules/kernel/algebra.h
+++ b/monetdb5/modules/kernel/algebra.h
@@ -56,22 +56,26 @@ algebra_export str ALGuselect(int *resul
algebra_export str ALGselectInclusive(int *result, int *bid, ptr low, ptr
high, bit *lin, bit *rin);
algebra_export str ALGuselectInclusive(int *result, int *bid, ptr low, ptr
high, bit *lin, bit *rin);
+algebra_export str ALGsubjoin(bat *r1, bat *r2, bat *l, bat *r, bat *sl, bat
*sr, const bit *nil_matches, const lng *estimate);
+algebra_export str ALGsubleftjoin(bat *r1, bat *r2, bat *l, bat *r, bat *sl,
bat *sr, const bit *nil_matches, const lng *estimate);
+algebra_export str ALGsubouterjoin(bat *r1, bat *r2, bat *l, bat *r, bat *sl,
bat *sr, const bit *nil_matches, const lng *estimate);
+algebra_export str ALGsubthetajoin(bat *r1, bat *r2, bat *l, bat *r, bat *sl,
bat *sr, int *op, const bit *nil_matches, const lng *estimate);
+algebra_export str ALGsubbandjoin(bat *r1, bat *r2, bat *lid, bat *rid, bat
*slid, bat *srid, const void *low, const void *high, const bit *li, const bit
*hi, const lng *estimate);
+algebra_export str ALGsubrangejoin(bat *r1, bat *r2, bat *lid, bat *rlid, bat
*rhid, bat *slid, bat *srid, const bit *li, const bit *hi, const lng *estimate);
+
+/* legacy join functions */
algebra_export str ALGantijoin2(int *l, int *r, int *lid, int *rid);
algebra_export str ALGjoin2(int *l, int *r, int *lid, int *rid);
algebra_export str ALGthetajoin2(int *l, int *r, int *lid, int *rid, int *opc);
algebra_export str ALGcrossproduct2(int *l, int *r, int *lid, int *rid);
algebra_export str ALGbandjoin2(int *l, int *r, int *lid, int *rid, const void
*minus, const void *plus, bit *li, bit *hi);
algebra_export str ALGrangejoin2(int *l, int *r, int *lid, int *rlid, int
*rhid, bit *li, bit *hi);
-
algebra_export str ALGthetajoinEstimate(int *result, int *lid, int *rid, int
*opc, lng *estimate);
algebra_export str ALGthetajoin(int *result, int *lid, int *rid, int *opc);
algebra_export str ALGbandjoin_default(int *result, int *lid, int *rid, const
void *minus, const void *plus);
algebra_export str ALGbandjoin(int *result, int *lid, int *rid, const void
*minus, const void *plus, bit *li, bit *hi);
algebra_export str ALGrangejoin(int *result, int *lid, int *rlid, int *rhid,
bit *li, bit *hi);
-algebra_export str ALGsubjoin(bat *r1, bat *r2, bat *l, bat *r, bat *sl, bat
*sr, bit *nil_matches, lng *estimate);
-algebra_export str ALGsubleftjoin(bat *r1, bat *r2, bat *l, bat *r, bat *sl,
bat *sr, bit *nil_matches, lng *estimate);
-algebra_export str ALGsubouterjoin(bat *r1, bat *r2, bat *l, bat *r, bat *sl,
bat *sr, bit *nil_matches, lng *estimate);
-algebra_export str ALGsubthetajoin(bat *r1, bat *r2, bat *l, bat *r, bat *sl,
bat *sr, int *op, bit *nil_matches, lng *estimate);
+/* end legacy join functions */
algebra_export str ALGfirstn(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
diff --git a/monetdb5/modules/kernel/algebra.mal
b/monetdb5/modules/kernel/algebra.mal
--- a/monetdb5/modules/kernel/algebra.mal
+++ b/monetdb5/modules/kernel/algebra.mal
@@ -541,6 +541,14 @@ command subthetajoin(l:bat[:oid,:any_1],
address ALGsubthetajoin
comment "Theta join with candidate lists";
+command
subbandjoin(l:bat[:oid,:any_1],r:bat[:oid,:any_1],sl:bat[:oid,:oid],sr:bat[:oid,:oid],c1:any_1,c2:any_1,li:bit,hi:bit,estimate:lng)
(:bat[:oid,:oid],:bat[:oid,:oid])
+address ALGsubbandjoin
+comment "Band join: values in l and r match if r - c1 <[=] l <[=] r + c2";
+
+command
subrangejoin(l:bat[:oid,:any_1],r1:bat[:oid,:any_1],r2:bat[:oid,:any_1],sl:bat[:oid,:oid],sr:bat[:oid,:oid],li:bit,hi:bit,estimate:lng)
(:bat[:oid,:oid],:bat[:oid,:oid])
+address ALGsubrangejoin
+comment "Range join: values in l and r1/r2 match if r1 <[=] l <[=] r2";
+
# @+ Projection operations
command project(b:bat[:any_1,:any_2]) :bat[:any_1,:void]
address ALGprojectNIL
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list