Changeset: aa4d33e68cd0 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=aa4d33e68cd0
Modified Files:
        gdk/gdk.h
        gdk/gdk_aggr.c
        gdk/gdk_atoms.c
        gdk/gdk_bbp.c
        monetdb5/optimizer/opt_groups.c
        sql/backends/monet5/bam/bam_globals.c
        sql/backends/monet5/sql_statistics.c
Branch: default
Log Message:

Merge with Oct2014 branch.


diffs (truncated from 506 to 300 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -934,29 +934,29 @@ typedef struct PROPrec PROPrec;
 /* see also comment near BATassertProps() for more information about
  * the properties */
 typedef struct {
-       str id;                         /* label for head/tail column */
+       str id;                 /* label for head/tail column */
 
        unsigned short width;   /* byte-width of the atom array */
-       bte type;                       /* type id. */
-       bte shift;                      /* log2 of bunwidth */
+       bte type;               /* type id. */
+       bte shift;              /* log2 of bunwidth */
        unsigned int
         varsized:1,            /* varsized (1) or fixedsized (0) */
-        key:2,                         /* duplicates allowed? */
-        dense:1,                       /* OID only: only consecutive values */
-        nonil:1,                       /* nonil isn't propchecked yet */
-        nil:1,                         /* there is a nil in the column */
-        sorted:1,                      /* column is sorted in ascending order 
*/
+        key:2,                 /* duplicates allowed? */
+        dense:1,               /* OID only: only consecutive values */
+        nonil:1,               /* nonil isn't propchecked yet */
+        nil:1,                 /* there is a nil in the column */
+        sorted:1,              /* column is sorted in ascending order */
         revsorted:1;           /* column is sorted in descending order */
-       oid align;                      /* OID for sync alignment */
+       oid align;              /* OID for sync alignment */
        BUN nokey[2];           /* positions that prove key ==FALSE */
        BUN nosorted;           /* position that proves sorted==FALSE */
        BUN norevsorted;        /* position that proves revsorted==FALSE */
        BUN nodense;            /* position that proves dense==FALSE */
-       oid seq;                        /* start of dense head sequence */
+       oid seq;                /* start of dense head sequence */
 
-       Heap heap;                      /* space for the column. */
+       Heap heap;              /* space for the column. */
        Heap *vheap;            /* space for the varsized data. */
-       Hash *hash;                     /* hash table */
+       Hash *hash;             /* hash table */
        Imprints *imprints;     /* column imprints index */
 
        PROPrec *props;         /* list of dynamic properties stored in the bat 
descriptor */
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -1454,10 +1454,15 @@ BATgroupavg(BAT **bnp, BAT **cntsp, BAT 
                /* trivial: no averages, so return bat aligned with g
                 * with nil in the tail */
                bn = BATconstant(TYPE_dbl, &dbl_nil, ngrp, TRANSIENT);
+               if (bn == NULL) {
+                       GDKerror("BATgroupavg: failed to create BAT\n");
+                       return GDK_FAIL;
+               }
                BATseqbase(bn, ngrp == 0 ? 0 : min);
                if (cntsp) {
                        wrd zero = 0;
                        if ((*cntsp = BATconstant(TYPE_wrd, &zero, ngrp, 
TRANSIENT)) == NULL) {
+                               GDKerror("BATgroupavg: failed to create BAT\n");
                                BBPreclaim(bn);
                                return GDK_FAIL;
                        }
@@ -2054,118 +2059,15 @@ BATgroupsize(BAT *b, BAT *g, BAT *e, BAT
                }                                                       \
        } while (0)
 
-static BAT *
-BATgroupminmax(BAT *b, BAT *g, BAT *e, BAT *s, int tp, int skip_nils,
-              int abort_on_error, 
-              BUN (*minmax)(oid *restrict, BAT *, const oid *restrict, BUN,
-                            oid, oid, BUN, BUN, const oid *restrict,
-                            const oid *, BUN, int, int),
-              const char *name)
-{
-       const oid *restrict gids;
-       oid min, max;
-       BUN ngrp;
-       oid *restrict oids;
-       BAT *bn = NULL;
-       BUN nils;
-       BUN start, end, cnt;
-       const oid *cand = NULL, *candend = NULL;
-       const char *err;
-
-       assert(tp == TYPE_oid);
-       (void) tp;              /* compatibility (with other BATgroup* */
-       (void) abort_on_error;  /* functions) argument */
-
-       if (!ATOMlinear(b->ttype)) {
-               GDKerror("%s: cannot determine minimum on "
-                        "non-linear type %s\n", name, ATOMname(b->ttype));
-               return NULL;
-       }
-
-       if ((err = BATgroupaggrinit(b, g, e, s, &min, &max, &ngrp, &start, &end,
-                                   &cnt, &cand, &candend)) != NULL) {
-               GDKerror("%s: %s\n", name, err);
-               return NULL;
-       }
-
-       if (BATcount(b) == 0 || ngrp == 0) {
-               /* trivial: no minimums, so return bat aligned with g
-                * with nil in the tail */
-               bn = BATconstant(TYPE_oid, &oid_nil, ngrp, TRANSIENT);
-               BATseqbase(bn, ngrp == 0 ? 0 : min);
-               return bn;
-       }
-
-       bn = BATnew(TYPE_void, TYPE_oid, ngrp, TRANSIENT);
-       if (bn == NULL)
-               return NULL;
-       oids = (oid *) Tloc(bn, BUNfirst(bn));
-
-       if (g == NULL || BATtdense(g))
-               gids = NULL;
-       else
-               gids = (const oid *) Tloc(g, BUNfirst(g) + start);
-
-       nils = (*minmax)(oids, b, gids, ngrp, min, max, start, end,
-                        cand, candend, cnt, skip_nils, g && BATtdense(g));
-
-       BATsetcount(bn, ngrp);
-
-       BATseqbase(bn, min);
-       bn->tkey = BATcount(bn) <= 1;
-       bn->tsorted = BATcount(bn) <= 1;
-       bn->trevsorted = BATcount(bn) <= 1;
-       bn->T->nil = nils != 0;
-       bn->T->nonil = nils == 0;
-       return bn;
-}
-
-static void *
-BATminmax(BAT *b, void *aggr,
-         BUN (*minmax)(oid *restrict, BAT *, const oid *restrict, BUN,
-                       oid, oid, BUN, BUN, const oid *restrict,
-                       const oid *, BUN, int, int))
-{
-       oid pos;
-       void *res;
-       int s;
-       int needdecref = 0;
-       BATiter bi;
-
-       if (!BAThdense(b)) {
-               if ((b = BATmirror(BATmark(BATmirror(b), 0))) == NULL)
-                       return NULL;
-               needdecref = 1;
-       }
-       (void) (*minmax)(&pos, b, NULL, 1, 0, 0, 0, BATcount(b), NULL, NULL,
-                        BATcount(b), 1, 0);
-       if (pos == oid_nil) {
-               res = ATOMnilptr(b->ttype);
-       } else {
-               bi = bat_iterator(b);
-               res = BUNtail(bi, pos + BUNfirst(b) - b->hseqbase);
-       }
-       if (aggr == NULL) {
-               s = ATOMlen(b->ttype, res);
-               aggr = GDKmalloc(s);
-       } else {
-               s = ATOMsize(ATOMtype(b->ttype));
-       }
-       if (aggr != NULL)       /* else: malloc error */
-               memcpy(aggr, res, s);
-       if (needdecref)
-               BBPunfix(b->batCacheid);
-       return aggr;
-}
-
 /* calculate group minimums with optional candidates list
  *
  * note that this functions returns *positions* of where the minimum
  * values occur */
 static BUN
-do_groupmin(oid *restrict oids, BAT *b, const oid *restrict gids, BUN ngrp, 
oid min, oid max,
-           BUN start, BUN end, const oid *restrict cand, const oid *candend, 
BUN cnt,
-           int skip_nils, int gdense)
+do_groupmin(oid *restrict oids, BAT *b, const oid *restrict gids, BUN ngrp,
+           oid min, oid max, BUN start, BUN end,
+           const oid *restrict cand, const oid *candend,
+           BUN cnt, int skip_nils, int gdense)
 {
        oid gid;
        BUN i, nils;
@@ -2286,28 +2188,15 @@ do_groupmin(oid *restrict oids, BAT *b, 
        return nils;
 }
 
-BAT *
-BATgroupmin(BAT *b, BAT *g, BAT *e, BAT *s, int tp,
-           int skip_nils, int abort_on_error)
-{
-       return BATgroupminmax(b, g, e, s, tp, skip_nils, abort_on_error,
-                             do_groupmin, "BATgroupmin");
-}
-
-void *
-BATmin(BAT *b, void *aggr)
-{
-       return BATminmax(b, aggr, do_groupmin);
-}
-
 /* calculate group maximums with optional candidates list
  *
  * note that this functions returns *positions* of where the maximum
  * values occur */
 static BUN
-do_groupmax(oid *restrict oids, BAT *b, const oid *restrict gids, BUN ngrp, 
oid min, oid max,
-           BUN start, BUN end, const oid *restrict cand, const oid *candend, 
BUN cnt,
-           int skip_nils, int gdense)
+do_groupmax(oid *restrict oids, BAT *b, const oid *restrict gids, BUN ngrp,
+           oid min, oid max, BUN start, BUN end,
+           const oid *restrict cand, const oid *candend,
+           BUN cnt, int skip_nils, int gdense)
 {
        oid gid;
        BUN i, nils;
@@ -2429,6 +2318,147 @@ do_groupmax(oid *restrict oids, BAT *b, 
        return nils;
 }
 
+static BAT *
+BATgroupminmax(BAT *b, BAT *g, BAT *e, BAT *s, int tp, int skip_nils,
+              int abort_on_error, 
+              BUN (*minmax)(oid *restrict, BAT *, const oid *restrict, BUN,
+                            oid, oid, BUN, BUN, const oid *restrict,
+                            const oid *, BUN, int, int),
+              const char *name)
+{
+       const oid *restrict gids;
+       oid min, max;
+       BUN ngrp;
+       oid *restrict oids;
+       BAT *bn = NULL;
+       BUN nils;
+       BUN start, end, cnt;
+       const oid *cand = NULL, *candend = NULL;
+       const char *err;
+
+       assert(tp == TYPE_oid);
+       (void) tp;              /* compatibility (with other BATgroup* */
+       (void) abort_on_error;  /* functions) argument */
+
+       if (!ATOMlinear(b->ttype)) {
+               GDKerror("%s: cannot determine minimum on "
+                        "non-linear type %s\n", name, ATOMname(b->ttype));
+               return NULL;
+       }
+
+       if ((err = BATgroupaggrinit(b, g, e, s, &min, &max, &ngrp, &start, &end,
+                                   &cnt, &cand, &candend)) != NULL) {
+               GDKerror("%s: %s\n", name, err);
+               return NULL;
+       }
+
+       if (BATcount(b) == 0 || ngrp == 0) {
+               /* trivial: no minimums, so return bat aligned with g
+                * with nil in the tail */
+               bn = BATconstant(TYPE_oid, &oid_nil, ngrp, TRANSIENT);
+               BATseqbase(bn, ngrp == 0 ? 0 : min);
+               return bn;
+       }
+
+       bn = BATnew(TYPE_void, TYPE_oid, ngrp, TRANSIENT);
+       if (bn == NULL)
+               return NULL;
+       oids = (oid *) Tloc(bn, BUNfirst(bn));
+
+       if (g == NULL || BATtdense(g))
+               gids = NULL;
+       else
+               gids = (const oid *) Tloc(g, BUNfirst(g) + start);
+
+       nils = (*minmax)(oids, b, gids, ngrp, min, max, start, end,
+                        cand, candend, cnt, skip_nils, g && BATtdense(g));
+
+       BATsetcount(bn, ngrp);
+
+       BATseqbase(bn, min);
+       bn->tkey = BATcount(bn) <= 1;
+       bn->tsorted = BATcount(bn) <= 1;
+       bn->trevsorted = BATcount(bn) <= 1;
+       bn->T->nil = nils != 0;
+       bn->T->nonil = nils == 0;
+       return bn;
+}
+
+static void *
+BATminmax(BAT *b, void *aggr,
+         BUN (*minmax)(oid *restrict, BAT *, const oid *restrict, BUN,
+                       oid, oid, BUN, BUN, const oid *restrict,
+                       const oid *, BUN, int, int))
+{
+       oid pos;
+       void *res;
+       int s;
+       int needdecref = 0;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to