Changeset: 4a90b9e13490 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4a90b9e13490 Modified Files: gdk/gdk_batop.mx Branch: default Log Message:
Steps toward de-mx-ing gdk_batop. diffs (truncated from 803 to 300 lines): diff --git a/gdk/gdk_batop.mx b/gdk/gdk_batop.mx --- a/gdk/gdk_batop.mx +++ b/gdk/gdk_batop.mx @@ -51,17 +51,16 @@ All Rights Reserved. #include "gdk_private.h" #include "gdk_scanselect.h" -@= updateloop -{ - BATiter bi = bat_iterator(@2); - BUN p1, p2; +#define updateloop(bn, b, func) \ + do { \ + BATiter bi = bat_iterator(b); \ + BUN p1, p2; \ + \ + BATloop(b, p1, p2) { \ + func(bn, BUNhead(bi, p1), BUNtail(bi, p1)); \ + } \ + } while (0) - BATloop(@2, p1, p2) { - @3(@1, BUNhead(bi, p1), BUNtail(bi, p1)); - } -} -@ -@c /* * @+ BAT insert/delete/replace * The content of a BAT can be appended to (removed from) another using @@ -436,7 +435,7 @@ BATins(BAT *b, BAT *n, bit force) b->H->nonil &= n->H->nonil; b->T->nonil &= n->T->nonil; } else { - @:updateloop(b,n,bunins)@ + updateloop(b, n, bunins); } res = b; bunins_failed: @@ -709,7 +708,7 @@ BATdel(BAT *b, BAT *n, bit force) ALIGNdel(b, "BATdel", force); TYPEcheck(b->htype, n->htype); TYPEcheck(b->ttype, n->ttype); - @:updateloop(b,n,bundel)@ + updateloop(b, n, bundel); return b; } @@ -724,12 +723,11 @@ BATdelHead(BAT *b, BAT *n, bit force) } ALIGNdel(b, "BATdelHead", force); TYPEcheck(b->htype, n->htype); - @:updateloop(b,n,bundelhead)@ + updateloop(b, n, bundelhead); return b; } /* - * @- * The last in this series is a BATreplace, which replaces all the * buns mentioned. */ @@ -741,7 +739,7 @@ BATreplace(BAT *b, BAT *n, bit force) return b; } BATcompatible(b, n); - @:updateloop(b,n,BUNreplace_force)@ + updateloop(b, n, BUNreplace_force); return b; } @@ -792,7 +790,6 @@ BATslice(BAT *b, BUN l, BUN h) } /* - * @- * If the source BAT is readonly, then we can obtain a VIEW * that just reuses the memory of the source. */ @@ -807,7 +804,6 @@ BATslice(BAT *b, BUN l, BUN h) BATsetcount(bn, cnt); BATsetcapacity(bn, cnt); /* - * @- * We have to do it: create a new BAT and put everything into it. */ } else { @@ -1079,7 +1075,6 @@ BAT_select_(BAT *b, const void *tl, cons BATcheck(b, "BATselect"); BATcheck(tl, "BATselect: tl value required"); /* - * @- * Examine type, and values for lower- and higher-bound. */ batcnt = BATcount(b); @@ -1238,7 +1233,6 @@ BAT_select_(BAT *b, const void *tl, cons return bn; } /* - * @- * Use sampling to determine a good result size, when the bat is large. */ if (BATtkey(b)) { @@ -1266,7 +1260,6 @@ BAT_select_(BAT *b, const void *tl, cons estimate = MAX(estimate, BATguess(b)); } /* - * @- * Create the result BAT and execute the select algorithm. */ if (ht == TYPE_void && tt == TYPE_void) { @@ -1301,7 +1294,6 @@ BAT_select_(BAT *b, const void *tl, cons return NULL; /* error occurred */ } /* - * @- * Propagate alignment info. Key properties are inherited from the parent. * Hash changes the order; IDX yields ordered tail; scan respects original order. */ @@ -1414,7 +1406,6 @@ BATtopN(BAT *b, BUN topN) } /* - * @- * The baseline algorithm for fragment location is a two-phase process. * First we search on the 1st * dimension and collect the qualifying BUNs in a marking on the @@ -2062,7 +2053,7 @@ BATrevert(BAT *b) * @+ BAT partitioning * For distributed processing we support hash and range * partitioning operators: BATsplithash and BATsplitrange. - * @- + * * The part_bat function creates a partition BAT. */ static BAT * @@ -2140,7 +2131,7 @@ BAThashsplit(BAT *b, BUN n, int unary) goto bunins_failed; } metabati = bat_iterator(metabat); - @:updateloop(metabat,b,BUNhash)@ + updateloop(metabat, b, BUNhash); BATloop(metabat, p, q) { bat bt = *(bat *) BUNtail(metabati, p); @@ -2154,7 +2145,6 @@ BAThashsplit(BAT *b, BUN n, int unary) } /* - * @- * Range partitioning ensures that identical values appear in one * partition only. The routine also tries to deliver partitions of * uniform size. @@ -2190,7 +2180,6 @@ BATrangesplit(BAT *b, BUN n, int unary) nilval = ATOMnilptr(BATttype(b)); /* - * @- * We use sampling to determine bucket sizes. * Uniform bucket sizes are the ideal to be achieved. * If necessary though, we deliver less than n buckets. @@ -2205,7 +2194,6 @@ BATrangesplit(BAT *b, BUN n, int unary) if ((seps = (ptr *) GDKmalloc(2 * n * sizeof(ptr))) == NULL) goto bunins_failed; /* - * @- * Use the histogram to determine good split boundaries on b. */ BATorder(histo); @@ -2243,7 +2231,6 @@ BATrangesplit(BAT *b, BUN n, int unary) n = yy + 1; } /* - * @- * CASE 1: just one bucket. * This is done without copying b. */ @@ -2252,7 +2239,6 @@ BATrangesplit(BAT *b, BUN n, int unary) goto bunins_failed; /* - * @- * CASE 2: sorted on fragmentation column. * We can again avoid copying, by giving slices (views) on the source BAT. * Virtual oids (void) is a special subcase with positional lookup instead @@ -2278,7 +2264,6 @@ BATrangesplit(BAT *b, BUN n, int unary) } /* - * @- * CASE 3: full scan. * If it ain't sorted then we gotta scan the whole thing and split. * This is heavy stuff so we optimize execution according to datatype. @@ -2431,7 +2416,7 @@ BATnumber(BAT *b) if (bn == NULL) return NULL; r = BUNfirst(bn); - @:updateloop(bn,b,BUNnumber)@ + updateloop(bn, b, BUNnumber); ALIGNsetH(bn, b); BATsetprop_wrd(bn, GDK_AGGR_CARD, i); /* 64bit: no (wrd) cast to remind us */ bn->hsorted = BAThordered(b); @@ -2489,97 +2474,91 @@ BATgroup(BAT *b, int start, int incr, in return NULL; } -@= mark_grp_init - BUN w; +#define mark_grp_init(BUNfnd) \ + do { \ + BUN w; \ + \ + BUNfnd(w, gi, &v); \ + if (w != BUN_NONE) { \ + n = * (oid *) BUNtloc(gi, w); \ + } else { \ + n = oid_nil; \ + } \ + } while (0) - BUNfnd@1(w, gi, &v); - if (w != BUN_NONE) { - n = * (oid *) BUNtloc(gi, w); - } else { - n = oid_nil; - } -@ -@= mark_grp_loop4 - oid u = oid_nil; - oid n = oid_nil; +#define mark_grp_loop4(BUNhead, buninsert, BUNtail, init_n) \ + do { \ + oid u = oid_nil; \ + oid n = oid_nil; \ + \ + bn->T->nil = 0; \ + BATloop(b, p, q) { \ + oid v = * (oid *) BUNtail(bi, p); \ + \ + if (v != u) { \ + init_n; \ + u = v; \ + } else if (n != oid_nil) { \ + n++; \ + } \ + if (n == oid_nil) \ + bn->T->nil =1; \ + buninsert(bn, r, BUNhead(bi, p), &n); \ + r++; \ + } \ + bn->T->nonil = !bn->T->nil; \ + } while (0) - bn->T->nil = 0; - BATloop(b, p, q) { - oid v = * (oid *) BUNt@3(bi, p); +#define mark_grp_loop3(BUNhead, buninsert, BUNtail, BUNfnd) \ + do { \ + bn->T->nil = 0; \ + BATloop(b, p, q) { \ + oid n = oid_nil; \ + BUN w; \ + const void *v = BUNtail(bi, p); \ + oid *m; \ + \ + BUNfnd(w, gci, v); \ + if (w != BUN_NONE && *(m = (oid*) BUNtloc(gci, w)) != oid_nil) { \ + n = (*m)++; \ + } else \ + bn->T->nil = 1; \ + buninsert(bn, r, BUNhead(bi, p), &n); \ + r++; \ + } \ + bn->T->nonil = !bn->T->nil; \ + } while (0) - if (v != u) { - @4 - u = v; - } else if (n != oid_nil) { - n++; - } - if (n == oid_nil) - bn->T->nil =1; - @2oid_bunfastins_nocheck_noinc(bn, r, BUNh@1(bi, p), &n); - r++; - } - bn->T->nonil = !bn->T->nil; -@ -@= mark_grp_loop3 - bn->T->nil = 0; - BATloop(b, p, q) { - oid n = oid_nil; - BUN w; - const void *v = BUNt@3(bi, p); - oid *m; +#define mark_grp_loop2(BUNhead, buninsert, BUNtail) \ + do { \ + if (gc) { \ + BATiter gci = bat_iterator(gc); \ _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list