Changeset: 4fc468229e81 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4fc468229e81
Modified Files:
gdk/gdk_setop.mx
Branch: default
Log Message:
Partial de-mx of gdk_setop.
Small steps.
diffs (165 lines):
diff --git a/gdk/gdk_setop.mx b/gdk/gdk_setop.mx
--- a/gdk/gdk_setop.mx
+++ b/gdk/gdk_setop.mx
@@ -74,8 +74,6 @@ All Rights Reserved.
#define HITk(t1,t2) TRUE
#define HITs(t1,t2) ((*cmp)(t1,t2) == 0)
-#define TAILCHECKs(l,r) TYPEerror(BATttype(l), BATttype(r))
-#define TAILCHECKk(l,r) FALSE
#define EQUALs(t1,t2) ((*cmp)(t1,t2) == 0 && (*cmp)(t1,tnil))
#define EQUALk(t1,t2) TRUE
#define FLIPs(l,r) TRUE
@@ -98,9 +96,7 @@ All Rights Reserved.
#define ENDintersect(h,t)
#define ENDdiff(h,t) for(;p1<q1;p1++) bunfastins(bn,h,t)
-#define RALIGNdiff(bn,l,r) FALSE
-#define RALIGNintersect(bn,l,r) (BAThordered(l) & BAThordered(r) && (l)->hkey \
- && BATcount(bn)==BATcount(r))
+
/*
* @+ Double Elimination
* Comes in two flavors: looking at one column, or at two at-a-time.
@@ -638,6 +634,7 @@ BATins_@1@2(BAT *bn, BAT *l, BAT *r)
{
int hash = TRUE, (*cmp)(const void *, const void *), (*merge)(const
void *, const void *) = NULL;
ptr hnil, tnil;
+ BAT *b = bn;
/* determine how to do the intersect */
if (BAThordered(l) & BAThordered(r)) {
@@ -760,44 +757,73 @@ BATins_@1@2(BAT *bn, BAT *l, BAT *r)
}
}
}
- return bn;
+ return b;
bunins_failed:
- BBPreclaim(bn);
+ BBPreclaim(b);
return NULL;
}
+@
+@c
-BAT *
-BAT@1@2(BAT *l, BAT *r)
+@:batcheck(s,intersect,)@
+@:batcheck(s,diff,-)@
+@:batcheck(k,intersect,)@
+@:batcheck(k,diff,-)@
+
+
+static BAT *
+diff_intersect(BAT *l, BAT *r, int diff, int set)
{
- BUN smaller;
- BAT *bn;
+ BUN smaller;
+ BAT *bn;
- ERRORcheck(l == NULL, "BAT@1@2: left is null");
- ERRORcheck(r == NULL, "BAT@1@2: right is null");
- ERRORcheck(TYPEerror(BAThtype(l), BAThtype(r)), "BUN@1@2: incompatible
head-types");
- ERRORcheck(TAILCHECK@1(l,r), "BUN@1@2: incompatible tail-types");
+ ERRORcheck(l == NULL, "diff_intersect: left is null");
+ ERRORcheck(r == NULL, "diff_intersect: right is null");
+ ERRORcheck(TYPEerror(BAThtype(l), BAThtype(r)), "diff_intersect:
incompatible head-types");
+ if (set)
+ ERRORcheck(TYPEerror(BATttype(l), BATttype(r)),
"diff_intersect: incompatible tail-types");
if (BATcount(r) == 0) {
- return EMPTYr@2(l);
+ return diff ? BATcopy(l, l->htype, l->ttype, FALSE) :
BATclone(l, 10);
} else if (BATcount(l) == 0) {
- return EMPTYl@2(l);
+ return BATclone(l, 10);
}
- smaller = @2_size(l, r);
+ smaller = BATcount(l);
+ if (!diff && BATcount(r) < smaller)
+ smaller = BATcount(r);
bn = BATnew(BAThtype(l), BATttype(l), MAX(smaller,BATTINY));
if (bn == NULL)
return NULL;
/* fill result bat bn */
- ALGODEBUG fprintf(stderr, "#BAT@1@2: BATins_@1@2(bn, l, r);\n");
- if (BATins_@1@2(bn, l, r) == NULL) {
+ if (set) {
+ if (diff) {
+ ALGODEBUG fprintf(stderr, "#diff_intersect:
BATins_sdiff(bn, l, r);\n");
+ bn = BATins_sdiff(bn, l, r);
+ } else {
+ ALGODEBUG fprintf(stderr, "#diff_intersect:
BATins_sintersect(bn, l, r);\n");
+ bn = BATins_sintersect(bn, l, r);
+ }
+ } else {
+ if (diff) {
+ ALGODEBUG fprintf(stderr, "#diff_intersect:
BATins_kdiff(bn, l, r);\n");
+ bn = BATins_kdiff(bn, l, r);
+ } else {
+ ALGODEBUG fprintf(stderr, "#diff_intersect:
BATins_kintersect(bn, l, r);\n");
+ bn = BATins_kintersect(bn, l, r);
+ }
+ }
+ if (bn == NULL)
return NULL;
- }
/* propagate alignment info */
if (BATcount(bn) == BATcount(l)) {
ALIGNset(bn, l);
}
- if (RALIGN@2(bn, l, r)) {
+ if (!diff &&
+ BAThordered(l) & BAThordered(r) &&
+ l->hkey &&
+ BATcount(bn) == BATcount(r)) {
ALIGNsetH(bn, r);
}
bn->hsorted = BAThordered(l);
@@ -815,21 +841,30 @@ BAT@1@2(BAT *l, BAT *r)
bn->T->nonil = l->T->nonil;
return bn;
}
-@
-@c
-#define EMPTYldiff(l) BATclone(l,10)
-#define EMPTYrdiff(l) BATcopy(l, l->htype, l->ttype, FALSE)
-#define EMPTYlintersect(l) BATclone(l,10)
-#define EMPTYrintersect(l) EMPTYlintersect(l)
-#define intersect_size(l,r) MIN(BATcount(l), BATcount(r))
-#define diff_size(l,r) BATcount(l)
+BAT *
+BATsdiff(BAT *l, BAT *r)
+{
+ return diff_intersect(l, r, 1, 1);
+}
-@:batcheck(s,intersect,)@
-@:batcheck(s,diff,-)@
-@:batcheck(k,intersect,)@
-@:batcheck(k,diff,-)@
+BAT *
+BATsintersect(BAT *l, BAT *r)
+{
+ return diff_intersect(l, r, 0, 1);
+}
+BAT *
+BATkdiff(BAT *l, BAT *r)
+{
+ return diff_intersect(l, r, 1, 0);
+}
+
+BAT *
+BATkintersect(BAT *l, BAT *r)
+{
+ return diff_intersect(l, r, 0, 0);
+}
/*
* @+ Union
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list