Changeset: d0c8200da692 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d0c8200da692 Modified Files: clients/mapiclient/mclient.c clients/mapilib/mapi.c clients/mapilib/mapi.h gdk/gdk.h gdk/gdk_bat.c gdk/gdk_batop.c gdk/gdk_bbp.c gdk/gdk_group.c gdk/gdk_hash.c gdk/gdk_hash.h gdk/gdk_heap.c gdk/gdk_imprints.c gdk/gdk_private.h gdk/gdk_unique.c monetdb5/mal/mal_resource.h monetdb5/modules/kernel/status.c monetdb5/optimizer/opt_support.c sql/backends/monet5/sql.c sql/backends/monet5/sql_result.c sql/backends/monet5/sql_result.h Branch: jitudf Log Message:
Merge with default. diffs (truncated from 1311 to 300 lines): diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c --- a/clients/mapiclient/mclient.c +++ b/clients/mapiclient/mclient.c @@ -1301,11 +1301,11 @@ RAWrenderer(MapiHdl hdl) } static void -TIMERrenderer(MapiHdl hdl, int64_t querytime) +TIMERrenderer(MapiHdl hdl, int64_t querytime, int64_t maloptimizertime) { SQLqueryEcho(hdl); mapi_next_result(hdl); - printf("%" PRId64 " %s\n", querytime, timerHuman()); + printf("%s sql:0 opt:%" PRId64 " run:%" PRId64 "\n", timerHuman(), maloptimizertime, querytime); } @@ -1827,6 +1827,7 @@ format_result(Mapi mid, MapiHdl hdl, cha int64_t aff, lid; char *reply; int64_t querytime; + int64_t maloptimizer; #ifdef HAVE_POPEN stream *saveFD; @@ -1860,12 +1861,13 @@ format_result(Mapi mid, MapiHdl hdl, cha continue; case Q_UPDATE: querytime = mapi_get_querytime(hdl); + maloptimizer = mapi_get_maloptimizertime(hdl); SQLqueryEcho(hdl); if (formatter == RAWformatter || formatter == TESTformatter) mnstr_printf(toConsole, "[ %" PRId64 "\t]\n", mapi_rows_affected(hdl)); else if (formatter == TIMERformatter) - printf("%" PRId64 " %s\n", querytime, timerHuman()); + TIMERrenderer(hdl, querytime, maloptimizer); else { aff = mapi_rows_affected(hdl); lid = mapi_get_last_id(hdl); @@ -1887,6 +1889,7 @@ format_result(Mapi mid, MapiHdl hdl, cha continue; case Q_SCHEMA: querytime = mapi_get_querytime(hdl); + maloptimizer = mapi_get_maloptimizertime(hdl); SQLqueryEcho(hdl); if (formatter == TABLEformatter) { mnstr_printf(toConsole, "operation successful"); @@ -1895,7 +1898,7 @@ format_result(Mapi mid, MapiHdl hdl, cha timerHuman()); mnstr_printf(toConsole, "\n"); } else if (formatter == TIMERformatter) - printf("%" PRId64 " %s\n", querytime, timerHuman()); + TIMERrenderer(hdl, querytime, maloptimizer); continue; case Q_TRANS: SQLqueryEcho(hdl); @@ -1914,6 +1917,7 @@ format_result(Mapi mid, MapiHdl hdl, cha break; case Q_TABLE: querytime = mapi_get_querytime(hdl); + maloptimizer = mapi_get_maloptimizertime(hdl); break; default: if (formatter == TABLEformatter && specials != DEBUGmodifier) { @@ -1974,7 +1978,7 @@ format_result(Mapi mid, MapiHdl hdl, cha } break; case TIMERformatter: - TIMERrenderer(hdl, querytime); + TIMERrenderer(hdl, querytime, maloptimizer); break; case SAMformatter: SAMrenderer(hdl); diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -885,6 +885,7 @@ struct MapiResultSet { int64_t row_count; int64_t last_id; int64_t querytime; + int64_t maloptimizertime; int fieldcnt; int maxfields; char *errorstr; /* error from server */ @@ -1450,6 +1451,7 @@ new_result(MapiHdl hdl) result->querytype = -1; result->errorstr = NULL; result->querytime = 0; + result->maloptimizertime = 0; memset(result->sqlstate, 0, sizeof(result->sqlstate)); result->tuple_count = 0; @@ -3759,6 +3761,7 @@ parse_header_line(MapiHdl hdl, char *lin result->querytype = qt; result->commentonly = 0; result->querytime = 0; + result->maloptimizertime = 0; nline++; /* skip space */ switch (qt) { @@ -3776,13 +3779,16 @@ parse_header_line(MapiHdl hdl, char *lin result->last_id = strtoll(nline, &nline, 10); queryid = strtoll(nline, &nline, 10); result->querytime = strtoll(nline, &nline, 10); + result->maloptimizertime = strtoll(nline, &nline, 10); break; case Q_TABLE: - if (sscanf(nline, "%d %" SCNd64 " %d %" SCNd64 " %" SCNu64 " %" SCNd64, + if (sscanf(nline, "%d %" SCNd64 " %d %" SCNd64 " %" SCNu64 " %" SCNd64 " %" SCNd64, &result->tableid, &result->row_count, &result->fieldcnt, &result->tuple_count, - &queryid, &result->querytime) < 6) - result->querytime = 0; + &queryid, &result->querytime, &result->maloptimizertime) < 7){ + result->querytime = 0; + result->maloptimizertime = 0; + } (void) queryid; /* ignored for now */ break; case Q_PREPARE: @@ -5311,6 +5317,17 @@ mapi_get_querytime(MapiHdl hdl) return result->querytime; } +int64_t +mapi_get_maloptimizertime(MapiHdl hdl) +{ + struct MapiResultSet *result; + + mapi_hdl_check(hdl, "mapi_get_maloptimizertime"); + if ((result = hdl->result) == NULL) + return 0; + return result->maloptimizertime; +} + char * mapi_get_dbname(Mapi mid) { diff --git a/clients/mapilib/mapi.h b/clients/mapilib/mapi.h --- a/clients/mapilib/mapi.h +++ b/clients/mapilib/mapi.h @@ -191,6 +191,7 @@ mapi_export int64_t mapi_get_row_count(M mapi_export int64_t mapi_get_last_id(MapiHdl hdl); mapi_export int64_t mapi_rows_affected(MapiHdl hdl); mapi_export int64_t mapi_get_querytime(MapiHdl hdl); +mapi_export int64_t mapi_get_maloptimizertime(MapiHdl hdl); mapi_export char *mapi_fetch_field(MapiHdl hdl, int fnr); mapi_export size_t mapi_fetch_field_len(MapiHdl hdl, int fnr); diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -625,7 +625,7 @@ typedef struct { BUN mask; /* number of hash buckets-1 (power of 2) */ void *Hash; /* hash table */ void *Link; /* collision list */ - Heap *heap; /* heap where the hash is stored */ + Heap heap; /* heap where the hash is stored */ } Hash; typedef struct Imprints Imprints; diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -1145,6 +1145,8 @@ BUNinplace(BAT *b, BUN p, const void *t, HASHdestroy(b); PROPdestroy(b->tprops); b->tprops = NULL; + OIDXdestroy(b); + IMPSdestroy(b); Treplacevalue(b, BUNtloc(bi, p), t); tt = b->ttype; @@ -1408,7 +1410,7 @@ BATvmsize(BAT *b, int dirty) if (b->batDirty || (b->batPersistence != TRANSIENT && !b->batCopiedtodisk)) dirty = 0; return (!dirty || b->theap.dirty ? HEAPvmsize(&b->theap) : 0) + - ((!dirty || b->theap.dirty) && b->thash && b->thash != (Hash *) 1 ? HEAPvmsize(b->thash->heap) : 0) + + ((!dirty || b->theap.dirty) && b->thash && b->thash != (Hash *) 1 ? HEAPvmsize(&b->thash->heap) : 0) + (b->tvheap && (!dirty || b->tvheap->dirty) ? HEAPvmsize(b->tvheap) : 0); } @@ -1421,7 +1423,7 @@ BATmemsize(BAT *b, int dirty) dirty = 0; return (!dirty || b->batDirtydesc ? sizeof(BAT) : 0) + (!dirty || b->theap.dirty ? HEAPmemsize(&b->theap) : 0) + - ((!dirty || b->theap.dirty) && b->thash && b->thash != (Hash *) 1 ? HEAPmemsize(b->thash->heap) : 0) + + ((!dirty || b->theap.dirty) && b->thash && b->thash != (Hash *) 1 ? HEAPmemsize(&b->thash->heap) : 0) + (b->tvheap && (!dirty || b->tvheap->dirty) ? HEAPmemsize(b->tvheap) : 0); } @@ -2167,17 +2169,16 @@ BATassertProps(BAT *b) /* we need to check for uniqueness the hard * way (i.e. using a hash table) */ const char *nme = BBP_physical(b->batCacheid); - Heap *hp; Hash *hs = NULL; BUN mask; - if ((hp = GDKzalloc(sizeof(Heap))) == NULL) { + if ((hs = GDKzalloc(sizeof(Hash))) == NULL) { fprintf(stderr, "#BATassertProps: cannot allocate " "hash table\n"); goto abort_check; } - snprintf(hp->filename, sizeof(hp->filename), + snprintf(hs->heap.filename, sizeof(hs->heap.filename), "%s.hash%d", nme, THRgettid()); if (ATOMsize(b->ttype) == 1) mask = (BUN) 1 << 8; @@ -2185,11 +2186,11 @@ BATassertProps(BAT *b) mask = (BUN) 1 << 16; else mask = HASHmask(b->batCount); - if ((hp->farmid = BBPselectfarm(TRANSIENT, b->ttype, + if ((hs->heap.farmid = BBPselectfarm(TRANSIENT, b->ttype, hashheap)) < 0 || - (hs = HASHnew(hp, b->ttype, BUNlast(b), - mask, BUN_NONE)) == NULL) { - GDKfree(hp); + HASHnew(hs, b->ttype, BUNlast(b), + mask, BUN_NONE) != GDK_SUCCEED) { + GDKfree(hs); fprintf(stderr, "#BATassertProps: cannot allocate " "hash table\n"); @@ -2212,8 +2213,7 @@ BATassertProps(BAT *b) if (cmp == 0) seennil = 1; } - HEAPfree(hp, 1); - GDKfree(hp); + HEAPfree(&hs->heap, 1); GDKfree(hs); } abort_check: diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -1100,7 +1100,6 @@ BATkeyed(BAT *b) const char *nme; BUN prb; BUN mask; - Heap *hp = NULL; GDKclrerr(); /* not interested in BAThash errors */ nme = BBP_physical(b->batCacheid); @@ -1115,13 +1114,11 @@ BATkeyed(BAT *b) if (mask < ((BUN) 1 << 16)) mask = (BUN) 1 << 16; } - if ((hp = GDKzalloc(sizeof(Heap))) == NULL || - snprintf(hp->filename, sizeof(hp->filename), + if ((hs = GDKzalloc(sizeof(Hash))) == NULL || + snprintf(hs->heap.filename, sizeof(hs->heap.filename), "%s.hash%d", nme, THRgettid()) < 0 || - (hs = HASHnew(hp, b->ttype, BUNlast(b), mask, BUN_NONE)) == NULL) { - if (hp) { - GDKfree(hp); - } + HASHnew(hs, b->ttype, BUNlast(b), mask, BUN_NONE) != GDK_SUCCEED) { + GDKfree(hs); /* err on the side of caution: not keyed */ goto doreturn; } @@ -1144,8 +1141,7 @@ BATkeyed(BAT *b) HASHput(hs, prb, p); } doreturn_free: - HEAPfree(hp, 1); - GDKfree(hp); + HEAPfree(&hs->heap, 1); GDKfree(hs); if (p == q) { /* we completed the complete scan: no @@ -1437,7 +1433,7 @@ BATsort(BAT **sorted, BAT **order, BAT * } else { pb = b; } - if (g == NULL && groups == NULL && o == NULL && !reverse && + if (g == NULL && o == NULL && !reverse && pb != NULL && BATcheckorderidx(pb) && /* if we want a stable sort, the order index must be * stable, if we don't want stable, we don't care */ @@ -1453,12 +1449,28 @@ BATsort(BAT **sorted, BAT **order, BAT * on->tnonil = 1; on->tsorted = on->trevsorted = 0; on->tdense = 0; - if (sorted) { + if (sorted || groups) { bn = BATproject(on, b); if (bn == NULL) goto error; bn->tsorted = 1; - *sorted = bn; + if (groups) { + if (BATgroup_internal(groups, NULL, NULL, bn, NULL, g, NULL, NULL, 1) != GDK_SUCCEED) + goto error; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list