MonetDB: monetdbe-proxy - Get a plain old BAT pushed as a MAL in...
Changeset: 98602eaebcf7 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=98602eaebcf7 Modified Files: tools/monetdbe/monetdbe.c Branch: monetdbe-proxy Log Message: Get a plain old BAT pushed as a MAL instruction argument. diffs (34 lines): diff --git a/tools/monetdbe/monetdbe.c b/tools/monetdbe/monetdbe.c --- a/tools/monetdbe/monetdbe.c +++ b/tools/monetdbe/monetdbe.c @@ -1710,7 +1710,7 @@ monetdbe_append(monetdbe_database dbhdl, // TODO handle error } - int idx = newVariable(mb, NULL, 0, newBatType(tpe->localtype)); + int idx = newTmpVariable(mb, newBatType(tpe->localtype)); f = pushArgument(mb, f, idx); InstrPtr a = newInstruction(mb, sqlRef, appendRef); @@ -1929,13 +1929,18 @@ monetdbe_append(monetdbe_database dbhdl, if (b == NULL) { // TODO: handle error } - ValRecord v = { .len=0 }; - VALset(&v, TYPE_bat, &b->batCacheid); + + int idx = newTmpVariable(mb, newBatType(c->type.type->localtype)); + ValRecord v = { .vtype = TYPE_bat, .len = ATOMlen(TYPE_bat, &b->batCacheid), .val.bval = b->batCacheid}; + // TODO: check gdk_value.h functions. They don't seem to handle TYPE_bat that well e.g. VALset. + getVarConstant(mb, idx) = v; + setVarConstant(mb, idx); InstrPtr p = newFcnCall(mb, remoteRef, putRef); + ; setArgType(mb, p, 0, TYPE_str); p = pushStr(mb, p, mdbe->mid); - p = pushValue(mb, p, &v); + p = pushArgument(mb, p, idx); e = pushArgument(mb, e, getArg(p, 0)); } ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: window-tunning - More bugfixes but more needed
Changeset: ab9aaaf96534 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ab9aaaf96534 Modified Files: gdk/gdk_analytic_bounds.c gdk/gdk_analytic_func.c sql/server/rel_select.c sql/server/sql_atom.c sql/server/sql_atom.h Branch: window-tunning Log Message: More bugfixes but more needed diffs (truncated from 949 to 300 lines): diff --git a/gdk/gdk_analytic_bounds.c b/gdk/gdk_analytic_bounds.c --- a/gdk/gdk_analytic_bounds.c +++ b/gdk/gdk_analytic_bounds.c @@ -164,12 +164,9 @@ GDKanalyticaldiff(BAT *r, BAT *b, BAT *p if (np[i]) \ ANALYTICAL_WINDOW_BOUNDS_ROWS##IMP(LIMIT); \ } \ - i = cnt;\ - ANALYTICAL_WINDOW_BOUNDS_ROWS##IMP(LIMIT); \ - } else {\ - i = cnt;\ - ANALYTICAL_WINDOW_BOUNDS_ROWS##IMP(LIMIT); \ - } \ + } \ + i = cnt;\ + ANALYTICAL_WINDOW_BOUNDS_ROWS##IMP(LIMIT); \ } while (0) #define ANALYTICAL_WINDOW_BOUNDS_GROUPS_PRECEDING(LIMIT) \ @@ -214,12 +211,9 @@ GDKanalyticaldiff(BAT *r, BAT *b, BAT *p if (np[i]) \ ANALYTICAL_WINDOW_BOUNDS_GROUPS##IMP(LIMIT); \ } \ - i = cnt;\ - ANALYTICAL_WINDOW_BOUNDS_GROUPS##IMP(LIMIT);\ - } else {\ - i = cnt;\ - ANALYTICAL_WINDOW_BOUNDS_GROUPS##IMP(LIMIT);\ - } \ + } \ + i = cnt;\ + ANALYTICAL_WINDOW_BOUNDS_GROUPS##IMP(LIMIT);\ } while (0) #define ANALYTICAL_WINDOW_BOUNDS_FIXED_RANGE_PRECEDING(TPE1, LIMIT, TPE2) \ @@ -313,12 +307,9 @@ GDKanalyticaldiff(BAT *r, BAT *b, BAT *p if (np[i]) \ IMP(TPE1, LIMIT, TPE2); \ } \ - i = cnt;\ - IMP(TPE1, LIMIT, TPE2); \ - } else {\ - i = cnt;\ - IMP(TPE1, LIMIT, TPE2); \ - } \ + } \ + i = cnt;\ + IMP(TPE1, LIMIT, TPE2); \ } while (0) #define ANALYTICAL_WINDOW_BOUNDS_VARSIZED_RANGE_PRECEDING(LIMIT, TPE) \ @@ -424,12 +415,9 @@ GDKanalyticaldiff(BAT *r, BAT *b, BAT *p if (np[i]) \ ANALYTICAL_WINDOW_BOUNDS_VARSIZED_RANGE##IMP(LIMIT, CAST); \ } \ - i = cnt;\ - ANALYTICAL_WINDOW_BOUNDS_VARSIZED_RANGE##IMP(LIMIT, CAST); \ - } else {\ - i = cnt;\ - ANALYTICAL_WINDOW_BOUNDS_VARSIZED_RANGE##IMP(LIMIT, CAST); \ - } \ + } \ + i = cnt;\ + ANALYTICAL_WINDOW_BOUNDS_VARSIZED_RANGE##IMP(LIMIT, CAST); \ } \ } \ } while (0) @@ -486,18 +474,55 @@ GDKanalyticaldiff(BAT *r, BAT *b, BAT *p if (np[i]) \ ANALYTICAL_WINDOW_BOUNDS_VARSIZED_RANGE##IMP(LIMIT, hge); \ } \ -
MonetDB: default - Merge with Oct2020 branch.
Changeset: a8afa43ca17e for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a8afa43ca17e Modified Files: MonetDB.spec gdk/gdk_bbp.c monetdb5/mal/mal_profiler.c sql/storage/bat/bat_storage.c tools/mserver/mserver5.c Branch: default Log Message: Merge with Oct2020 branch. diffs (truncated from 413 to 300 lines): diff --git a/.editorconfig b/.editorconfig --- a/.editorconfig +++ b/.editorconfig @@ -1,3 +1,5 @@ +root = true + # Unix-style newlines with a newline ending every file [*] end_of_line = lf @@ -16,7 +18,3 @@ indent_style = space indent_size = 4 trim_trailing_whitespace = true charset = utf-8 - -[gdk/*.{c,h}] -tab_width = 8 -max_line_length = 72 diff --git a/MonetDB.spec b/MonetDB.spec --- a/MonetDB.spec +++ b/MonetDB.spec @@ -140,6 +140,13 @@ BuildRequires: pkgconfig(openssl) BuildRequires: pkgconfig(libpcre) >= 4.5 %endif BuildRequires: pkgconfig(zlib) +%if %{?rhel:0}%{!?rhel:1} || 0%{?rhel} > 7 +# not on RHEL 7 +BuildRequires: pkgconfig(liblz4) >= 1.8 +%global LZ4 ON +%else +%global LZ4 OFF +%endif %if %{with py3integration} BuildRequires: pkgconfig(python3) >= 3.5 BuildRequires: python3-numpy @@ -149,8 +156,6 @@ BuildRequires: pkgconfig(libR) %endif # if we were to compile with cmocka support (-DWITH_CMOCKA=ON): # BuildRequires: pkgconfig(cmocka) -# if we were to compile with lz4 support (-DWITH_LZ4=ON): -# BuildRequires: pkgconfig(liblz4) # if we were to compile with NetCDF support (-DNETCDF=ON): # BuildRequires: pkgconfig(netcdf) # if we were to compile with proj support (-DWITH_PROJ=ON): @@ -801,7 +806,7 @@ export CFLAGS -DWITH_CMOCKA=OFF \ -DWITH_CRYPTO=ON \ -DWITH_CURL=ON \ - -DWITH_LZ4=OFF \ + -DWITH_LZ4=%{LZ4} \ -DWITH_LZMA=ON \ -DWITH_PCRE=ON \ -DWITH_PROJ=OFF \ diff --git a/debian/control b/debian/control --- a/debian/control +++ b/debian/control @@ -7,7 +7,7 @@ Vcs-Browser: https://dev.monetdb.org/hg/ Vcs-Hg: https://dev.monetdb.org/hg/MonetDB/ Build-Depends: debhelper (>= 9), cmake (>= 3.12), bison, libbz2-dev, libcurl4-gnutls-dev, libgeos-dev (>= 3.4.0), - libpcre3-dev, libreadline-dev, liblzma-dev, + libpcre3-dev, libreadline-dev, liblzma-dev, liblz4-dev (>= 1.8.0), libssl-dev, libxml2-dev, pkg-config, python3, python3-dev, python3-numpy, unixodbc-dev, uuid-dev, zlib1g-dev, r-base-dev, diff --git a/debian/rules b/debian/rules --- a/debian/rules +++ b/debian/rules @@ -31,7 +31,7 @@ override_dh_auto_configure: -DWITH_CMOCKA=OFF \ -DWITH_CRYPTO=ON \ -DWITH_CURL=ON \ - -DWITH_LZ4=OFF \ + -DWITH_LZ4=ON \ -DWITH_LZMA=ON \ -DWITH_PCRE=ON \ -DWITH_PROJ=OFF \ diff --git a/gdk/.editorconfig b/gdk/.editorconfig new file mode 100644 --- /dev/null +++ b/gdk/.editorconfig @@ -0,0 +1,3 @@ +[*.{c,h}] +tab_width = 8 +max_line_length = 72 diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -3624,6 +3624,10 @@ BBPdiskscan(const char *parent, size_t b /* older versions used .thash which we * can simply ignore */ delete = true; + } else if (strncmp(p + 1, "thsh", 4) == 0) { + /* temporary hash files which we can +* simply ignore */ + delete = true; } else if (strncmp(p + 1, "timprints", 9) == 0) { BAT *b = getdesc(bid); delete = b == NULL; diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c --- a/monetdb5/mal/mal_profiler.c +++ b/monetdb5/mal/mal_profiler.c @@ -60,17 +60,51 @@ static struct rusage prevUsage; #define LOGLEN 8192 #define lognew() loglen = 0; logbase = logbuffer; *logbase = 0; +/* + * We use a buffer (`logbuffer`) where we incrementally create the output JSON object. Initially we allocate LOGLEN (8K) + * bytes and we keep the capacity of the buffer (`logcap`) and the length of the current string (`loglen`). + * + * We use the `logadd` macro to add data to our buffer (usually key-value pairs). This macro offers an interface similar + * to printf. + * + * The first snprintf bellow happens in a statically allocated buffer that might be much smaller than logcap. We do not + * care. We only need to perform this snprintf to get the actual length of the string that is to be produced. + * + * There are three cases: + * + * 1. The new string fits in the current buffer -> we just update the buffer + * + * 2. The new string does not fit in the current buffer, but is smaller than the capacity of the buffer -> we output the + * current contents of the buffer and start at the beginnig. + * + * 3. The new string exceeds the current capacity of the buffer -> we output the current contents and reallocate the + * buffer. The new capacity is 1.5
MonetDB: monetdbe-proxy - Work in progress: proxified monetdbe_a...
Changeset: e2aa9541880b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e2aa9541880b Modified Files: ctest/tools/monetdbe/example_proxy.c design.txt monetdb5/modules/mal/remote.c tools/monetdbe/monetdbe.c Branch: monetdbe-proxy Log Message: Work in progress: proxified monetdbe_append compiles. diffs (truncated from 383 to 300 lines): diff --git a/ctest/tools/monetdbe/example_proxy.c b/ctest/tools/monetdbe/example_proxy.c --- a/ctest/tools/monetdbe/example_proxy.c +++ b/ctest/tools/monetdbe/example_proxy.c @@ -33,15 +33,18 @@ main(void) if (monetdbe_open(&mdbe, "mapi:monetdb://127.0.0.1:5?database=devdb", &opt)) error("Failed to open database") - if ((err = monetdbe_query(mdbe, "SELECT x, y, 1 AS some_int FROM test; ", &result, NULL)) != NULL) + if ((err = monetdbe_query(mdbe, "SELECT * FROM test; ", &result, NULL)) != NULL) error(err) + monetdbe_column* appendable_columns[2]; + fprintf(stdout, "Query result with %zu cols and %"PRId64" rows\n", result->ncols, result->nrows); for (int64_t r = 0; r < result->nrows; r++) { for (size_t c = 0; c < result->ncols; c++) { monetdbe_column* rcol; if ((err = monetdbe_result_fetch(result, &rcol, c)) != NULL) error(err) + appendable_columns[c] = rcol; switch (rcol->type) { case monetdbe_int8_t: { monetdbe_column_int8_t * col = (monetdbe_column_int8_t *) rcol; @@ -91,6 +94,9 @@ main(void) printf("\n"); } + if ((err = monetdbe_append(mdbe, "sys", "test", appendable_columns, 2)) != NULL) + error(err) + if ((err = monetdbe_cleanup_result(mdbe, result)) != NULL) error(err) @@ -110,6 +116,7 @@ main(void) if ((err = monetdbe_execute(stmt, &result, NULL)) != NULL) error(err) + fprintf(stdout, "Query result with %zu cols and %"PRId64" rows\n", result->ncols, result->nrows); for (int64_t r = 0; r < result->nrows; r++) { for (size_t c = 0; c < result->ncols; c++) { diff --git a/design.txt b/design.txt --- a/design.txt +++ b/design.txt @@ -80,6 +80,9 @@ function user.%temp(X1, ..., XN) sql.affectedRows(m, c); end +function user.%temp2() +remote.put() + Register this function and remotely execute it: remote.register(conn, user, %temp) remote.exec(conn, user, %temp, RB1, ..., RBN) diff --git a/monetdb5/modules/mal/remote.c b/monetdb5/modules/mal/remote.c --- a/monetdb5/modules/mal/remote.c +++ b/monetdb5/modules/mal/remote.c @@ -70,7 +70,6 @@ #ifdef HAVE_MAPI - #include "mal_exception.h" #include "mal_interpreter.h" #include "mal_function.h" /* for printFunction */ @@ -1138,7 +1137,7 @@ static str RMTput(Client cntxt, MalBlkPt * The implementation is based on serialisation of the block into a string * followed by remote parsing. */ -static str RMTregisterInternal(Client cntxt, const char *conn, const char *mod, const char *fcn) +static str RMTregisterInternal(Client cntxt, char** fcn_id, const char *conn, const char *mod, const char *fcn) { str tmp, qry, msg; connection c; @@ -1176,32 +1175,60 @@ static str RMTregisterInternal(Client cn if (mhdl) mapi_close_handle(mhdl); + /* get a free, typed identifier for the remote host */ + char ident[BUFSIZ]; + tmp = RMTgetId(ident, sym->def, getInstrPtr(sym->def, 0), 0); + if (tmp != MAL_SUCCEED) { + MT_lock_unset(&c->lock); + return tmp; + } + + *fcn_id = GDKmalloc(strlen(ident)); + if (*fcn_id == NULL) { + //TODO: handle error + } + + strcpy(*fcn_id, ident); + + Symbol prg; + + if ((prg = newFunction(putName(mod), putName(*fcn_id), FUNCTIONsymbol)) == NULL) { + // TODO: handle error + return createException(MAL, "Remote register", MAL_MALLOC_FAIL); + } + prg->def = copyMalBlk(sym->def); + // TODO: handle if == NULL + setFunctionId(getInstrPtr(prg->def, 0), putName(*fcn_id)); + /* make sure the program is error free */ - msg = chkProgram(cntxt->usermodule, sym->def); - if ( msg == MAL_SUCCEED || sym->def->errors) { + msg = chkProgram(cntxt->usermodule, prg->def); + if ( msg != MAL_SUCCEED || prg->def->errors) { MT_lock_unset(&c->lock); throw(MAL, "remote.register", "function '%s.%s' contains syntax or type errors", - mod, fcn); + mod, *fcn_id); } - qry = mal2str(sym->def, 0, sym->def->stop); + qry = mal2str(prg->def, 0, prg->def->stop);
MonetDB: Oct2020 - Use local .editorconfig and stop searching fo...
Changeset: e701fe189d72 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e701fe189d72 Added Files: gdk/.editorconfig Modified Files: .editorconfig Branch: Oct2020 Log Message: Use local .editorconfig and stop searching for more .editorconfig files. diffs (25 lines): diff --git a/.editorconfig b/.editorconfig --- a/.editorconfig +++ b/.editorconfig @@ -1,3 +1,5 @@ +root = true + # Unix-style newlines with a newline ending every file [*] end_of_line = lf @@ -16,7 +18,3 @@ indent_style = space indent_size = 4 trim_trailing_whitespace = true charset = utf-8 - -[gdk/*.{c,h}] -tab_width = 8 -max_line_length = 72 diff --git a/gdk/.editorconfig b/gdk/.editorconfig new file mode 100644 --- /dev/null +++ b/gdk/.editorconfig @@ -0,0 +1,3 @@ +[*.{c,h}] +tab_width = 8 +max_line_length = 72 ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: window-tunning - Reduced number of cases for count and ...
Changeset: 6a406bfa0027 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6a406bfa0027 Modified Files: gdk/gdk_analytic_func.c sql/backends/monet5/sql_rank.c Branch: window-tunning Log Message: Reduced number of cases for count and updated number of arguments check diffs (truncated from 405 to 300 lines): diff --git a/gdk/gdk_analytic_func.c b/gdk/gdk_analytic_func.c --- a/gdk/gdk_analytic_func.c +++ b/gdk/gdk_analytic_func.c @@ -1070,7 +1070,7 @@ ANALYTICAL_MIN_MAX(min, MIN, >) ANALYTICAL_MIN_MAX(max, MAX, <) /* Counting no nils for fixed sizes */ -#define ANALYTICAL_COUNT_NO_NIL_FIXED_UNBOUNDED_TILL_CURRENT_ROW(TPE) \ +#define ANALYTICAL_COUNT_FIXED_UNBOUNDED_TILL_CURRENT_ROW(TPE) \ do { \ curval = 0; \ if (count_all) { \ @@ -1098,7 +1098,7 @@ ANALYTICAL_MIN_MAX(max, MAX, <) } \ } while (0) -#define ANALYTICAL_COUNT_NO_NIL_FIXED_CURRENT_ROW_TILL_UNBOUNDED(TPE) \ +#define ANALYTICAL_COUNT_FIXED_CURRENT_ROW_TILL_UNBOUNDED(TPE) \ do { \ curval = 0; \ if (count_all) { \ @@ -1129,7 +1129,7 @@ ANALYTICAL_MIN_MAX(max, MAX, <) k = i; \ } while (0) -#define ANALYTICAL_COUNT_NO_NIL_FIXED_ALL_ROWS(TPE) \ +#define ANALYTICAL_COUNT_FIXED_ALL_ROWS(TPE) \ do { \ if (count_all) { \ curval = i - k; \ @@ -1144,7 +1144,7 @@ ANALYTICAL_MIN_MAX(max, MAX, <) } \ } while (0) -#define ANALYTICAL_COUNT_NO_NIL_FIXED_CURRENT_ROW(TPE) \ +#define ANALYTICAL_COUNT_FIXED_CURRENT_ROW(TPE) \ do { \ if (count_all) { \ for (; k < i; k++) \ @@ -1155,7 +1155,7 @@ ANALYTICAL_MIN_MAX(max, MAX, <) } \ } while (0) -#define ANALYTICAL_COUNT_NO_NIL_FIXED_OTHERS(TPE) \ +#define ANALYTICAL_COUNT_FIXED_OTHERS(TPE) \ do { \ if (count_all) { \ for (; k < i; k++) \ @@ -1174,240 +1174,163 @@ ANALYTICAL_MIN_MAX(max, MAX, <) } while (0) /* Counting no nils for other types */ -#define ANALYTICAL_COUNT_NO_NIL_OTHERS_UNBOUNDED_TILL_CURRENT_ROW \ +#define ANALYTICAL_COUNT_OTHERS_UNBOUNDED_TILL_CURRENT_ROW \ do { \ curval = 0; \ if (count_all) { \ - if (isvarsized) { \ - for (; k < i; ) { \ - j = k++; \ + for (; k < i; ) { \ + j = k++; \ + curval++; \ + while (k < i && !op[k]) { \ curval++; \ - while (k < i && !op[k]) { \ - curval++; \ - k++; \ - } \ - for (; j < k; j++) \ - rb[j] = curval; \ + k++; \ } \ - } else { \ - for (; k < i; ) { \ - j = k++; \ - curval++; \ - while (k < i && !op[k]) { \ - curval++; \ - k++; \ - } \ - for (; j < k; j++) \ - rb[j] = curval; \ - } \ + for (; j < k; j++) \ + rb[j] = curval; \ } \ } else { \ - if (isvarsized) { \ - for (; k < i; ) { \ - j = k++; \ - const void *v = base + ((const var_t *) bheap)[j]; \ - curval += cmp(v, nil) != 0; \ - while (k < i && !op[k]) { \ - curval += cmp(base + ((const var_t *) bheap)[k], nil) != 0; \ - k++; \ - } \ - for (; j < k; j++) \ - rb[j] = curval; \ + for (; k < i; ) { \ + j = k++; \ + const void *v = BUNtail(bpi, j); \ + curval += cmp(v, nil) != 0; \ + while (k < i && !op[k]) { \ + curval += cmp(BUNtail(bpi, k),
MonetDB: window-tunning - Pass ordering information for FRAME_UN...
Changeset: f1a38bed20d5 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f1a38bed20d5 Modified Files: gdk/gdk_analytic.h gdk/gdk_analytic_func.c sql/backends/monet5/sql.c sql/backends/monet5/sql_rank.c sql/server/rel_select.c Branch: window-tunning Log Message: Pass ordering information for FRAME_UNBOUNDED_TILL_CURRENT_ROW and FRAME_CURRENT_ROW_TILL_UNBOUNDED cases. Cleaned the rest diffs (truncated from 1404 to 300 lines): diff --git a/gdk/gdk_analytic.h b/gdk/gdk_analytic.h --- a/gdk/gdk_analytic.h +++ b/gdk/gdk_analytic.h @@ -29,13 +29,13 @@ gdk_export gdk_return GDKanalyticalfirst gdk_export gdk_return GDKanalyticallast(BAT *r, BAT *b, BAT *s, BAT *e, int tpe); gdk_export gdk_return GDKanalyticalnthvalue(BAT *r, BAT *b, BAT *s, BAT *e, BAT *l, const void *restrict bound, int tp1, int tp2); -gdk_export gdk_return GDKanalyticalmin(BAT *r, BAT *p, BAT *b, BAT *s, BAT *e, int tpe, int frame_type); -gdk_export gdk_return GDKanalyticalmax(BAT *r, BAT *p, BAT *b, BAT *s, BAT *e, int tpe, int frame_type); -gdk_export gdk_return GDKanalyticalcount(BAT *r, BAT *p, BAT *b, BAT *s, BAT *e, bit ignore_nils, int tpe, int frame_type); -gdk_export gdk_return GDKanalyticalsum(BAT *r, BAT *p, BAT *b, BAT *s, BAT *e, int tp1, int tp2, int frame_type); -gdk_export gdk_return GDKanalyticalprod(BAT *r, BAT *p, BAT *b, BAT *s, BAT *e, int tp1, int tp2, int frame_type); -gdk_export gdk_return GDKanalyticalavg(BAT *r, BAT *p, BAT *b, BAT *s, BAT *e, int tpe, int frame_type); -gdk_export gdk_return GDKanalyticalavginteger(BAT *r, BAT *p, BAT *b, BAT *s, BAT *e, int tpe, int frame_type); +gdk_export gdk_return GDKanalyticalmin(BAT *r, BAT *p, BAT *o, BAT *b, BAT *s, BAT *e, int tpe, int frame_type); +gdk_export gdk_return GDKanalyticalmax(BAT *r, BAT *p, BAT *o, BAT *b, BAT *s, BAT *e, int tpe, int frame_type); +gdk_export gdk_return GDKanalyticalcount(BAT *r, BAT *p, BAT *o, BAT *b, BAT *s, BAT *e, bit ignore_nils, int tpe, int frame_type); +gdk_export gdk_return GDKanalyticalsum(BAT *r, BAT *p, BAT *o, BAT *b, BAT *s, BAT *e, int tp1, int tp2, int frame_type); +gdk_export gdk_return GDKanalyticalprod(BAT *r, BAT *p, BAT *o, BAT *b, BAT *s, BAT *e, int tp1, int tp2, int frame_type); +gdk_export gdk_return GDKanalyticalavg(BAT *r, BAT *p, BAT *o, BAT *b, BAT *s, BAT *e, int tpe, int frame_type); +gdk_export gdk_return GDKanalyticalavginteger(BAT *r, BAT *p, BAT *o, BAT *b, BAT *s, BAT *e, int tpe, int frame_type); gdk_export gdk_return GDKanalytical_stddev_samp(BAT *r, BAT *b, BAT *s, BAT *e, int tpe); gdk_export gdk_return GDKanalytical_stddev_pop(BAT *r, BAT *b, BAT *s, BAT *e, int tpe); diff --git a/gdk/gdk_analytic_func.c b/gdk/gdk_analytic_func.c --- a/gdk/gdk_analytic_func.c +++ b/gdk/gdk_analytic_func.c @@ -790,10 +790,9 @@ GDKanalyticallead(BAT *r, BAT *b, BAT *p #define ANALYTICAL_MIN_MAX_CALC_FIXED_UNBOUNDED_TILL_CURRENT_ROW(TPE, MIN_MAX) \ do { \ for (; k < i;) { \ - TPE v = bp[k]; \ - TPE curval = v; \ j = k++; \ - while (k < i && bp[k] == v) { \ + TPE curval = bp[j]; \ + while (k < i && !op[k]) { \ if (!is_##TPE##_nil(bp[k])) { \ if (is_##TPE##_nil(curval)) \ curval = bp[k]; \ @@ -811,10 +810,9 @@ GDKanalyticallead(BAT *r, BAT *b, BAT *p #define ANALYTICAL_MIN_MAX_CALC_FIXED_CURRENT_ROW_TILL_UNBOUNDED(TPE, MIN_MAX) \ do { \ for (j = i - 1; j >= k; ) { \ - TPE v = bp[j]; \ - TPE curval = v; \ l = j--; \ - while (j >= k && bp[j] == v) { \ + TPE curval = bp[l]; \ + while (j >= k && !op[j]) { \ if (!is_##TPE##_nil(bp[j])) { \ if (is_##TPE##_nil(curval)) \ curval = bp[j]; \ @@ -883,15 +881,15 @@ GDKanalyticallead(BAT *r, BAT *b, BAT *p #define ANALYTICAL_MIN_MAX_CALC_VARSIZED_UNBOUNDED_TILL_CURRENT_ROW(GT_LT) \ do { \ for (; k < i;) { \ - void *next = BUNtail(bpi, k), *curval = next; \ j = k++; \ - while (k < i && atomcmp(BUNtail(bpi, k), next) == 0) { \ - void *nnext = BUNtail(bpi, k); \ - if (atomcmp(nnext, nil) != 0) { \ + void *curval = BUNtail(bpi, j); \ + while (k < i && !op[k]) { \ + void *next = BUNtail(bpi, k); \ + if (atomcmp(next, nil) != 0) { \
MonetDB: Oct2020 - Merge with Jun2020 branch.
Changeset: 60843e29a4ed for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=60843e29a4ed Modified Files: tools/mserver/mserver5.c Branch: Oct2020 Log Message: Merge with Jun2020 branch. diffs (19 lines): diff --git a/tools/mserver/mserver5.c b/tools/mserver/mserver5.c --- a/tools/mserver/mserver5.c +++ b/tools/mserver/mserver5.c @@ -487,7 +487,6 @@ main(int argc, char **av) if (!(setlen = mo_system_config(&set, setlen))) usage(prog, -1); - GDKsetdebug(debug | grpdebug); /* add the algorithm tracers */ if (debug) mo_print_options(set, setlen); @@ -541,6 +540,7 @@ main(int argc, char **av) fprintf(stderr, "%s\n", GDKerrbuf); exit(1); } + GDKsetdebug(debug | grpdebug); /* add the algorithm tracers */ mo_free_options(set, setlen); if (GDKsetenv("monet_version", GDKversion()) != GDK_SUCCEED || ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: Jun2020 - Wait until GDKenv is initialized before setti...
Changeset: b077e864c5ce for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b077e864c5ce Modified Files: tools/mserver/mserver5.c Branch: Jun2020 Log Message: Wait until GDKenv is initialized before setting tracer options. diffs (19 lines): diff --git a/tools/mserver/mserver5.c b/tools/mserver/mserver5.c --- a/tools/mserver/mserver5.c +++ b/tools/mserver/mserver5.c @@ -480,7 +480,6 @@ main(int argc, char **av) if (!(setlen = mo_system_config(&set, setlen))) usage(prog, -1); - GDKsetdebug(debug | grpdebug); /* add the algorithm tracers */ if (debug) mo_print_options(set, setlen); @@ -529,6 +528,7 @@ main(int argc, char **av) fprintf(stderr, "%s\n", GDKerrbuf); exit(1); } + GDKsetdebug(debug | grpdebug); /* add the algorithm tracers */ mo_free_options(set, setlen); if (GDKsetenv("monet_version", GDKversion()) != GDK_SUCCEED || ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: window-tunning - More cleanup, this is still not right
Changeset: 335b42ba9584 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=335b42ba9584 Modified Files: gdk/gdk_analytic_func.c Branch: window-tunning Log Message: More cleanup, this is still not right diffs (truncated from 884 to 300 lines): diff --git a/gdk/gdk_analytic_func.c b/gdk/gdk_analytic_func.c --- a/gdk/gdk_analytic_func.c +++ b/gdk/gdk_analytic_func.c @@ -11,10 +11,6 @@ #include "gdk_analytic.h" #include "gdk_calc_private.h" -/* needed for some operators on floating-points */ -#define NAN_CHECK(TPE, i) || (is_##TPE##_nil(v) && is_##TPE##_nil(bp[i])) -#define NO_NAN_CHECK(TPE, i) - #define NTILE_CALC(TPE, NEXT_VALUE, LNG_HGE, UPCAST) \ do {\ for (TPE i = 0; rb < rp; i++, rb++) { \ @@ -791,20 +787,20 @@ GDKanalyticallead(BAT *r, BAT *b, BAT *p return GDK_SUCCEED; } -#define ANALYTICAL_MIN_MAX_CALC_FIXED_UNBOUNDED_TILL_CURRENT_ROW(TPE, NAN_CHECK, MIN_MAX) \ +#define ANALYTICAL_MIN_MAX_CALC_FIXED_UNBOUNDED_TILL_CURRENT_ROW(TPE, MIN_MAX) \ do { \ for (; k < i;) { \ TPE v = bp[k]; \ TPE curval = v; \ j = k++; \ - while (k < i && (bp[k] == v NAN_CHECK(TPE, k))) { \ - k++; \ + while (k < i && bp[k] == v) { \ if (!is_##TPE##_nil(bp[k])) { \ if (is_##TPE##_nil(curval)) \ curval = bp[k]; \ else\ curval = MIN_MAX(bp[k], curval); \ } \ + k++; \ } \ for (; j < k; j++) \ rb[j] = curval; \ @@ -812,20 +808,20 @@ GDKanalyticallead(BAT *r, BAT *b, BAT *p } \ } while (0) -#define ANALYTICAL_MIN_MAX_CALC_FIXED_CURRENT_ROW_TILL_UNBOUNDED(TPE, NAN_CHECK, MIN_MAX) \ +#define ANALYTICAL_MIN_MAX_CALC_FIXED_CURRENT_ROW_TILL_UNBOUNDED(TPE, MIN_MAX) \ do { \ for (j = i - 1; j >= k; ) { \ TPE v = bp[j]; \ TPE curval = v; \ l = j--; \ - while (j >= k && (bp[j] == v NAN_CHECK(TPE, j))) { \ - j--; \ + while (j >= k && bp[j] == v) { \ if (!is_##TPE##_nil(bp[j])) { \ if (is_##TPE##_nil(curval)) \ curval = bp[j]; \ else\ curval = MIN_MAX(bp[j], curval); \ } \ + j--; \ } \ m = MAX(k, j); \ for (; l >= m; l--) \ @@ -835,7 +831,7 @@ GDKanalyticallead(BAT *r, BAT *b, BAT *p k = i; \ } while (0) -#define ANALYTICAL_MIN_MAX_CALC_FIXED_ALL_ROWS(TPE, NAN_CHECK, MIN_MAX) \ +#define ANALYTICAL_MIN_MAX_CALC_FIXED_ALL_ROWS(TPE, MIN_MAX) \ do { \ TPE curval = TPE##_nil; \ for (j = k; j < i; j++) { \ @@ -852,7 +848,7 @@ GDKanalyticallead(BAT *r, BAT *b, BAT *p has_nils |= is_##TPE##_nil(curval); \ } while (0) -#define ANALYTICAL_MIN_MAX_CALC_FIXED_CURRENT_ROW(TPE, NAN_CHECK, MIN_MAX) \ +#define ANALYTICAL_MIN_MAX_CALC_FIXED_CURRENT_ROW(TPE, MIN_MAX)\ do { \ for (; k < i; k++) { \ TPE v = bp[k]; \ @@ -861,7 +857,7 @@ GDKanalyticallead(BAT *r, BAT *b, BAT *p } \ } while (0) -#define ANALYTICAL_MIN_MAX_CALC_FIXED_OTHERS(TPE, NAN_CHECK, MIN_MAX) \ +#define ANALYTICAL_MIN_MAX_CALC_FIXED_OTHERS(TPE, MIN_MAX) \ do { \ TPE curval = TPE##_nil; \ for (; k < i; k++) { \ @@ -890,7 +886,6 @@ GDKanalyticallead(BAT *r, BAT *b, BAT *p void *next = BUNtail(bpi, k), *curval = next; \ j = k++; \ while (k < i && atomcmp(BUNtail(bpi, k), next) == 0) { \ - k++; \ void *nnext = BUNtail(bpi, k); \ if (atomcmp(nnext, nil) != 0) { \ if (atomcmp(curval, nil) == 0) \ @@ -898,6 +893,7 @@ GDKanalyticallead(BAT *r, BAT *b, BAT *p else\
MonetDB: window-tunning - More cleanup, I had to undo one of the...
Changeset: 52eb4938ea71 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=52eb4938ea71 Modified Files: gdk/gdk_analytic_func.c Branch: window-tunning Log Message: More cleanup, I had to undo one of the previous commits because it was becoming difficult to manage many nested macros diffs (truncated from 612 to 300 lines): diff --git a/gdk/gdk_analytic_func.c b/gdk/gdk_analytic_func.c --- a/gdk/gdk_analytic_func.c +++ b/gdk/gdk_analytic_func.c @@ -793,16 +793,10 @@ GDKanalyticallead(BAT *r, BAT *b, BAT *p #define ANALYTICAL_MIN_MAX_CALC_FIXED_UNBOUNDED_TILL_CURRENT_ROW(TPE, NAN_CHECK, MIN_MAX) \ do { \ - TPE curval = TPE##_nil; \ for (; k < i;) { \ TPE v = bp[k]; \ + TPE curval = v; \ j = k++; \ - if (!is_##TPE##_nil(v)) { \ - if (is_##TPE##_nil(curval)) \ - curval = v; \ - else\ - curval = MIN_MAX(v, curval); \ - } \ while (k < i && (bp[k] == v NAN_CHECK(TPE, k))) { \ k++; \ if (!is_##TPE##_nil(bp[k])) { \ @@ -820,16 +814,10 @@ GDKanalyticallead(BAT *r, BAT *b, BAT *p #define ANALYTICAL_MIN_MAX_CALC_FIXED_CURRENT_ROW_TILL_UNBOUNDED(TPE, NAN_CHECK, MIN_MAX) \ do { \ - TPE curval = TPE##_nil; \ for (j = i - 1; j >= k; ) { \ TPE v = bp[j]; \ + TPE curval = v; \ l = j--; \ - if (!is_##TPE##_nil(v)) { \ - if (is_##TPE##_nil(curval)) \ - curval = v; \ - else\ - curval = MIN_MAX(v, curval); \ - } \ while (j >= k && (bp[j] == v NAN_CHECK(TPE, j))) { \ j--; \ if (!is_##TPE##_nil(bp[j])) { \ @@ -898,16 +886,9 @@ GDKanalyticallead(BAT *r, BAT *b, BAT *p #define ANALYTICAL_MIN_MAX_CALC_VARSIZED_UNBOUNDED_TILL_CURRENT_ROW(GT_LT) \ do { \ - void *curval = (void*) nil; \ for (; k < i;) { \ - void *next = BUNtail(bpi, k); \ + void *next = BUNtail(bpi, k), *curval = next; \ j = k++; \ - if (atomcmp(next, nil) != 0) { \ - if (atomcmp(curval, nil) == 0) \ - curval = next; \ - else\ - curval = atomcmp(next, curval) GT_LT 0 ? curval : next; \ - } \ while (k < i && atomcmp(BUNtail(bpi, k), next) == 0) { \ k++; \ void *nnext = BUNtail(bpi, k); \ @@ -927,16 +908,9 @@ GDKanalyticallead(BAT *r, BAT *b, BAT *p #define ANALYTICAL_MIN_MAX_CALC_VARSIZED_CURRENT_ROW_TILL_UNBOUNDED(GT_LT) \ do { \ - void *curval = (void*) nil; \ for (j = i - 1; j >= k; ) { \ - void *next = BUNtail(bpi, j); \ + void *next = BUNtail(bpi, j), *curval = next; \ l = j--; \ - if (atomcmp(next, nil) != 0) { \ - if (atomcmp(curval, nil) == 0) \ - curval = next; \ - else\ - curval = atomcmp(next, curval) GT_LT 0 ? curval : next; \ - } \ while (j >= k && atomcmp(BUNtail(bpi, j), next) == 0) { \ j--; \ void *nnext = BUNtail(bpi, j); \ @@ -1490,16 +1464,10 @@ GDKanalyticalcount(BAT *r, BAT *p, BAT * /* sum on fixed size integers */ #define ANALYTICAL_SUM_IMP_NUM_UNBOUNDED_TILL_CURRENT_ROW(TPE1, TPE2) \ do { \ - TPE2 curval = TPE2##_nil; \ for (; k < i;) { \ TPE1 v = bp[k]; \ + TPE2 curval = is_##TPE1##_nil(v) ? TPE2##_nil : (TPE2) v; \ j = k++; \ - if (!is_##TPE1##_nil(v)) { \ - if
MonetDB: window-tunning - More cleanup
Changeset: de9d7a7fb942 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=de9d7a7fb942 Modified Files: gdk/gdk_analytic_func.c Branch: window-tunning Log Message: More cleanup diffs (truncated from 432 to 300 lines): diff --git a/gdk/gdk_analytic_func.c b/gdk/gdk_analytic_func.c --- a/gdk/gdk_analytic_func.c +++ b/gdk/gdk_analytic_func.c @@ -791,44 +791,67 @@ GDKanalyticallead(BAT *r, BAT *b, BAT *p return GDK_SUCCEED; } -#define ANALYTICAL_MIN_MAX_CALC_FIXED_UNBOUNDED_TILL_CURRENT_ROW(TPE, MIN_MAX) \ +#define ANALYTICAL_MIN_MAX_CALC_FIXED_UNBOUNDED_TILL_CURRENT_ROW(TPE, NAN_CHECK, MIN_MAX) \ do { \ TPE curval = TPE##_nil; \ - for (; k < i; k++) { \ - v = bp[k]; \ + for (; k < i;) { \ + TPE v = bp[k]; \ + j = k++; \ if (!is_##TPE##_nil(v)) { \ if (is_##TPE##_nil(curval)) \ curval = v; \ else\ curval = MIN_MAX(v, curval); \ } \ - rb[k] = curval; \ + while (k < i && (bp[k] == v NAN_CHECK(TPE, k))) { \ + k++; \ + if (!is_##TPE##_nil(bp[k])) { \ + if (is_##TPE##_nil(curval)) \ + curval = bp[k]; \ + else\ + curval = MIN_MAX(bp[k], curval); \ + } \ + } \ + for (; j < k; j++) \ + rb[j] = curval; \ has_nils |= is_##TPE##_nil(curval); \ } \ } while (0) -#define ANALYTICAL_MIN_MAX_CALC_FIXED_CURRENT_ROW_TILL_UNBOUNDED(TPE, MIN_MAX) \ +#define ANALYTICAL_MIN_MAX_CALC_FIXED_CURRENT_ROW_TILL_UNBOUNDED(TPE, NAN_CHECK, MIN_MAX) \ do { \ TPE curval = TPE##_nil; \ - for (j = i - 1; j >= k; j--) { \ - v = bp[j]; \ + for (j = i - 1; j >= k; ) { \ + TPE v = bp[j]; \ + l = j--; \ if (!is_##TPE##_nil(v)) { \ if (is_##TPE##_nil(curval)) \ curval = v; \ else\ curval = MIN_MAX(v, curval); \ } \ - rb[j] = curval; \ + while (j >= k && (bp[j] == v NAN_CHECK(TPE, j))) { \ + j--; \ + if (!is_##TPE##_nil(bp[j])) { \ + if (is_##TPE##_nil(curval)) \ + curval = bp[j]; \ + else\ + curval = MIN_MAX(bp[j], curval); \ + } \ + } \ + m = MAX(k, j); \ + for (; l >= m; l--) \ + rb[l] = curval; \ has_nils |= is_##TPE##_nil(curval); \ - } \ + } \ k = i; \ } while (0) -#define ANALYTICAL_MIN_MAX_CALC_FIXED_ALL_ROWS(TPE, MIN_MAX) \ +#define ANALYTICAL_MIN_MAX_CALC_FIXED_ALL_ROWS(TPE, NAN_CHECK, MIN_MAX) \ do { \ TPE curval = TPE##_nil; \ for (j = k; j < i; j++) { \ - v = bp[j]; \ + TPE v = bp[j]; \ if (!is_##TPE##_nil(v)) { \ if (is_##TPE##_nil(curval)) \ curval = v; \ @@ -841,23 +864,23 @@ GDKanalyticallead(BAT *r, BAT *b, BAT *p has_nils |= is_##TPE##_nil(curval); \ } while (0) -#define ANALYTICAL_MIN_MAX_CALC_FIXED_CURRENT_ROW(TPE, MIN_MAX)\ +#define ANALYTICAL_MIN_MAX_CALC_FIXED_CURRENT_ROW(TPE, NAN_CHECK, MIN_MAX) \ do { \ for (; k < i; k++) { \ - v = bp[k]; \ + TPE v = bp[k]; \ rb[k] = v; \
MonetDB: window-tunning - Need extra check for NULL values on fl...
Changeset: 38a8ed3bd243 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=38a8ed3bd243 Modified Files: gdk/gdk_analytic_func.c Branch: window-tunning Log Message: Need extra check for NULL values on floating-points in order to match diffs (288 lines): diff --git a/gdk/gdk_analytic_func.c b/gdk/gdk_analytic_func.c --- a/gdk/gdk_analytic_func.c +++ b/gdk/gdk_analytic_func.c @@ -11,6 +11,10 @@ #include "gdk_analytic.h" #include "gdk_calc_private.h" +/* needed for some operators on floating-points */ +#define NAN_CHECK(TPE, i) || (is_##TPE##_nil(v) && is_##TPE##_nil(bp[i])) +#define NO_NAN_CHECK(TPE, i) + #define NTILE_CALC(TPE, NEXT_VALUE, LNG_HGE, UPCAST) \ do {\ for (TPE i = 0; rb < rp; i++, rb++) { \ @@ -1056,15 +1060,15 @@ ANALYTICAL_MIN_MAX(min, MIN, >) ANALYTICAL_MIN_MAX(max, MAX, <) /* Counting no nils for fixed sizes */ -#define ANALYTICAL_COUNT_NO_NIL_FIXED_UNBOUNDED_TILL_CURRENT_ROW(TPE) \ +#define ANALYTICAL_COUNT_NO_NIL_FIXED_UNBOUNDED_TILL_CURRENT_ROW(TPE, NAN_CHECK) \ do { \ curval = 0; \ if (count_all) { \ for (; k < i;) { \ - TPE v = bpf[k]; \ + TPE v = bp[k]; \ j = k++; \ curval++; \ - while (k < i && bpf[k] == v) { \ + while (k < i && (bp[k] == v NAN_CHECK(TPE, k))) { \ k++; \ curval++; \ } \ @@ -1073,12 +1077,12 @@ ANALYTICAL_MIN_MAX(max, MAX, <) } \ } else { \ for (; k < i;) { \ - TPE v = bpf[k]; \ + TPE v = bp[k]; \ j = k++; \ - curval += !is_##TPE##_nil(bpf[k]); \ - while (k < i && bpf[k] == v) { \ + curval += !is_##TPE##_nil(bp[k]); \ + while (k < i && (bp[k] == v NAN_CHECK(TPE, k))) { \ k++; \ - curval += !is_##TPE##_nil(bpf[k]); \ + curval += !is_##TPE##_nil(bp[k]); \ } \ for (; j < k; j++) \ rb[j] = curval; \ @@ -1086,15 +1090,15 @@ ANALYTICAL_MIN_MAX(max, MAX, <) } \ } while (0) -#define ANALYTICAL_COUNT_NO_NIL_FIXED_CURRENT_ROW_TILL_UNBOUNDED(TPE) \ +#define ANALYTICAL_COUNT_NO_NIL_FIXED_CURRENT_ROW_TILL_UNBOUNDED(TPE, NAN_CHECK) \ do { \ curval = 0; \ if (count_all) { \ for (j = i - 1; j >= k; ) { \ - TPE v = bpf[j]; \ + TPE v = bp[j]; \ l = j--; \ curval++; \ - while (j >= k && bpf[j] == v) { \ + while (j >= k && (bp[j] == v NAN_CHECK(TPE, j))) { \ j--; \ curval++; \ } \ @@ -1104,12 +1108,12 @@ ANALYTICAL_MIN_MAX(max, MAX, <) } \ } else { \ for (j = i - 1; j >= k; ) { \ - TPE v = bpf[j]; \ + TPE v = bp[j]; \ l = j--; \ - curval += !is_##TPE##_nil(bpf[j]); \ - while (j >= k && bpf[j] == v) { \ + curval += !is_##TPE##_nil(bp[j]); \ + while (j >= k && (bp[j] == v NAN_CHECK(TPE, j))) { \ j--; \ - curval += !is_##TPE##_nil(bpf[j]); \ + curval += !is_##TPE##_nil(bp[j]); \ } \ m = MAX(k, j); \ for (; l >= m; l--) \ @@ -1119,7 +1123,7 @@ ANALYTICAL_MIN_MAX(max, MAX, <) k = i; \ } while (0) -#define ANALYTICAL_COUNT_NO_NIL_FIXED_ALL_ROWS(TPE)\ +#define ANALYTICAL_COUNT_NO_NIL_FIXED_ALL_ROWS(TPE, NAN_CHECK) \ do { \ if (count_all) { \ curval = i - k; \ @@ -1128,24 +1132,24 @@ ANALYTICAL_MIN_MAX(max, MAX, <) } else {\ curval = 0; \ for (; j < i; j++) \ - curval += !is_##TPE##_nil(bpf[j]); \ +
MonetDB: window-tunning - Fixing the bugs I created. I forgot in...
Changeset: 44f2824bed4a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=44f2824bed4a Modified Files: gdk/gdk_analytic_func.c sql/server/rel_select.c Branch: window-tunning Log Message: Fixing the bugs I created. I forgot in the unbounded cases, the peer rows get the same value, time for another small cleanup. Also reduced the number of branches in count function diffs (truncated from 676 to 300 lines): diff --git a/gdk/gdk_analytic_func.c b/gdk/gdk_analytic_func.c --- a/gdk/gdk_analytic_func.c +++ b/gdk/gdk_analytic_func.c @@ -1055,166 +1055,231 @@ GDKanalytical##OP(BAT *r, BAT *p, BAT *b ANALYTICAL_MIN_MAX(min, MIN, >) ANALYTICAL_MIN_MAX(max, MAX, <) -/* Counting all rows including nils */ -#define ANALYTICAL_COUNT_ALL_UNBOUNDED_TILL_CURRENT_ROW\ - do { \ - curval = 0; \ - for (; k < i; k++) \ - rb[k] = ++curval; \ - } while (0) - -#define ANALYTICAL_COUNT_ALL_CURRENT_ROW_TILL_UNBOUNDED\ - do { \ - curval = 0; \ - for (j = i - 1; j >= k; j--) \ - rb[j] = ++curval; \ - k = i; \ - } while (0) - -#define ANALYTICAL_COUNT_ALL_ALL_ROWS \ - do { \ - curval = i - k; \ - for (; k < i; k++) \ - rb[k] = curval; \ - } while (0) - -#define ANALYTICAL_COUNT_ALL_CURRENT_ROW \ - do { \ - for (; k < i; k++) \ - rb[k] = 1; \ - } while (0) - -#define ANALYTICAL_COUNT_ALL_OTHERS\ - do { \ - for (; k < i; k++) \ - rb[k] = (end[k] > start[k]) ? (end[k] - start[k]) : 0; \ - } while (0) - /* Counting no nils for fixed sizes */ #define ANALYTICAL_COUNT_NO_NIL_FIXED_UNBOUNDED_TILL_CURRENT_ROW(TPE) \ do { \ curval = 0; \ - for (; k < i; k++) { \ - curval += !is_##TPE##_nil(bpf[k]); \ - rb[k] = curval; \ - } \ + if (count_all) { \ + for (; k < i;) { \ + TPE v = bpf[k]; \ + j = k++; \ + curval++; \ + while (k < i && bpf[k] == v) { \ + k++; \ + curval++; \ + } \ + for (; j < k; j++) \ + rb[j] = curval; \ + } \ + } else { \ + for (; k < i;) { \ + TPE v = bpf[k]; \ + j = k++; \ + curval += !is_##TPE##_nil(bpf[k]); \ + while (k < i && bpf[k] == v) { \ + k++; \ + curval += !is_##TPE##_nil(bpf[k]); \ + } \ + for (; j < k; j++) \ + rb[j] = curval; \ + } \ + } \ } while (0) #define ANALYTICAL_COUNT_NO_NIL_FIXED_CURRENT_ROW_TILL_UNBOUNDED(TPE) \ do { \ curval = 0; \ - for (j = i - 1; j >= k; j--) { \ - curval += !is_##TPE##_nil(bpf[j]); \ - rb[j] = curval; \ + if (count_all) { \ + for (j = i - 1; j >= k; ) { \ + TPE v = bpf[j]; \ + l = j--; \ + curval++; \ + while (j >= k && bpf[j] == v) { \ + j--; \ + curval++; \ + } \ + m = MAX(k, j); \ + for (; l >= m; l--) \ + rb[l] = curval; \ + } \ + } else { \ + for (j = i - 1; j >= k; ) { \ + TPE v = bpf[j]; \ + l = j--; \ + curval += !is_##TPE##_nil(bpf[j]); \ + while (j >= k && bpf[j] == v) { \ + j--; \ + curval += !is_##TPE##_nil(bpf[j]); \ + } \ + m = MAX(k, j); \ + for (; l >= m; l--) \ + rb[l] = curval; \ + } \ } \ k = i; \ } while (0) #define ANALYTICAL_COUNT_NO_NIL_FIXED_ALL_ROWS(TPE)\ do { \ - curval