Changeset: 7b1e29ae11c7 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7b1e29ae11c7
Modified Files:
        gdk/gdk_aggr.c
Branch: Jul2017
Log Message:

Since we now store the max group ID, use it for aggregates.


diffs (80 lines):

diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -84,38 +84,46 @@ BATgroupaggrinit(BAT *b, BAT *g, BAT *e,
                ngrp = 1;
        } else if (e == NULL) {
                /* we need to find out the min and max of g */
-               min = oid_nil;  /* note that oid_nil > 0! (unsigned) */
-               max = 0;
-               if (BATtdense(g)) {
-                       min = g->tseqbase;
-                       max = g->tseqbase + BATcount(g) - 1;
-               } else if (g->tsorted) {
-                       gids = (const oid *) Tloc(g, 0);
-                       /* find first non-nil */
-                       for (i = 0, ngrp = BATcount(g); i < ngrp; i++, gids++) {
-                               if (*gids != oid_nil) {
-                                       min = *gids;
-                                       break;
+               PROPrec *prop;
+
+               prop = BATgetprop(g, GDK_MAX_VALUE);
+               if (prop) {
+                       min = 0; /* just assume it starts at 0 */
+                       max = prop->v.val.oval;
+               } else {
+                       min = oid_nil;  /* note that oid_nil > 0! (unsigned) */
+                       max = 0;
+                       if (BATtdense(g)) {
+                               min = g->tseqbase;
+                               max = g->tseqbase + BATcount(g) - 1;
+                       } else if (g->tsorted) {
+                               gids = (const oid *) Tloc(g, 0);
+                               /* find first non-nil */
+                               for (i = 0, ngrp = BATcount(g); i < ngrp; i++, 
gids++) {
+                                       if (*gids != oid_nil) {
+                                               min = *gids;
+                                               break;
+                                       }
                                }
+                               if (min != oid_nil) {
+                                       /* found a non-nil, max must be last
+                                        * value (and there is one!) */
+                                       max = * (const oid *) Tloc(g, 
BUNlast(g) - 1);
+                               }
+                       } else {
+                               /* we'll do a complete scan */
+                               gids = (const oid *) Tloc(g, 0);
+                               for (i = 0, ngrp = BATcount(g); i < ngrp; i++, 
gids++) {
+                                       if (*gids != oid_nil) {
+                                               if (*gids < min)
+                                                       min = *gids;
+                                               if (*gids > max)
+                                                       max = *gids;
+                                       }
+                               }
+                               /* note: max < min is possible if all groups
+                                * are nil (or BATcount(g)==0) */
                        }
-                       if (min != oid_nil) {
-                               /* found a non-nil, max must be last
-                                * value (and there is one!) */
-                               max = * (const oid *) Tloc(g, BUNlast(g) - 1);
-                       }
-               } else {
-                       /* we'll do a complete scan */
-                       gids = (const oid *) Tloc(g, 0);
-                       for (i = 0, ngrp = BATcount(g); i < ngrp; i++, gids++) {
-                               if (*gids != oid_nil) {
-                                       if (*gids < min)
-                                               min = *gids;
-                                       if (*gids > max)
-                                               max = *gids;
-                               }
-                       }
-                       /* note: max < min is possible if all groups
-                        * are nil (or BATcount(g)==0) */
                }
                ngrp = max < min ? 0 : max - min + 1;
        } else {
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to