Changeset: 375a5c8f3592 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=375a5c8f3592 Modified Files: gdk/gdk_aggr.c gdk/gdk_bbp.c gdk/gdk_utils.c Branch: default Log Message:
Merge with Jul2017 branch. diffs (174 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 { diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -1594,7 +1594,7 @@ vheap_entry(FILE *fp, Heap *h) } static gdk_return -new_bbpentry(FILE *fp, bat i) +new_bbpentry(FILE *fp, bat i, const char *prefix) { #ifndef NDEBUG assert(i > 0); @@ -1610,8 +1610,9 @@ new_bbpentry(FILE *fp, bat i) } #endif - if (fprintf(fp, SSZFMT " %d %s %s %d " BUNFMT " " - BUNFMT " " OIDFMT, /* BAT info */ + if (fprintf(fp, "%s" SSZFMT " %d %s %s %d " BUNFMT " " + BUNFMT " " OIDFMT, prefix, + /* BAT info */ (ssize_t) i, BBP_status(i) & BBPPERSISTENT, BBP_logical(i), @@ -1709,10 +1710,10 @@ BBPdir_subcommit(int cnt, bat *subcommit bat i = subcommit[j]; /* BBP.dir consists of all persistent bats only */ if (BBP_status(i) & BBPPERSISTENT) { - if (new_bbpentry(nbbpf, i) != GDK_SUCCEED) { + if (new_bbpentry(nbbpf, i, "") != GDK_SUCCEED) { goto bailout; } - IODEBUG new_bbpentry(stderr, i); + IODEBUG new_bbpentry(stderr, i, "#"); } if (i == n) n = 0; /* read new entry (i.e. skip this one from old BBP.dir */ @@ -1725,7 +1726,7 @@ BBPdir_subcommit(int cnt, bat *subcommit GDKsyserror("BBPdir_subcommit: Copying BBP.dir entry failed\n"); goto bailout; } - IODEBUG fprintf(stderr, "%s", buf); + IODEBUG fprintf(stderr, "#%s", buf); n = 0; } } @@ -1787,10 +1788,10 @@ BBPdir(int cnt, bat *subcommit) /* write the entry * BBP.dir consists of all persistent bats */ if (BBP_status(i) & BBPPERSISTENT) { - if (new_bbpentry(fp, i) != GDK_SUCCEED) { + if (new_bbpentry(fp, i, "") != GDK_SUCCEED) { goto bailout; } - IODEBUG new_bbpentry(stderr, i); + IODEBUG new_bbpentry(stderr, i, "#"); } } @@ -3603,7 +3604,7 @@ BBPrecover_subdir(void) if (ret == GDK_SUCCEED) { ret = GDKremovedir(0, SUBDIR); if (backup_dir == 2) { - IODEBUG fprintf(stderr, "BBPrecover_subdir: %s%cBBP.dir had disappeared!", SUBDIR, DIR_SEP); + IODEBUG fprintf(stderr, "#BBPrecover_subdir: %s%cBBP.dir had disappeared!", SUBDIR, DIR_SEP); backup_dir = 0; } } diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c --- a/gdk/gdk_utils.c +++ b/gdk/gdk_utils.c @@ -1579,6 +1579,10 @@ GDKmalloc_internal(size_t size) return NULL; } #endif + if (GDKvm_cursize() + size >= GDK_vm_maxsize) { + GDKerror("allocating too much memory\n"); + return NULL; + } /* pad to multiple of eight bytes and add some extra space to * write real size in front; when debugging, also allocate @@ -1716,6 +1720,11 @@ GDKrealloc(void *s, size_t size) nsize = (size + 7) & ~7; asize = ((size_t *) s)[-1]; /* how much allocated last */ + if (nsize > asize && + GDKvm_cursize() + nsize - asize >= GDK_vm_maxsize) { + GDKerror("allocating too much memory\n"); + return NULL; + } #ifndef NDEBUG assert((asize & 2) == 0); /* check against duplicate free */ /* check for out-of-bounds writes */ _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list