Changeset: 51b97d607fdf for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=51b97d607fdf
Modified Files:
        gdk/gdk_aggr.c
        gdk/gdk_join.c
        gdk/gdk_logger.c
        gdk/gdk_select.c
Branch: default
Log Message:

merger


diffs (268 lines):

diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -2186,13 +2186,15 @@ BATmax(BAT *b, void *aggr)
 /* quantiles/median */
 
 BAT *
-
-BATgroupmedian(BAT *b, BAT *g, BAT *e, BAT *s, int tp, int skip_nils, int 
abort_on_error) {
+BATgroupmedian(BAT *b, BAT *g, BAT *e, BAT *s, int tp,
+              int skip_nils, int abort_on_error)
+{
        return BATgroupquantile(b,g,e,s,tp,0.5,skip_nils,abort_on_error);
 }
 
 BAT *
- BATgroupquantile(BAT *b, BAT *g, BAT *e, BAT *s, int tp, double quantile,int 
skip_nils, int abort_on_error)
+BATgroupquantile(BAT *b, BAT *g, BAT *e, BAT *s, int tp, double quantile,
+                int skip_nils, int abort_on_error)
 {
        int freeb = 0, freeg = 0;
        oid min, max;
@@ -2221,7 +2223,8 @@ BAT *
                return NULL;
        }
        if (quantile < 0 || quantile > 1) {
-               GDKerror("BATgroupquantile: cannot determine quantile for p=%f 
(p has to be in [0,1])\n",quantile);
+               GDKerror("BATgroupquantile: cannot determine quantile for "
+                        "p=%f (p has to be in [0,1])\n", quantile);
                return NULL;
        }
        assert(quantile >=0 && quantile <=1);
@@ -2237,20 +2240,10 @@ BAT *
        if (s) {
                /* there is a candidate list, replace b (and g, if
                 * given) with just the values we're interested in */
-               b = BATleftjoin(s, b, BATcount(s));
-               if (b->htype != TYPE_void) {
-                       t1 = BATmirror(BATmark(BATmirror(b), 0));
-                       BBPunfix(b->batCacheid);
-                       b = t1;
-               }
+               b = BATproject(s, b);
                freeb = 1;
                if (g) {
-                       g = BATleftjoin(s, g, BATcount(s));
-                       if (g->htype != TYPE_void) {
-                               t1 = BATmirror(BATmark(BATmirror(g), 0));
-                               BBPunfix(g->batCacheid);
-                               g = t1;
-                       }
+                       g = BATproject(s, g);
                        freeg = 1;
                }
        }
@@ -2299,7 +2292,8 @@ BAT *
 
                grps = (const oid *) Tloc(g, BUNfirst(g));
                prev = grps[0];
-                /* for each group (r and p are the beginning and end of the 
current group, respectively) */
+                /* for each group (r and p are the beginning and end
+                 * of the current group, respectively) */
                for (r = 0, p = 1, q = BATcount(g); p <= q; p++) {
                        assert(r < p);
                        if ( p == q || grps[p] != prev) {
@@ -2314,7 +2308,7 @@ BAT *
                                        nils++;
                                }
                                qindex = BUNfirst(b) + (BUN) (r + (p-r-1) * 
quantile);
-                               // be a little paranoid about the index
+                               /* be a little paranoid about the index */
                                assert(qindex >= (BUNfirst(b) + r ));
                                assert(qindex <  (BUNfirst(b) + p));
                                v = BUNtail(bi, qindex);
diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -2682,6 +2682,8 @@ BATproject(BAT *l, BAT *r)
 }
 
 /* backward compatible interfaces */
+
+/* Return a subset of l where head elements occur as head element in r. */
 BAT *
 BATsemijoin(BAT *l, BAT *r)
 {
@@ -2775,13 +2777,24 @@ do_batjoin(BAT *l, BAT *r, int op,
           gdk_return (*thetajoin)(BAT **, BAT **, BAT *, BAT *, BAT *, BAT *,
                                   int, int, BUN),
           gdk_return (*bandjoin)(BAT **, BAT **, BAT *, BAT *, BAT *, BAT *,
-                                 const void *, const void *, int, int, BUN))
+                                 const void *, const void *, int, int, BUN),
+          const char *name)
 {
        BAT *lmap, *rmap;
        BAT *res1, *res2;
        BAT *bn;
        gdk_return ret;
 
+       ALGODEBUG fprintf(stderr, "#Legacy %s(l=%s#" BUNFMT "[%s,%s]%s%s%s,"
+                         "r=%s#" BUNFMT "[%s,%s]%s%s%s)\n", name,
+                         BATgetId(l), BATcount(l), ATOMname(l->htype), 
ATOMname(l->ttype),
+                         BAThdense(l) ? "-hdense" : "",
+                         l->tsorted ? "-sorted" : "",
+                         l->trevsorted ? "-revsorted" : "",
+                         BATgetId(r), BATcount(r), ATOMname(r->htype), 
ATOMname(r->ttype),
+                         BAThdense(r) ? "-hdense" : "",
+                         r->tsorted ? "-sorted" : "",
+                         r->trevsorted ? "-revsorted" : "");
        r = BATmirror(r);
        /* r is [any_3,any_2] */
        if (!BAThdense(l) || !BAThdense(r)) {
@@ -2854,7 +2867,8 @@ do_batjoin(BAT *l, BAT *r, int op,
 BAT *
 BATjoin(BAT *l, BAT *r, BUN estimate)
 {
-       return do_batjoin(l, r, 0, NULL, NULL, 0, 0, estimate, BATsubjoin, 
NULL, NULL);
+       return do_batjoin(l, r, 0, NULL, NULL, 0, 0, estimate,
+                         BATsubjoin, NULL, NULL, "BATjoin");
 }
 
 /* join [any_1,any_2] with [any_2,any_3], return [any_1,any_3];
@@ -2862,7 +2876,8 @@ BATjoin(BAT *l, BAT *r, BUN estimate)
 BAT *
 BATleftjoin(BAT *l, BAT *r, BUN estimate)
 {
-       return do_batjoin(l, r, 0, NULL, NULL, 0, 0, estimate, BATsubleftjoin, 
NULL, NULL);
+       return do_batjoin(l, r, 0, NULL, NULL, 0, 0, estimate,
+                         BATsubleftjoin, NULL, NULL, "BATleftjoin");
 }
 
 /* join [any_1,any_2] with [any_2,any_3], return [any_1,any_3] */
@@ -2870,8 +2885,10 @@ BAT *
 BATthetajoin(BAT *l, BAT *r, int op, BUN estimate)
 {
        if (op == JOIN_EQ)
-               return do_batjoin(l, r, 0, NULL, NULL, 0, 0, estimate, 
BATsubjoin, NULL, NULL);
-       return do_batjoin(l, r, op, NULL, NULL, 0, 0, estimate, NULL, 
BATsubthetajoin, NULL);
+               return do_batjoin(l, r, 0, NULL, NULL, 0, 0, estimate,
+                                 BATsubjoin, NULL, NULL, "BATthetajoin");
+       return do_batjoin(l, r, op, NULL, NULL, 0, 0, estimate, NULL,
+                         BATsubthetajoin, NULL, "BATthetajoin");
 }
 
 /* join [any_1,any_2] with [any_2,any_3], return [any_1,any_3];
@@ -2879,7 +2896,8 @@ BATthetajoin(BAT *l, BAT *r, int op, BUN
 BAT *
 BATouterjoin(BAT *l, BAT *r, BUN estimate)
 {
-       return do_batjoin(l, r, 0, NULL, NULL, 0, 0, estimate, BATsubouterjoin, 
NULL, NULL);
+       return do_batjoin(l, r, 0, NULL, NULL, 0, 0, estimate,
+                         BATsubouterjoin, NULL, NULL, "BATouterjoin");
 }
 
 /* join [any_1,any_2] with [any_2,any_3], return [any_1,any_3];
@@ -2887,7 +2905,8 @@ BATouterjoin(BAT *l, BAT *r, BUN estimat
 BAT *
 BATleftfetchjoin(BAT *l, BAT *r, BUN estimate)
 {
-       return do_batjoin(l, r, 0, NULL, NULL, 0, 0, estimate, 
BATsubleftfetchjoin, NULL, NULL);
+       return do_batjoin(l, r, 0, NULL, NULL, 0, 0, estimate,
+                         BATsubleftfetchjoin, NULL, NULL, "BATleftfetchjoin");
 }
 
 BAT *
@@ -2895,12 +2914,12 @@ BATantijoin(BAT *l, BAT *r)
 {
        return do_batjoin(l, r, JOIN_NE, NULL, NULL, 0, 0,
                          (BUN) MIN((lng) BATcount(l) * BATcount(r), BUN_MAX),
-                         NULL, BATsubthetajoin, NULL);
+                         NULL, BATsubthetajoin, NULL, "BATantijoin");
 }
 
 BAT *
 BATbandjoin(BAT *l, BAT *r, const void *c1, const void *c2, bit li, bit hi)
 {
        return do_batjoin(l, r, 0, c1, c2, li, hi, BUN_NONE,
-                         NULL, NULL, BATsubbandjoin);
+                         NULL, NULL, BATsubbandjoin, "BATbandjoin");
 }
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -1912,13 +1912,18 @@ log_tend(logger *lg)
 
        if (DELTAdirty(lg->snapshots_bid)) {
                /* sub commit all new snapshots */
-               BAT *tids = BATuselect(lg->snapshots_tid, &lg->tid, &lg->tid);
-               BAT *bids = BATsemijoin(lg->snapshots_bid, tids);
+               BAT *tids, *bids;
 
+               tids = BATsubselect(lg->snapshots_tid, NULL, &lg->tid, &lg->tid,
+                                   TRUE, TRUE, FALSE);
+               if (tids == NULL)
+                       return LOG_ERR;
+               bids = BATproject(tids, lg->snapshots_bid);
                BBPunfix(tids->batCacheid);
                if (bids == NULL)
                        return LOG_ERR;
-               res = bm_subcommit(bids, NULL, lg->snapshots_bid, 
lg->snapshots_tid, NULL, lg->debug);
+               res = bm_subcommit(bids, NULL, lg->snapshots_bid,
+                                  lg->snapshots_tid, NULL, lg->debug);
                BBPunfix(bids->batCacheid);
        }
        l.flag = LOG_END;
diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -1425,13 +1425,23 @@ BATthetasubselect(BAT *b, BAT *s, const 
 
 static BAT *
 BAT_select_(BAT *b, const void *tl, const void *th,
-            bit li, bit hi, bit tail, bit anti)
+            bit li, bit hi, bit tail, bit anti, const char *name)
 {
        BAT *bn;
        BAT *bn1 = NULL;
        BAT *map;
        BAT *b1;
 
+       ALGODEBUG fprintf(stderr, "#Legacy %s(b=%s#" BUNFMT "[%s,%s]%s%s%s,"
+                         "li=%s,hi=%s,tail=%s,anti=%s)\n", name,
+                         BATgetId(b), BATcount(b), ATOMname(b->htype), 
ATOMname(b->ttype),
+                         BAThdense(b) ? "-hdense" : "",
+                         b->tsorted ? "-sorted" : "",
+                         b->trevsorted ? "-revsorted" : "",
+                         li ? "true" : "false",
+                         hi ? "true" : "false",
+                         tail ? "true" : "false",
+                         anti ? "true" : "false");
        BATcheck(b, "BAT_select_");
        /* b is a [any_1,any_2] BAT */
        if (!BAThdense(b)) {
@@ -1533,27 +1543,31 @@ BAT_select_(BAT *b, const void *tl, cons
 BAT *
 BATselect_(BAT *b, const void *h, const void *t, bit li, bit hi)
 {
-       return BAT_select_(b, h, t, li, hi, TRUE, FALSE);
+       return BAT_select_(b, h, t, li, hi, TRUE, FALSE, "BATselect_");
 }
 
 BAT *
 BATuselect_(BAT *b, const void *h, const void *t, bit li, bit hi)
 {
-       return BAT_select_(b, h, t, li, hi, FALSE, FALSE);
+       return BAT_select_(b, h, t, li, hi, FALSE, FALSE, "BATuselect_");
 }
 
 BAT *
 BATantiuselect_(BAT *b, const void *h, const void *t, bit li, bit hi)
 {
-       return BAT_select_(b, h, t, li, hi, FALSE, TRUE);
+       return BAT_select_(b, h, t, li, hi, FALSE, TRUE, "BATantiuselect");
 }
 
+/* Return a BAT which is a subset of b with just the qualifying
+ * tuples. */
 BAT *
 BATselect(BAT *b, const void *h, const void *t)
 {
        return BATselect_(b, h, t, TRUE, TRUE);
 }
 
+/* Return a BAT with in its head a subset of qualifying tuples from
+ * the head of b, and void-nil in its tail. */
 BAT *
 BATuselect(BAT *b, const void *h, const void *t)
 {
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to