Actually now that I see it again, it is ok. Only if we ever change the headers of imprints again, there might be a problem but easy to identify. 

On Thu, Jan 22, 2015 at 2:33 PM, Lefteris <lsidir@gmail.com> wrote:
Imprints code contains such a search for min/max, maybe we could expose it as a function and thus avoid having the same code twice (for the usual reasons of easy maintenance  and bugfix)

On Thu, Jan 22, 2015 at 2:15 PM, Sjoerd Mullender <commits@monetdb.org> wrote:
Changeset: 69a4f7d2fd58 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=69a4f7d2fd58
Modified Files:
        gdk/gdk_aggr.c
Branch: Oct2014
Log Message:

Use imprints to calculate min/max of bat.
But with limitations: no grouped min/max, and only on the complete bat
(i.e. if view, it's a view on the complete bat).


diffs (37 lines):

diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -2207,8 +2207,31 @@ BATminmax(BAT *b, void *aggr,
                        return NULL;
                needdecref = 1;
        }
-       (void) (*minmax)(&pos, b, NULL, 1, 0, 0, 0, BATcount(b),
-                        NULL, NULL, BATcount(b), 1, 0);
+       if (b->T->imprints &&
+           (VIEWtparent(b) == 0 ||
+            BATcount(b) == BATcount(BBPdescriptor(VIEWtparent(b))))) {
+               pos = oid_nil;
+               if (minmax == do_groupmin) {
+                       /* find first non-empty bin */
+                       for (s = 0; s < b->T->imprints->bits; s++) {
+                               if (b->T->imprints->stats[s + 128]) {
+                                       pos = b->T->imprints->stats[s] + b->hseqbase;
+                                       break;
+                               }
+                       }
+               } else {
+                       /* find last non-empty bin */
+                       for (s = b->T->imprints->bits - 1; s >= 0; s--) {
+                               if (b->T->imprints->stats[s + 128]) {
+                                       pos = b->T->imprints->stats[s + 64] + b->hseqbase;
+                                       break;
+                               }
+                       }
+               }
+       } else {
+               (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 {
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list