Mercurial > hg > MonetDB-extend
changeset 55:68263b10998e
Updated: added bat_iterator_end.
author | Sjoerd Mullender <sjoerd@acm.org> |
---|---|
date | Wed, 26 Jan 2022 14:59:05 +0100 (2022-01-26) |
parents | 9ff721585946 |
children | 8122094c79b1 |
files | Makefile cxx-reverse/reverse.cpp regexp/README.rst regexp/regexp.c reverse/README.rst reverse/reverse.c |
diffstat | 6 files changed, 25 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Mon Dec 13 12:40:58 2021 +0100 +++ b/Makefile Wed Jan 26 14:59:05 2022 +0100 @@ -7,7 +7,7 @@ all: doc: README.html README.pdf - for d in reverse regexp gmean; do make -C $$d; done + for d in reverse regexp gmean; do make -C $$d doc; done README.html: README.rst rst2html -d README.rst > README.html
--- a/cxx-reverse/reverse.cpp Mon Dec 13 12:40:58 2021 +0100 +++ b/cxx-reverse/reverse.cpp Wed Jan 26 14:59:05 2022 +0100 @@ -150,6 +150,7 @@ goto bailout; } } + bat_iterator_end(&bi); GDKfree(dst); BBPunfix(b->batCacheid); @@ -162,6 +163,7 @@ bailout: /* we only get here in the case of an allocation error; clean * up the mess we've created and throw an exception */ + bat_iterator_end(&bi); GDKfree(dst); BBPunfix(b->batCacheid); BBPunfix(bn->batCacheid);
--- a/regexp/README.rst Mon Dec 13 12:40:58 2021 +0100 +++ b/regexp/README.rst Wed Jan 26 14:59:05 2022 +0100 @@ -478,6 +478,9 @@ instead of ``BUNtail`` should be slightly faster since it omits a few tests. +The call to ``bat_iterator`` must be matched with a call to +``bat_iterator_end``. + Now we get to the core of the algorithm. We iterate over the candidates and in each iteration we check first whether the value is nil, and if not whether the value matches the regular expression. If
--- a/regexp/regexp.c Mon Dec 13 12:40:58 2021 +0100 +++ b/regexp/regexp.c Wed Jan 26 14:59:05 2022 +0100 @@ -197,6 +197,7 @@ pos = pcre_exec(re, sd, val, (int) strlen(val), 0, 0, NULL, 0); if (pos < 0 && pos != PCRE_ERROR_NOMATCH && pos != PCRE_ERROR_BADUTF8) { /* error during processing */ + bat_iterator_end(&bi); BBPunfix(b->batCacheid); BBPreclaim(bn); pcre_free_study(sd); @@ -208,6 +209,7 @@ *outp++ = pos >= 0; /* TRUE if match, FALSE if not */ } } + bat_iterator_end(&bi); /* set properties and size of result BAT */ BATsetcount(bn, BATcount(b)); @@ -381,6 +383,7 @@ *outp++ = o; } else { /* error during processing */ + bat_iterator_end(&bi); BBPunfix(b->batCacheid); BBPunfix(s->batCacheid); BBPreclaim(bn); @@ -392,6 +395,8 @@ } } } + /* we're done with the BAT iterator */ + bat_iterator_end(&bi); /* we're done with b, s, and re */ BBPunfix(b->batCacheid); if (s) @@ -610,6 +615,8 @@ pcre_free_study(sd); pcre_free(re); } + bat_iterator_end(&li); + bat_iterator_end(&ri); BBPunfix(l->batCacheid); BBPunfix(r->batCacheid); @@ -624,6 +631,8 @@ return MAL_SUCCEED; bailout: + bat_iterator_end(&li); + bat_iterator_end(&ri); BBPreclaim(bn1); BBPreclaim(bn2); BBPunfix(l->batCacheid);
--- a/reverse/README.rst Mon Dec 13 12:40:58 2021 +0100 +++ b/reverse/README.rst Wed Jan 26 14:59:05 2022 +0100 @@ -323,6 +323,7 @@ BATloop(b, p, q) { ... } + bat_iterator_end(&bi); ``BATloop`` is a macro that translates to a C ``for`` loop, using the first argument to set the bounds, the second argument to iterate @@ -330,6 +331,13 @@ argument can be used inside the body as an argument to e.g. ``BUNtail``. +We make use of a BAT iterator (type ``BATiter``) which is initialized +with a call to ``bat_iterator(b)``. Since this call increments a +reference count, we need to match the initialization with a call to +``bat_iterator_end(&bi)``. The calls to ``bat_iterator`` and +``bat_iterator_end`` cannot fail. The need for ``bat_iterator_end`` is +new since the Jul2021 release (11.41.X). + The body of the loop first retrieves the current value from the column:
--- a/reverse/reverse.c Mon Dec 13 12:40:58 2021 +0100 +++ b/reverse/reverse.c Wed Jan 26 14:59:05 2022 +0100 @@ -146,6 +146,7 @@ goto bailout; } } + bat_iterator_end(&bi); GDKfree(dst); BBPunfix(b->batCacheid); @@ -158,6 +159,7 @@ bailout: /* we only get here in the case of an allocation error; clean * up the mess we've created and throw an exception */ + bat_iterator_end(&bi); GDKfree(dst); BBPunfix(b->batCacheid); BBPunfix(bn->batCacheid);