Changeset: f12d17f7ddce for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f12d17f7ddce
Modified Files:
gdk/gdk_calc.c
Branch: qcancel
Log Message:
timeout negate, logical not, min, max
diffs (truncated from 623 to 300 lines):
diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -88,6 +88,8 @@ checkbats(BAT *b1, BAT *b2, const char *
const TYPE1 *restrict src = (const TYPE1 *) Tloc(b, 0); \
TYPE2 *restrict dst = (TYPE2 *) Tloc(bn, 0); \
for (i = 0; i < ncand; i++) { \
+ GDK_CHECK_TIMEOUT(timeoffset, counter, \
+ GOTO_LABEL_TIMEOUT_HANDLER(bailout)); \
x = canditer_next(&ci) - bhseqbase; \
if (is_##TYPE1##_nil(src[x])) { \
nils++; \
@@ -103,6 +105,8 @@ checkbats(BAT *b1, BAT *b2, const char *
const TYPE1 *restrict src = (const TYPE1 *) Tloc(b, 0); \
TYPE2 *restrict dst = (TYPE2 *) Tloc(bn, 0); \
for (i = 0; i < ncand; i++) { \
+ GDK_CHECK_TIMEOUT(timeoffset, counter, \
+ GOTO_LABEL_TIMEOUT_HANDLER(bailout)); \
x = canditer_next(&ci) - bhseqbase; \
if (is_##TYPE1##_nil(src[x])) { \
nils++; \
@@ -358,6 +362,13 @@ BATcalcnot(BAT *b, BAT *s)
oid x, bhseqbase = b->hseqbase;
struct canditer ci;
+ size_t counter = 0;
+ lng timeoffset = 0;
+ QryCtx *qry_ctx = MT_thread_get_qry_ctx();
+ if (qry_ctx != NULL) {
+ timeoffset = (qry_ctx->starttime && qry_ctx->querytimeout) ?
(qry_ctx->starttime + qry_ctx->querytimeout) : 0;
+ }
+
TRC_DEBUG_IF(ALGO) t0 = GDKusec();
BATcheck(b, NULL);
@@ -379,15 +390,21 @@ BATcalcnot(BAT *b, BAT *s)
ncand = (ncand + 31) / 32;
if (bits == 0) {
for (i = 0; i < ncand; i++)
+ GDK_CHECK_TIMEOUT(timeoffset, counter,
+
GOTO_LABEL_TIMEOUT_HANDLER(bailout));
dst[i] = ~src[i];
} else {
for (i = 0; i < ncand; i++)
+ GDK_CHECK_TIMEOUT(timeoffset, counter,
+
GOTO_LABEL_TIMEOUT_HANDLER(bailout));
dst[i] = (~src[i] >> bits) | ~(src[i +
1] >> (32 - bits));
}
if (ci.ncand % 32 != 0)
dst[ci.ncand / 32] &= (1U << (ci.ncand % 32)) -
1;
} else {
for (i = 0; i < ncand; i++) {
+ GDK_CHECK_TIMEOUT(timeoffset, counter,
+
GOTO_LABEL_TIMEOUT_HANDLER(bailout));
x = canditer_next(&ci) - bhseqbase;
mskSetVal(bn, i, !mskGetVal(b, x));
}
@@ -435,6 +452,10 @@ BATcalcnot(BAT *b, BAT *s)
ALGOOPTBATPAR(bn), GDKusec() - t0);
return bn;
+
+bailout:
+ BBPunfix(bn->batCacheid);
+ return NULL;
}
gdk_return
@@ -532,6 +553,14 @@ BATcalcnegate(BAT *b, BAT *s)
oid x, bhseqbase = b->hseqbase;
struct canditer ci;
+ size_t counter = 0;
+ lng timeoffset = 0;
+ QryCtx *qry_ctx = MT_thread_get_qry_ctx();
+ if (qry_ctx != NULL) {
+ timeoffset = (qry_ctx->starttime && qry_ctx->querytimeout) ?
(qry_ctx->starttime + qry_ctx->querytimeout) : 0;
+ }
+
+
TRC_DEBUG_IF(ALGO) t0 = GDKusec();
BATcheck(b, NULL);
@@ -589,6 +618,9 @@ BATcalcnegate(BAT *b, BAT *s)
ALGOOPTBATPAR(bn), GDKusec() - t0);
return bn;
+bailout:
+ BBPunfix(bn->batCacheid);
+ return NULL;
}
gdk_return
@@ -660,6 +692,14 @@ BATcalcabsolute(BAT *b, BAT *s)
oid x, bhseqbase = b->hseqbase;
struct canditer ci;
+ size_t counter = 0;
+ lng timeoffset = 0;
+ QryCtx *qry_ctx = MT_thread_get_qry_ctx();
+ if (qry_ctx != NULL) {
+ timeoffset = (qry_ctx->starttime && qry_ctx->querytimeout) ?
(qry_ctx->starttime + qry_ctx->querytimeout) : 0;
+ }
+
+
TRC_DEBUG_IF(ALGO) t0 = GDKusec();
BATcheck(b, NULL);
@@ -719,6 +759,9 @@ BATcalcabsolute(BAT *b, BAT *s)
ALGOOPTBATPAR(bn), GDKusec() - t0);
return bn;
+bailout:
+ BBPunfix(bn->batCacheid);
+ return NULL;
}
gdk_return
@@ -792,6 +835,13 @@ BATcalciszero(BAT *b, BAT *s)
oid x, bhseqbase = b->hseqbase;
struct canditer ci;
+ size_t counter = 0;
+ lng timeoffset = 0;
+ QryCtx *qry_ctx = MT_thread_get_qry_ctx();
+ if (qry_ctx != NULL) {
+ timeoffset = (qry_ctx->starttime && qry_ctx->querytimeout) ?
(qry_ctx->starttime + qry_ctx->querytimeout) : 0;
+ }
+
TRC_DEBUG_IF(ALGO) t0 = GDKusec();
BATcheck(b, NULL);
@@ -848,6 +898,9 @@ BATcalciszero(BAT *b, BAT *s)
ALGOOPTBATPAR(bn), GDKusec() - t0);
return bn;
+bailout:
+ BBPunfix(bn->batCacheid);
+ return NULL;
}
gdk_return
@@ -922,6 +975,13 @@ BATcalcsign(BAT *b, BAT *s)
oid x, bhseqbase = b->hseqbase;
struct canditer ci;
+ size_t counter = 0;
+ lng timeoffset = 0;
+ QryCtx *qry_ctx = MT_thread_get_qry_ctx();
+ if (qry_ctx != NULL) {
+ timeoffset = (qry_ctx->starttime && qry_ctx->querytimeout) ?
(qry_ctx->starttime + qry_ctx->querytimeout) : 0;
+ }
+
TRC_DEBUG_IF(ALGO) t0 = GDKusec();
BATcheck(b, NULL);
@@ -981,6 +1041,9 @@ BATcalcsign(BAT *b, BAT *s)
ALGOOPTBATPAR(bn), GDKusec() - t0);
return bn;
+bailout:
+ BBPunfix(bn->batCacheid);
+ return NULL;
}
gdk_return
@@ -1047,6 +1110,7 @@ VARcalcsign(ValPtr ret, const ValRecord
do { \
const TYPE *restrict src = (const TYPE *) Tloc(b, 0); \
for (i = 0; i < ncand; i++) { \
+ GDK_CHECK_TIMEOUT(timeoffset, counter,
TIMEOUT_HANDLER(NULL)); \
x = canditer_next(&ci) - bhseqbase; \
dst[i] = (bit) (is_##TYPE##_nil(src[x]) ^ NOTNIL); \
} \
@@ -1064,6 +1128,13 @@ BATcalcisnil_implementation(BAT *b, BAT
BUN nils = 0;
oid bhseqbase = b->hseqbase;
+ size_t counter = 0;
+ lng timeoffset = 0;
+ QryCtx *qry_ctx = MT_thread_get_qry_ctx();
+ if (qry_ctx != NULL) {
+ timeoffset = (qry_ctx->starttime && qry_ctx->querytimeout) ?
(qry_ctx->starttime + qry_ctx->querytimeout) : 0;
+ }
+
TRC_DEBUG_IF(ALGO) t0 = GDKusec();
BATcheck(b, NULL);
@@ -1120,6 +1191,7 @@ BATcalcisnil_implementation(BAT *b, BAT
const void *nil = ATOMnilptr(b->ttype);
for (i = 0; i < ncand; i++) {
+ GDK_CHECK_TIMEOUT(timeoffset, counter,
TIMEOUT_HANDLER(NULL));
x = canditer_next(&ci) - bhseqbase;
dst[i] = (bit) (((*atomcmp)(BUNtail(bi, x), nil) == 0)
^ notnil);
}
@@ -1184,6 +1256,8 @@ VARcalcisnotnil(ValPtr ret, const ValRec
TYPE *tb1 = Tloc(b1, 0), *tb2 = Tloc(b2, 0), *restrict tbn =
Tloc(bn, 0); \
if (ci1.tpe == cand_dense && ci2.tpe == cand_dense) { \
for (BUN i = 0; i < ncand; i++) { \
+ GDK_CHECK_TIMEOUT(timeoffset, counter,
\
+
GOTO_LABEL_TIMEOUT_HANDLER(bunins_failed)); \
oid x1 = canditer_next_dense(&ci1) -
b1hseqbase; \
oid x2 = canditer_next_dense(&ci2) -
b2hseqbase; \
TYPE p1 = tb1[x1], p2 = tb2[x2]; \
@@ -1196,6 +1270,8 @@ VARcalcisnotnil(ValPtr ret, const ValRec
} \
} else { \
for (BUN i = 0; i < ncand; i++) { \
+ GDK_CHECK_TIMEOUT(timeoffset, counter, \
+
GOTO_LABEL_TIMEOUT_HANDLER(bunins_failed)); \
oid x1 = canditer_next(&ci1) - b1hseqbase; \
oid x2 = canditer_next(&ci2) - b2hseqbase; \
TYPE p1 = tb1[x1], p2 = tb2[x2]; \
@@ -1219,6 +1295,13 @@ BATcalcmin(BAT *b1, BAT *b2, BAT *s1, BA
struct canditer ci1, ci2;
oid b1hseqbase = b1->hseqbase, b2hseqbase = b2->hseqbase;
+ size_t counter = 0;
+ lng timeoffset = 0;
+ QryCtx *qry_ctx = MT_thread_get_qry_ctx();
+ if (qry_ctx != NULL) {
+ timeoffset = (qry_ctx->starttime && qry_ctx->querytimeout) ?
(qry_ctx->starttime + qry_ctx->querytimeout) : 0;
+ }
+
TRC_DEBUG_IF(ALGO) t0 = GDKusec();
BATcheck(b1, NULL);
@@ -1271,6 +1354,8 @@ BATcalcmin(BAT *b1, BAT *b2, BAT *s1, BA
if (ATOMvarsized(b1->ttype)) {
if (ci1.tpe == cand_dense && ci2.tpe == cand_dense) {
for (BUN i = 0; i < ncand; i++) {
+ GDK_CHECK_TIMEOUT(timeoffset, counter,
+
GOTO_LABEL_TIMEOUT_HANDLER(bunins_failed));
oid x1 = canditer_next_dense(&ci1) -
b1hseqbase;
oid x2 = canditer_next_dense(&ci2) -
b2hseqbase;
const void *p1 = BUNtvar(b1i, x1);
@@ -1286,6 +1371,8 @@ BATcalcmin(BAT *b1, BAT *b2, BAT *s1, BA
}
} else {
for (BUN i = 0; i < ncand; i++) {
+ GDK_CHECK_TIMEOUT(timeoffset, counter,
+
GOTO_LABEL_TIMEOUT_HANDLER(bunins_failed));
oid x1 = canditer_next(&ci1) -
b1hseqbase;
oid x2 = canditer_next(&ci2) -
b2hseqbase;
const void *p1 = BUNtvar(b1i, x1);
@@ -1305,6 +1392,8 @@ BATcalcmin(BAT *b1, BAT *b2, BAT *s1, BA
uint16_t width = bn->twidth;
if (ci1.tpe == cand_dense && ci2.tpe == cand_dense) {
for (BUN i = 0; i < ncand; i++) {
+ GDK_CHECK_TIMEOUT(timeoffset, counter,
+
GOTO_LABEL_TIMEOUT_HANDLER(bunins_failed));
oid x1 = canditer_next_dense(&ci1) -
b1hseqbase;
oid x2 = canditer_next_dense(&ci2) -
b2hseqbase;
const void *p1 = BUNtloc(b1i, x1);
@@ -1320,6 +1409,8 @@ BATcalcmin(BAT *b1, BAT *b2, BAT *s1, BA
}
} else {
for (BUN i = 0; i < ncand; i++) {
+ GDK_CHECK_TIMEOUT(timeoffset, counter,
+
GOTO_LABEL_TIMEOUT_HANDLER(bunins_failed));
oid x1 = canditer_next(&ci1) -
b1hseqbase;
oid x2 = canditer_next(&ci2) -
b2hseqbase;
const void *p1 = BUNtloc(b1i, x1);
@@ -1371,6 +1462,8 @@ BATcalcmin(BAT *b1, BAT *b2, BAT *s1, BA
TYPE *tb1 = Tloc(b1, 0), *tb2 = Tloc(b2, 0), *restrict tbn =
Tloc(bn, 0); \
if (ci1.tpe == cand_dense && ci2.tpe == cand_dense) { \
for (BUN i = 0; i < ncand; i++) { \
+ GDK_CHECK_TIMEOUT(timeoffset, counter, \
+
GOTO_LABEL_TIMEOUT_HANDLER(bunins_failed)); \
oid x1 = canditer_next_dense(&ci1) -
b1hseqbase; \
oid x2 = canditer_next_dense(&ci2) -
b2hseqbase; \
TYPE p1 = tb1[x1], p2 = tb2[x2]; \
@@ -1387,6 +1480,8 @@ BATcalcmin(BAT *b1, BAT *b2, BAT *s1, BA
} \
} else { \
for (BUN i = 0; i < ncand; i++) { \
+ GDK_CHECK_TIMEOUT(timeoffset, counter, \
+
GOTO_LABEL_TIMEOUT_HANDLER(bunins_failed)); \
oid x1 = canditer_next(&ci1) - b1hseqbase; \
oid x2 = canditer_next(&ci2) - b2hseqbase; \
TYPE p1 = tb1[x1], p2 = tb2[x2]; \
@@ -1414,6 +1509,13 @@ BATcalcmin_no_nil(BAT *b1, BAT *b2, BAT
struct canditer ci1, ci2;
oid b1hseqbase = b1->hseqbase, b2hseqbase = b2->hseqbase;
+ size_t counter = 0;
+ lng timeoffset = 0;
+ QryCtx *qry_ctx = MT_thread_get_qry_ctx();
+ if (qry_ctx != NULL) {
+ timeoffset = (qry_ctx->starttime && qry_ctx->querytimeout) ?
(qry_ctx->starttime + qry_ctx->querytimeout) : 0;
+ }
+
TRC_DEBUG_IF(ALGO) t0 = GDKusec();
BATcheck(b1, NULL);
@@ -1466,6 +1568,8 @@ BATcalcmin_no_nil(BAT *b1, BAT *b2, BAT
if (ATOMvarsized(b1->ttype)) {
if (ci1.tpe == cand_dense && ci2.tpe == cand_dense) {
for (BUN i = 0; i < ncand; i++) {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list