Changeset: e60d6f7bfa10 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e60d6f7bfa10
Modified Files:
        gdk/gdk_calc.c
        gdk/gdk_calc_compare.h
Branch: qcancel
Log Message:

timeout gdk_calc xor, or, and, lt, <<, >>, <, <=, >=, etc


diffs (231 lines):

diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -125,6 +125,7 @@ checkbats(BAT *b1, BAT *b2, const char *
                i = j = 0;                                              \
                if (ci1->tpe == cand_dense && ci2->tpe == cand_dense) { \
                        for (k = 0; k < ncand; k++) {                   \
+                               GDK_CHECK_TIMEOUT(timeoffset, counter, 
TIMEOUT_HANDLER(BUN_NONE)); \
                                if (incr1)                              \
                                        i = canditer_next_dense(ci1) - 
candoff1; \
                                if (incr2)                              \
@@ -140,6 +141,7 @@ checkbats(BAT *b1, BAT *b2, const char *
                        }                                               \
                } else {                                                \
                        for (k = 0; k < ncand; k++) {                   \
+                               GDK_CHECK_TIMEOUT(timeoffset, counter, 
TIMEOUT_HANDLER(BUN_NONE)); \
                                if (incr1)                              \
                                        i = canditer_next(ci1) - candoff1; \
                                if (incr2)                              \
@@ -161,6 +163,7 @@ checkbats(BAT *b1, BAT *b2, const char *
                i = j = 0;                                              \
                if (ci1->tpe == cand_dense && ci2->tpe == cand_dense) { \
                        for (k = 0; k < ncand; k++) {                   \
+                               GDK_CHECK_TIMEOUT(timeoffset, counter, 
TIMEOUT_HANDLER(BUN_NONE)); \
                                if (incr1)                              \
                                        i = canditer_next_dense(ci1) - 
candoff1; \
                                if (incr2)                              \
@@ -178,6 +181,7 @@ checkbats(BAT *b1, BAT *b2, const char *
                        }                                               \
                } else {                                                \
                        for (k = 0; k < ncand; k++) {                   \
+                               GDK_CHECK_TIMEOUT(timeoffset, counter, 
TIMEOUT_HANDLER(BUN_NONE)); \
                                if (incr1)                              \
                                        i = canditer_next(ci1) - candoff1; \
                                if (incr2)                              \
@@ -203,6 +207,7 @@ checkbats(BAT *b1, BAT *b2, const char *
                i = j = 0;                                              \
                if (ci1->tpe == cand_dense && ci2->tpe == cand_dense) { \
                        for (k = 0; k < ncand; k++) {                   \
+                               GDK_CHECK_TIMEOUT(timeoffset, counter, 
TIMEOUT_HANDLER(BUN_NONE)); \
                                if (incr1)                              \
                                        i = canditer_next_dense(ci1) - 
candoff1; \
                                if (incr2)                              \
@@ -217,6 +222,7 @@ checkbats(BAT *b1, BAT *b2, const char *
                        }                                               \
                } else {                                                \
                        for (k = 0; k < ncand; k++) {                   \
+                               GDK_CHECK_TIMEOUT(timeoffset, counter, 
TIMEOUT_HANDLER(BUN_NONE)); \
                                if (incr1)                              \
                                        i = canditer_next(ci1) - candoff1; \
                                if (incr2)                              \
@@ -237,6 +243,7 @@ checkbats(BAT *b1, BAT *b2, const char *
                i = j = 0;                                              \
                if (ci1->tpe == cand_dense && ci2->tpe == cand_dense) { \
                        for (k = 0; k < ncand; k++) {                   \
+                               GDK_CHECK_TIMEOUT(timeoffset, counter, 
TIMEOUT_HANDLER(BUN_NONE)); \
                                if (incr1)                              \
                                        i = canditer_next_dense(ci1) - 
candoff1; \
                                if (incr2)                              \
@@ -247,6 +254,7 @@ checkbats(BAT *b1, BAT *b2, const char *
                        }                                               \
                } else {                                                \
                        for (k = 0; k < ncand; k++) {                   \
+                               GDK_CHECK_TIMEOUT(timeoffset, counter, 
TIMEOUT_HANDLER(BUN_NONE)); \
                                if (incr1)                              \
                                        i = canditer_next(ci1) - candoff1; \
                                if (incr2)                              \
@@ -263,6 +271,7 @@ checkbats(BAT *b1, BAT *b2, const char *
                i = j = 0;                                              \
                if (ci1->tpe == cand_dense && ci2->tpe == cand_dense) { \
                        for (k = 0; k < ncand; k++) {                   \
+                               GDK_CHECK_TIMEOUT(timeoffset, counter, 
TIMEOUT_HANDLER(BUN_NONE)); \
                                if (incr1)                              \
                                        i = canditer_next_dense(ci1) - 
candoff1; \
                                if (incr2)                              \
@@ -275,6 +284,7 @@ checkbats(BAT *b1, BAT *b2, const char *
                        }                                               \
                } else {                                                \
                        for (k = 0; k < ncand; k++) {                   \
+                               GDK_CHECK_TIMEOUT(timeoffset, counter, 
TIMEOUT_HANDLER(BUN_NONE)); \
                                if (incr1)                              \
                                        i = canditer_next(ci1) - candoff1; \
                                if (incr2)                              \
@@ -293,6 +303,7 @@ checkbats(BAT *b1, BAT *b2, const char *
                i = j = 0;                                              \
                if (ci1->tpe == cand_dense && ci2->tpe == cand_dense) { \
                        for (k = 0; k < ncand; k++) {                   \
+                               GDK_CHECK_TIMEOUT(timeoffset, counter, 
TIMEOUT_HANDLER(BUN_NONE)); \
                                if (incr1)                              \
                                        i = canditer_next_dense(ci1) - 
candoff1; \
                                if (incr2)                              \
@@ -319,6 +330,7 @@ checkbats(BAT *b1, BAT *b2, const char *
                        }                                               \
                } else {                                                \
                        for (k = 0; k < ncand; k++) {                   \
+                               GDK_CHECK_TIMEOUT(timeoffset, counter, 
TIMEOUT_HANDLER(BUN_NONE)); \
                                if (incr1)                              \
                                        i = canditer_next(ci1) - candoff1; \
                                if (incr2)                              \
@@ -12570,6 +12582,13 @@ xor_typeswitchloop(const void *lft, bool
        BUN i, j, k, ncand = ci1->ncand;
        BUN nils = 0;
 
+       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;
+       }
+
        switch (ATOMbasetype(tp)) {
        case TYPE_bte:
                if (tp == TYPE_bit) {
@@ -12781,6 +12800,13 @@ or_typeswitchloop(const void *lft, bool 
        BUN i = 0, j = 0, k, ncand = ci1->ncand;
        BUN nils = 0;
 
+       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;
+       }
+
        /* note, we don't have to check whether the result is equal to
         * NIL when using bitwise OR: there is only a single bit set in
         * NIL, which means that at least one of the operands must have
@@ -12791,6 +12817,7 @@ or_typeswitchloop(const void *lft, bool 
                if (tp == TYPE_bit) {
                        /* implement tri-Boolean algebra */
                        for (k = 0; k < ncand; k++) {
+                               GDK_CHECK_TIMEOUT(timeoffset, counter, 
TIMEOUT_HANDLER(BUN_NONE));
                                if (incr1)
                                        i = canditer_next(ci1) - candoff1;
                                if (incr2)
@@ -13009,11 +13036,19 @@ and_typeswitchloop(const void *lft, bool
        BUN i = 0, j = 0, k, ncand = ci1->ncand;
        BUN nils = 0;
 
+       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;
+       }
+
        switch (ATOMbasetype(tp)) {
        case TYPE_bte:
                if (tp == TYPE_bit) {
                        /* implement tri-Boolean algebra */
                        for (k = 0; k < ncand; k++) {
+                               GDK_CHECK_TIMEOUT(timeoffset, counter, 
TIMEOUT_HANDLER(BUN_NONE));
                                if (incr1)
                                        i = canditer_next(ci1) - candoff1;
                                if (incr2)
@@ -13246,6 +13281,13 @@ lsh_typeswitchloop(const void *lft, int 
        BUN i, j, k, ncand = ci1->ncand;
        BUN nils = 0;
 
+       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;
+       }
+
        tp1 = ATOMbasetype(tp1);
        tp2 = ATOMbasetype(tp2);
        switch (tp1) {
@@ -13590,6 +13632,13 @@ rsh_typeswitchloop(const void *lft, int 
        BUN i, j, k, ncand = ci1->ncand;
        BUN nils = 0;
 
+       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;
+       }
+
        tp1 = ATOMbasetype(tp1);
        tp2 = ATOMbasetype(tp2);
        switch (tp1) {
diff --git a/gdk/gdk_calc_compare.h b/gdk/gdk_calc_compare.h
--- a/gdk/gdk_calc_compare.h
+++ b/gdk/gdk_calc_compare.h
@@ -25,12 +25,20 @@ op_typeswitchloop(const void *lft, int t
        const void *restrict nil;
        int (*atomcmp)(const void *, const void *);
 
+       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;
+       }
+
        switch (tp1) {
        case TYPE_void: {
                assert(incr1);
                assert(tp2 == TYPE_oid || incr2); /* if void, incr2==1 */
                oid v = lft ? * (const oid *) lft : oid_nil;
                for (k = 0; k < ncand; k++) {
+                       GDK_CHECK_TIMEOUT(timeoffset, counter, 
TIMEOUT_HANDLER(BUN_NONE));
                        TPE res;
                        i = canditer_next(ci1) - candoff1;
                        if (incr2)
@@ -631,6 +639,7 @@ op_typeswitchloop(const void *lft, int t
                if (tp2 == TYPE_void) {
                        oid v = * (const oid *) rgt;
                        for (k = 0; k < ncand; k++) {
+                               GDK_CHECK_TIMEOUT(timeoffset, counter, 
TIMEOUT_HANDLER(BUN_NONE));
                                if (incr1)
                                        i = canditer_next(ci1) - candoff1;
                                j = canditer_next(ci2) - candoff2;
@@ -677,6 +686,7 @@ op_typeswitchloop(const void *lft, int t
                if (tp1 != tp2)
                        goto unsupported;
                for (k = 0; k < ncand; k++) {
+                       GDK_CHECK_TIMEOUT(timeoffset, counter, 
TIMEOUT_HANDLER(BUN_NONE));
                        if (incr1)
                                i = canditer_next(ci1) - candoff1;
                        if (incr2)
@@ -728,6 +738,7 @@ op_typeswitchloop(const void *lft, int t
                        goto dbldbl;
                nil = ATOMnilptr(tp1);
                for (k = 0; k < ncand; k++) {
+                       GDK_CHECK_TIMEOUT(timeoffset, counter, 
TIMEOUT_HANDLER(BUN_NONE));
                        if (incr1)
                                i = canditer_next(ci1) - candoff1;
                        if (incr2)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to