Changeset: 6973a579443a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6973a579443a
Added Files:
gdk/gdk_setop.c
Removed Files:
gdk/gdk_setop.mx
Modified Files:
gdk/Makefile.ag
Branch: default
Log Message:
The last .mx file bites the dust.
This is a very simplistic conversion where the MX macros were simple
replaced by C macros.
diffs (truncated from 1063 to 300 lines):
diff --git a/gdk/Makefile.ag b/gdk/Makefile.ag
--- a/gdk/Makefile.ag
+++ b/gdk/Makefile.ag
@@ -26,7 +26,7 @@ lib_gdk = {
gdk.h gdk_atomic.h gdk_batop.c gdk_select.c \
gdk_search.c gdk_search.h gdk_tm.c \
gdk_align.c gdk_bbp.c gdk_bbp.h \
- gdk_heap.c gdk_setop.mx gdk_utils.c gdk_utils.h \
+ gdk_heap.c gdk_setop.c gdk_utils.c gdk_utils.h \
gdk_atoms.c gdk_atoms.h \
gdk_qsort.c gdk_qsort_impl.h gdk_ssort.c gdk_ssort_impl.h \
gdk_storage.c gdk_bat.c \
diff --git a/gdk/gdk_setop.mx b/gdk/gdk_setop.c
rename from gdk/gdk_setop.mx
rename to gdk/gdk_setop.c
--- a/gdk/gdk_setop.mx
+++ b/gdk/gdk_setop.c
@@ -1,25 +1,26 @@
-@/
-The contents of this file are subject to the MonetDB Public License
-Version 1.1 (the "License"); you may not use this file except in
-compliance with the License. You may obtain a copy of the License at
-http://www.monetdb.org/Legal/MonetDBLicense
+/*
+ * The contents of this file are subject to the MonetDB Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.monetdb.org/Legal/MonetDBLicense
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the MonetDB Database System.
+ *
+ * The Initial Developer of the Original Code is CWI.
+ * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+ * Copyright August 2008-2013 MonetDB B.V.
+ * All Rights Reserved.
+ */
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is the MonetDB Database System.
-
-The Initial Developer of the Original Code is CWI.
-Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
-Copyright August 2008-2013 MonetDB B.V.
-All Rights Reserved.
-@
-
-@f gdk_setop
-
-@c
+/*
+ * @f gdk_setop
+ *
+ */
/*
* @a Peter Boncz
*
@@ -66,7 +67,7 @@ All Rights Reserved.
* The @emph{kintersect(l,r)} is used also as implementation for the
* @emph{semijoin()}.
*/
-@c
+
#include "monetdb_config.h"
#include "gdk.h"
#include "gdk_private.h"
@@ -76,8 +77,6 @@ All Rights Reserved.
#define HITs(t1,t2) ((*cmp)(t1,t2) == 0)
#define EQUALs(t1,t2) ((*cmp)(t1,t2) == 0 && (*cmp)(t1,tnil))
#define EQUALk(t1,t2) TRUE
-#define FLIPs TRUE
-#define FLIPk FALSE
#define HITintersect(h,t) bunfastins(bn,h,t)
#define HITdiff(h,t)
@@ -102,105 +101,115 @@ All Rights Reserved.
* Comes in two flavors: looking at one column, or at two at-a-time.
* Implementation is either merge- or hash-based.
*/
-@= mergeelim
- BATloop(b, p, q) {
- ptr h = BUNh@2(bi,p);
- ptr t = BUNt@3(bi,p);
+#define mergeelim(a1,a2,a3,a4,a5) \
+ do { \
+ BATloop(b, p, q) { \
+ ptr h = BUNh##a2(bi,p); \
+ ptr t = BUNt##a3(bi,p); \
+ \
+ for (r = p + 1; r < q && a4 == 0; r++) { \
+ if (HIT##a1(t, BUNt##a3(bi, r))) \
+ goto next##a2##a3##a5; \
+ } \
+ bunfastins(bn, h, t); \
+ next##a2##a3##a5:; \
+ } \
+ } while (0)
+#define hashelim(a1,a2,a3,a4) \
+ do { \
+ zz = BUNfirst(bn); \
+ if (!bn->H->hash) { \
+ if (BAThash(bn, BATcapacity(bn)) == NULL) { \
+ BBPreclaim(bn); \
+ return NULL; \
+ } \
+ } \
+ BATloop(b, p, q) { \
+ ptr h = BUNh##a2(bi, p); \
+ ptr t = BUNt##a3(bi, p); \
+ int ins = 1; \
+ BUN yy; \
+ \
+ if (BATprepareHash(bn)) { \
+ BBPreclaim(bn); \
+ return NULL; \
+ } \
+ HASHloop##a4(bni, bn->H->hash, yy, h) { \
+ if (HIT##a1(t, BUNt##a3(bni, yy))) { \
+ ins = 0; \
+ break; \
+ } \
+ } \
+ if (ins) { \
+ bunfastins(bn, h, t); \
+ if (bn->H->hash) \
+ HASHins##a4(bn->H->hash, zz, h); \
+ zz++; \
+ } \
+ } \
+ } while (0)
+#define elim(a1,a2,a3,a4) \
+ { \
+ int (*cmp)(const void *, const void *) =
BATatoms[b->ttype].atomCmp; \
+ BUN zz; \
+ BUN p, q, r; \
+ \
+ if (BAThordered(b)) { \
+ ALGODEBUG fprintf(stderr, "#BATins_%sunique:
BAThordered(b)\n", #a1); \
+ ALGODEBUG fprintf(stderr, "#BATins_%sunique:
mergeelim\n", #a1); \
+ if (b->tvarsized) { \
+ mergeelim(a1,a2,var,a4,a3); \
+ } else { \
+ mergeelim(a1,a2,loc,a4,a3); \
+ } \
+ } else if (b->tvarsized) { \
+ ALGODEBUG fprintf(stderr, "#BATins_%sunique:
hashelim\n", #a1); \
+ hashelim(a1,a2,var,a3); \
+ } else { \
+ ALGODEBUG fprintf(stderr, "#BATins_%sunique:
hashelim\n", #a1); \
+ hashelim(a1,a2,loc,a3); \
+ } \
+ (void) cmp; \
+ break; \
+ }
+#define elim_doubles(a1) \
+ switch (ATOMstorage(b->htype)) { \
+ case TYPE_bte: \
+ elim(a1,loc,_bte,simple_CMP(h,BUNhloc(bi,r),bte)); \
+ break; \
+ case TYPE_sht: \
+ elim(a1,loc,_sht,simple_CMP(h,BUNhloc(bi,r),sht)); \
+ break; \
+ case TYPE_int: \
+ elim(a1,loc,_int,simple_CMP(h,BUNhloc(bi,r),int)); \
+ break; \
+ case TYPE_flt: \
+ elim(a1,loc,_flt,simple_CMP(h,BUNhloc(bi,r),flt)); \
+ break; \
+ case TYPE_dbl: \
+ elim(a1,loc,_dbl,simple_CMP(h,BUNhloc(bi,r),dbl)); \
+ break; \
+ case TYPE_lng: \
+ elim(a1,loc,_lng,simple_CMP(h,BUNhloc(bi,r),lng)); \
+ break; \
+ case TYPE_str: \
+ if (b->H->vheap->hashash) { \
+ elim(a1,var,_str_hv,GDK_STRCMP(h,BUNhvar(bi,r))); \
+ break; \
+ } \
+ /* fall through */ \
+ default: { \
+ int (*merge)(const void *, const void *) =
BATatoms[b->htype].atomCmp; \
+ \
+ if (b->hvarsized) { \
+ elim(a1,var,var,((*merge)(h,BUNhvar(bi,r)))); \
+ } else { \
+ elim(a1,loc,loc,((*merge)(h,BUNhloc(bi,r)))); \
+ } \
+ break; \
+ } \
+ }
- for (r = p + 1; r < q && @4 == 0; r++) {
- if (HIT@1(t, BUNt@3(bi, r)))
- goto next@2@3@5;
- }
- bunfastins(bn, h, t);
- next@2@3@5:;
- }
-@= hashelim
- zz = BUNfirst(bn);
- if (!bn->H->hash) {
- if (BAThash(bn, BATcapacity(bn)) == NULL) {
- BBPreclaim(bn);
- return NULL;
- }
- }
- BATloop(b, p, q) {
- ptr h = BUNh@2(bi, p);
- ptr t = BUNt@3(bi, p);
- int ins = 1;
- BUN yy;
-
- if (BATprepareHash(bn)) {
- BBPreclaim(bn);
- return NULL;
- }
- HASHloop@4(bni, bn->H->hash, yy, h) {
- if (HIT@1(t, BUNt@3(bni, yy))) {
- ins = 0;
- break;
- }
- }
- if (ins) {
- bunfastins(bn, h, t);
- if (bn->H->hash)
- HASHins@4(bn->H->hash, zz, h);
- zz++;
- }
- }
-@= elim
- {
- int (*cmp)(const void *, const void *) =
BATatoms[b->ttype].atomCmp;
- BUN zz;
- BUN p, q, r;
-
- if (BAThordered(b)) {
- ALGODEBUG fprintf(stderr, "#BATins_@1unique:
BAThordered(b)\n");
- ALGODEBUG fprintf(stderr, "#BATins_@1unique:
mergeelim\n");
- if (b->tvarsized) {
- @:mergeelim(@1,@2,var,@4,@3)@
- } else {
- @:mergeelim(@1,@2,loc,@4,@3)@
- }
- } else if (b->tvarsized) {
- ALGODEBUG fprintf(stderr, "#BATins_@1unique:
hashelim\n");
- @:hashelim(@1,@2,var,@3)@
- } else {
- ALGODEBUG fprintf(stderr, "#BATins_@1unique:
hashelim\n");
- @:hashelim(@1,@2,loc,@3)@
- }
- (void) cmp;
- break;
- }
-@= elim_doubles
- switch (ATOMstorage(b->htype)) {
- case TYPE_bte:
- @:elim(@1,loc,_bte,simple_CMP(h,BUNhloc(bi,r),bte))@
- case TYPE_sht:
- @:elim(@1,loc,_sht,simple_CMP(h,BUNhloc(bi,r),sht))@
- case TYPE_int:
- @:elim(@1,loc,_int,simple_CMP(h,BUNhloc(bi,r),int))@
- case TYPE_flt:
- @:elim(@1,loc,_flt,simple_CMP(h,BUNhloc(bi,r),flt))@
- case TYPE_dbl:
- @:elim(@1,loc,_dbl,simple_CMP(h,BUNhloc(bi,r),dbl))@
- case TYPE_lng:
- @:elim(@1,loc,_lng,simple_CMP(h,BUNhloc(bi,r),lng))@
- case TYPE_str:
- if (b->H->vheap->hashash) {
- @:elim(@1,var,_str_hv,GDK_STRCMP(h,BUNhvar(bi,r)))@
- }
- /* fall through */
- default:
- {
- int (*merge)(const void *, const void *) =
BATatoms[b->htype].atomCmp;
-
- if (b->hvarsized) {
- @:elim(@1,var,var,((*merge)(h,BUNhvar(bi,r))))@
- } else {
- @:elim(@1,loc,loc,((*merge)(h,BUNhloc(bi,r))))@
- }
- }
- }
-@
-@c
static BAT *
BATins_kunique(BAT *bn, BAT *b)
{
@@ -211,7 +220,7 @@ BATins_kunique(BAT *bn, BAT *b)
BATcheck(b, "BATins_kunique: src BAT required");
BATcheck(bn, "BATins_kunique: dst BAT required");
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list