Changeset: 090dbb58aec7 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/090dbb58aec7
Modified Files:
sql/backends/monet5/sql.c
sql/backends/monet5/sql_result.c
Branch: directappend
Log Message:
Merge branch 'default' into 'directappend'
diffs (truncated from 2477 to 300 lines):
diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -1506,15 +1506,15 @@ describe_sequence(Mapi mid, const char *
goto bailout;
snprintf(query, maxquerylen,
- "SELECT s.name, "
/* 0 */
- "seq.name, "
/* 1 */
- "get_value_for(s.name, seq.name), " /* 2 */
- "seq.\"minvalue\", "
/* 3 */
- "seq.\"maxvalue\", "
/* 4 */
- "seq.\"increment\", " /* 5 */
- "seq.\"cycle\", "
/* 6 */
- "seq.\"cacheinc\", "
/* 7 */
- "rem.\"remark\" "
/* 8 */
+ "SELECT s.name, "
/* 0 */
+ "seq.name, "
/* 1 */
+ "peak_next_value_for(s.name, seq.name), " /* 2 */
+ "seq.\"minvalue\", "
/* 3 */
+ "seq.\"maxvalue\", "
/* 4 */
+ "seq.\"increment\", "
/* 5 */
+ "seq.\"cycle\", "
/* 6 */
+ "seq.\"cacheinc\", "
/* 7 */
+ "rem.\"remark\" "
/* 8 */
"FROM sys.sequences seq LEFT OUTER JOIN sys.comments rem ON
seq.id = rem.id, "
"sys.schemas s "
"WHERE s.id = seq.schema_id "
diff --git a/gdk/CMakeLists.txt b/gdk/CMakeLists.txt
--- a/gdk/CMakeLists.txt
+++ b/gdk/CMakeLists.txt
@@ -18,6 +18,7 @@ set(gdk_public_headers
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/gdk_utils.h>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/gdk_cand.h>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/gdk_calc.h>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/gdk_strimps.h>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/gdk_time.h>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/monetdb/gdk.h>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/monetdb/gdk_system.h>
@@ -30,6 +31,7 @@ set(gdk_public_headers
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/monetdb/gdk_utils.h>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/monetdb/gdk_calc.h>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/monetdb/gdk_cand.h>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/monetdb/gdk_strimps.h>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/monetdb/gdk_time.h>)
add_library(bat SHARED)
@@ -81,7 +83,7 @@ target_sources(bat
gdk_analytic_func.c
gdk_analytic.h
gdk_tracer.c gdk_tracer.h
- gdk_strimps.c gdk_strimps.h
+ gdk_strimps.c
PUBLIC
${gdk_public_headers})
diff --git a/gdk/gdk_strimps.c b/gdk/gdk_strimps.c
--- a/gdk/gdk_strimps.c
+++ b/gdk/gdk_strimps.c
@@ -297,16 +297,18 @@ STRMPbuildHeader(BAT *b, BAT *s, CharPai
CharPair cp, *cpp;
struct canditer ci;
size_t values = 0;
-
+ bool res;
TRC_DEBUG_IF(ACCELERATOR) t0 = GDKusec();
- hlen = STRIMP_HISTSIZE;
- if ((hist = (PairHistogramElem
*)GDKmalloc(hlen*sizeof(PairHistogramElem))) == NULL) {
+
+ ncand = canditer_init(&ci, b, s);
+ if (ncand == 0) {
+ GDKerror("Not enough distinct values to create strimp index\n");
return false;
}
- ncand = canditer_init(&ci, b, s);
- if (ncand == 0) {
+ hlen = STRIMP_HISTSIZE;
+ if ((hist = (PairHistogramElem
*)GDKmalloc(hlen*sizeof(PairHistogramElem))) == NULL) {
return false;
}
@@ -357,6 +359,13 @@ STRMPbuildHeader(BAT *b, BAT *s, CharPai
if (hist[hidx].p == NULL) {
values++;
hist[hidx].p = (CharPair
*)GDKmalloc(sizeof(CharPair));
+ if (!hist[hidx].p) {
+ bat_iterator_end(&bi);
+ for (hidx = 0; hidx <
hlen; hidx++)
+
GDKfree(hist[hidx].p);
+ GDKfree(hist);
+ return false;
+ }
hist[hidx].p->psize =
cpp->psize;
hist[hidx].p->pbytes =
cpp->pbytes;
}
@@ -382,7 +391,9 @@ STRMPbuildHeader(BAT *b, BAT *s, CharPai
GDKfree(hist);
TRC_DEBUG(ACCELERATOR, LLFMT " usec\n", GDKusec() - t0);
- return values >= STRIMP_HEADER_SIZE;
+ if (!(res = values >= STRIMP_HEADER_SIZE))
+ GDKerror("Not enough distinct values to create strimp index\n");
+ return res;
}
static bool
@@ -480,6 +491,16 @@ BATcheckstrimps(BAT *b)
return ret;
}
+#define STRMPfilterloop(next) \
+ do { \
+ for (i = 0; i < ncand; i++) { \
+ x = next(&ci); \
+ if ((bitstring_array[x] & qbmask) == qbmask) { \
+ rvals[j++] = x; \
+ } \
+ } \
+ } while (0)
+
/* Filter a BAT b using a string q. Return the result as a candidate
* list.
*/
@@ -487,11 +508,11 @@ BAT *
STRMPfilter(BAT *b, BAT *s, const str q)
{
BAT *r = NULL;
- BUN i, ncand;
+ BUN i, ncand, j = 0;
uint64_t qbmask;
uint64_t *bitstring_array;
Strimps *strmps;
- oid x;
+ oid x, *restrict rvals;
struct canditer ci;
lng t0 = 0;
BAT *pb;
@@ -512,7 +533,7 @@ STRMPfilter(BAT *b, BAT *s, const str q)
STRMPincref(strmps);
MT_lock_unset(&pb->batIdxLock);
- ncand = canditer_init(&ci, b, s);
+ ncand = canditer_init(&ci, b, s);
if (ncand == 0) {
STRMPdecref(strmps, false);
return BATdense(b->hseqbase, 0, 0);
@@ -525,18 +546,15 @@ STRMPfilter(BAT *b, BAT *s, const str q)
qbmask = STRMPmakebitstring(q, strmps);
bitstring_array = (uint64_t *)strmps->bitstrings_base;
+ rvals = Tloc(r, 0);
- for (i = 0; i < ncand; i++) {
- x = canditer_next(&ci);
- if ((bitstring_array[x] & qbmask) == qbmask) {
- if (BUNappend(r, &x, false) != GDK_SUCCEED) {
- BBPunfix(r->batCacheid);
- STRMPdecref(strmps, false);
- goto sfilter_fail;
- }
- }
+ if (ci.tpe == cand_dense) {
+ STRMPfilterloop(canditer_next_dense);
+ } else {
+ STRMPfilterloop(canditer_next);
}
+ BATsetcount(r, j);
r->tkey = true;
r->tsorted = true;
r->trevsorted = BATcount(r) <= 1;
@@ -636,8 +654,8 @@ STRMPcreateStrimpHeap(BAT *b, BAT *s)
CharPair hpairs[STRIMP_HEADER_SIZE];
const char *nme;
- if ((r = b->tstrimps) == NULL &&
- STRMPbuildHeader(b, s, hpairs)) { /* Find the header pairs, put
+ if ((r = b->tstrimps) == NULL &&
+ STRMPbuildHeader(b, s, hpairs)) { /* Find the header pairs, put
the result in hpairs */
sz = 8 + STRIMP_HEADER_SIZE; /* add 8-bytes for the descriptor
and
the pair sizes */
@@ -707,7 +725,7 @@ STRMPcreate(BAT *b, BAT *s)
if (pb->tstrimps == NULL) {
MT_lock_set(&pb->batIdxLock);
- if (pb->tstrimps == NULL) {
+ if (pb->tstrimps == NULL) {
Strimps *r;
BATiter bi;
BUN i, ncand;
@@ -716,10 +734,10 @@ STRMPcreate(BAT *b, BAT *s)
str cs;
uint64_t *dh;
- if ((r = STRMPcreateStrimpHeap(pb, s)) == NULL) {
- MT_lock_unset(&b->batIdxLock);
+ if ((r = STRMPcreateStrimpHeap(pb, s)) == NULL) {
+ MT_lock_unset(&pb->batIdxLock);
return GDK_FAIL;
- }
+ }
dh = (uint64_t *)r->bitstrings_base;
/* Compute bitstrings */
@@ -739,10 +757,10 @@ STRMPcreate(BAT *b, BAT *s)
pb->tstrimps = r;
pb->batDirtydesc = true;
persistStrimp(pb);
- }
- MT_lock_unset(&pb->batIdxLock);
- }
- TRC_DEBUG(ACCELERATOR, "strimp creation took " LLFMT " usec\n",
GDKusec()-t0);
+ }
+ MT_lock_unset(&pb->batIdxLock);
+ }
+ TRC_DEBUG(ACCELERATOR, "strimp creation took " LLFMT " usec\n",
GDKusec()-t0);
return GDK_SUCCEED;
}
@@ -780,6 +798,7 @@ STRMPappendBitstring(BAT *b, const str s
size_t pairs_offset = (char *)strmp->pairs_base -
strmp->strimps.base;
size_t bitstrings_offset = (char *)strmp->bitstrings_base -
strmp->strimps.base;
if (HEAPextend(&(strmp->strimps),
(size_t)(extend_factor*BATcount(pb)*sizeof(uint64_t)), false) == GDK_FAIL) {
+ MT_lock_unset(&pb->batIdxLock);
GDKerror("Cannot extend heap\n");
return GDK_FAIL;
}
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -5799,10 +5799,9 @@ pnpoly(int *out, int nvert, dbl *vx, dbl
}
bat_iterator_end(&bpxi);
bat_iterator_end(&bpyi);
-
+ BATsetcount(bo, cnt);
bo->tsorted = bo->trevsorted = false;
bo->tkey = false;
- BATsetcount(bo, cnt);
BBPunfix(bpx->batCacheid);
BBPunfix(bpy->batCacheid);
BBPkeepref(*out = bo->batCacheid);
@@ -5892,9 +5891,9 @@ pnpolyWithHoles(bat *out, int nvert, dbl
}
bat_iterator_end(&bpxi);
bat_iterator_end(&bpyi);
+ BATsetcount(bo, cnt);
bo->tsorted = bo->trevsorted = false;
bo->tkey = false;
- BATsetcount(bo, cnt);
BBPunfix(bpx->batCacheid);
BBPunfix(bpy->batCacheid);
BBPkeepref(*out = bo->batCacheid);
diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c
--- a/monetdb5/modules/atoms/json.c
+++ b/monetdb5/modules/atoms/json.c
@@ -1230,6 +1230,9 @@ static str
JSONfilterArrayDefault(json *ret, json *js, lng index, str other)
{
char expr[BUFSIZ], *s = expr;
+
+ if (index < 0)
+ throw(MAL,"json.filter", SQLSTATE(42000) "Filter index cannot
be negative");
snprintf(expr, BUFSIZ, "[" LLFMT "]", index);
return JSONfilterInternal(ret, js, &s, other);
}
@@ -1237,48 +1240,88 @@ JSONfilterArrayDefault(json *ret, json *
static str
JSONfilterArray_bte(json *ret, json *js, bte *index)
{
+ if (strNil(*js) || is_bte_nil(*index)) {
+ if (!(*ret = GDKstrdup(str_nil)))
+ throw(MAL,"json.filter", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ return MAL_SUCCEED;
+ }
return JSONfilterArrayDefault(ret, js, (lng) *index, 0);
}
static str
JSONfilterArrayDefault_bte(json *ret, json *js, bte *index, str *other)
{
+ if (strNil(*js) || is_bte_nil(*index) || strNil(*other)) {
+ if (!(*ret = GDKstrdup(str_nil)))
+ throw(MAL,"json.filter", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ return MAL_SUCCEED;
+ }
return JSONfilterArrayDefault(ret, js, (lng) *index, *other);
}
static str
JSONfilterArray_sht(json *ret, json *js, sht *index)
{
+ if (strNil(*js) || is_sht_nil(*index)) {
+ if (!(*ret = GDKstrdup(str_nil)))
+ throw(MAL,"json.filter", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ return MAL_SUCCEED;
+ }
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list