Changeset: 7cf8b31a6c43 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7cf8b31a6c43
Modified Files:
        sql/backends/monet5/gsl/gsl.c
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql_bat2time.c
        sql/backends/monet5/sql_cast.c
        sql/backends/monet5/sql_cast_impl_down_from_flt.h
        sql/backends/monet5/sql_cast_impl_down_from_int.h
        sql/backends/monet5/sql_cast_impl_up_to_flt.h
        sql/backends/monet5/sql_cast_impl_up_to_int.h
        sql/backends/monet5/sql_round_impl.h
Branch: default
Log Message:

Avoid use of BUNins, use BUNappend and maybe replace head column (legacy).


diffs (truncated from 954 to 300 lines):

diff --git a/sql/backends/monet5/gsl/gsl.c b/sql/backends/monet5/gsl/gsl.c
--- a/sql/backends/monet5/gsl/gsl.c
+++ b/sql/backends/monet5/gsl/gsl.c
@@ -63,7 +63,7 @@ gsl_bat_chisqprob_cst(bat * retval, bat 
                throw(MAL, "chisqprob", "Cannot access descriptor");
        }
        bi = bat_iterator(b);
-       bn = BATnew(b->htype, TYPE_dbl, BATcount(b), TRANSIENT);
+       bn = BATnew(TYPE_void, TYPE_dbl, BATcount(b), TRANSIENT);
        if (bn == NULL){
                BBPunfix(b->batCacheid);
                throw(MAL, "gsl.chisqprob", MAL_MALLOC_FAIL);
@@ -74,7 +74,15 @@ gsl_bat_chisqprob_cst(bat * retval, bat 
                if ((d == dbl_nil) || (d < 0))
                        throw(MAL, "gsl.chi2prob", "Wrong value for chi2");
                r = gsl_cdf_chisq_Q(d, datapoints);
-               BUNins(bn, BUNhead(bi,p), &r, FALSE);
+               BUNappend(bn, &r, FALSE);
+       }
+       if (!BAThdense(b)) {
+               /* legacy */
+               BAT *b2 = VIEWcreate(b, bn);
+               BBPunfix(bn->batCacheid);
+               bn = b2;
+       } else {
+               BATseqbase(bn, b->hseqbase);
        }
        *retval = bn->batCacheid;
        BBPkeepref(bn->batCacheid);
@@ -100,7 +108,7 @@ gsl_cst_chisqprob_bat(bat * retval, dbl 
        if (chi2 < 0)
                throw(MAL, "gsl.chi2prob", "Wrong value for chi2");
        bi = bat_iterator(b);
-       bn = BATnew(b->htype, TYPE_dbl, BATcount(b), TRANSIENT);
+       bn = BATnew(TYPE_void, TYPE_dbl, BATcount(b), TRANSIENT);
        if( bn == NULL) {
                BBPunfix(b->batCacheid);
                throw(MAL, "gsl.chisqprob", MAL_MALLOC_FAIL);
@@ -112,7 +120,15 @@ gsl_cst_chisqprob_bat(bat * retval, dbl 
                if ((datapoints == dbl_nil) || (datapoints < 0))
                        throw(MAL, "gsl.chi2prob", "Wrong value for 
datapoints");
                r = gsl_cdf_chisq_Q(chi2, datapoints);
-               BUNins(bn, BUNhead(bi,p), &r, FALSE);
+               BUNappend(bn, &r, FALSE);
+       }
+       if (!BAThdense(b)) {
+               /* legacy */
+               BAT *b2 = VIEWcreate(b, bn);
+               BBPunfix(bn->batCacheid);
+               bn = b2;
+       } else {
+               BATseqbase(bn, b->hseqbase);
        }
        BBPkeepref( *retval = bn->batCacheid);
        BBPunfix(b->batCacheid);
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -1575,7 +1575,7 @@ mvc_bat_next_value(Client cntxt, MalBlkP
        if ((b = BATdescriptor(*sid)) == NULL)
                throw(SQL, "sql.next_value", "Cannot access descriptor");
 
-       r = BATnew(b->htype, TYPE_lng, BATcount(b), TRANSIENT);
+       r = BATnew(TYPE_void, TYPE_lng, BATcount(b), TRANSIENT);
        if (!r) {
                BBPunfix(b->batCacheid);
                throw(SQL, "sql.next_value", "Cannot create bat");
@@ -1611,7 +1611,15 @@ mvc_bat_next_value(Client cntxt, MalBlkP
                        seqbulk_destroy(sb);
                        throw(SQL, "sql.next_value", "error");
                }
-               BUNins(r, BUNhead(bi, p), &l, FALSE);
+               BUNappend(r, &l, FALSE);
+       }
+       if (!BAThdense(b)) {
+               /* legacy */
+               BAT *b2 = VIEWcreate(b, r);
+               BBPunfix(r->batCacheid);
+               r = b2;
+       } else {
+               BATseqbase(r, b->hseqbase);
        }
        if (sb)
                seqbulk_destroy(sb);
@@ -3901,7 +3909,7 @@ SQLbat_alpha_cst(bat *res, const bat *de
                throw(SQL, "alpha", "Cannot access descriptor");
        }
        bi = bat_iterator(b);
-       bn = BATnew(b->htype, TYPE_dbl, BATcount(b), TRANSIENT);
+       bn = BATnew(TYPE_void, TYPE_dbl, BATcount(b), TRANSIENT);
        if (bn == NULL) {
                BBPunfix(b->batCacheid);
                throw(SQL, "sql.alpha", MAL_MALLOC_FAIL);
@@ -3919,7 +3927,15 @@ SQLbat_alpha_cst(bat *res, const bat *de
                        c2 = cos(radians(d + *theta));
                        r = degrees(fabs(atan(s / sqrt(fabs(c1 * c2)))));
                }
-               BUNins(bn, BUNhead(bi, p), &r, FALSE);
+               BUNappend(bn, &r, FALSE);
+       }
+       if (!BAThdense(b)) {
+               /* legacy */
+               BAT *b2 = VIEWcreate(b, bn);
+               BBPunfix(bn->batCacheid);
+               bn = b2;
+       } else {
+               BATseqbase(bn, b->hseqbase);
        }
        *res = bn->batCacheid;
        BBPkeepref(bn->batCacheid);
@@ -3940,7 +3956,7 @@ SQLcst_alpha_bat(bat *res, const dbl *de
                throw(SQL, "alpha", "Cannot access descriptor");
        }
        bi = bat_iterator(b);
-       bn = BATnew(b->htype, TYPE_dbl, BATcount(b), TRANSIENT);
+       bn = BATnew(TYPE_void, TYPE_dbl, BATcount(b), TRANSIENT);
        if (bn == NULL) {
                BBPunfix(b->batCacheid);
                throw(SQL, "sql.alpha", MAL_MALLOC_FAIL);
@@ -3960,7 +3976,15 @@ SQLcst_alpha_bat(bat *res, const dbl *de
                        c2 = cos(radians(d + *theta));
                        r = degrees(fabs(atan(s / sqrt(fabs(c1 * c2)))));
                }
-               BUNins(bn, BUNhead(bi, p), &r, FALSE);
+               BUNappend(bn, &r, FALSE);
+       }
+       if (!BAThdense(b)) {
+               /* legacy */
+               BAT *b2 = VIEWcreate(b, bn);
+               BBPunfix(bn->batCacheid);
+               bn = b2;
+       } else {
+               BATseqbase(bn, b->hseqbase);
        }
        BBPkeepref(*res = bn->batCacheid);
        BBPunfix(b->batCacheid);
diff --git a/sql/backends/monet5/sql_bat2time.c 
b/sql/backends/monet5/sql_bat2time.c
--- a/sql/backends/monet5/sql_bat2time.c
+++ b/sql/backends/monet5/sql_bat2time.c
@@ -36,7 +36,7 @@ batstr_2time_timestamptz(bat *res, const
                throw(SQL, "batcalc.str_2time_timestamp", "Cannot access 
descriptor");
        }
        bi = bat_iterator(b);
-       dst = BATnew(b->htype, TYPE_timestamp, BATcount(b), TRANSIENT);
+       dst = BATnew(TYPE_void, TYPE_timestamp, BATcount(b), TRANSIENT);
        if (dst == NULL) {
                BBPunfix(b->batCacheid);
                throw(SQL, "sql.timestamp", MAL_MALLOC_FAIL);
@@ -49,9 +49,20 @@ batstr_2time_timestamptz(bat *res, const
                        timestamp r;
                } u;
                msg = str_2time_timestamptz(&u.r, &v, digits, tz);
-               if (msg)
-                       break;
-               BUNins(dst, BUNhead(bi, p), &u.r, FALSE);
+               if (msg) {
+                       BBPunfix(dst->batCacheid);
+                       BBPunfix(b->batCacheid);
+                       return msg;
+               }
+               BUNappend(dst, &u.r, FALSE);
+       }
+       if (!BAThdense(b)) {
+               /* legacy */
+               BAT *b2 = VIEWcreate(b, dst);
+               BBPunfix(dst->batCacheid);
+               dst = b2;
+       } else {
+               BATseqbase(dst, b->hseqbase);
        }
        BBPkeepref(*res = dst->batCacheid);
        BBPunfix(b->batCacheid);
@@ -77,7 +88,7 @@ battimestamp_2time_timestamp(bat *res, c
                throw(SQL, "batcalc.timestamp_2time_timestamp", "Cannot access 
descriptor");
        }
        bi = bat_iterator(b);
-       dst = BATnew(b->htype, TYPE_timestamp, BATcount(b), TRANSIENT);
+       dst = BATnew(TYPE_void, TYPE_timestamp, BATcount(b), TRANSIENT);
        if (dst == NULL) {
                BBPunfix(b->batCacheid);
                throw(SQL, "sql.timestamp", MAL_MALLOC_FAIL);
@@ -90,9 +101,20 @@ battimestamp_2time_timestamp(bat *res, c
                        timestamp r;
                } u;
                msg = timestamp_2time_timestamp(&u.r, v, digits);
-               if (msg)
-                       break;
-               BUNins(dst, BUNhead(bi, p), &u.r, FALSE);
+               if (msg) {
+                       BBPunfix(dst->batCacheid);
+                       BBPunfix(b->batCacheid);
+                       return msg;
+               }
+               BUNappend(dst, &u.r, FALSE);
+       }
+       if (!BAThdense(b)) {
+               /* legacy */
+               BAT *b2 = VIEWcreate(b, dst);
+               BBPunfix(dst->batCacheid);
+               dst = b2;
+       } else {
+               BATseqbase(dst, b->hseqbase);
        }
        BBPkeepref(*res = dst->batCacheid);
        BBPunfix(b->batCacheid);
@@ -111,7 +133,7 @@ batnil_2time_timestamp(bat *res, const b
                throw(SQL, "batcalc.nil_2time_timestamp", "Cannot access 
descriptor");
        }
        bi = bat_iterator(b);
-       dst = BATnew(b->htype, TYPE_timestamp, BATcount(b), TRANSIENT);
+       dst = BATnew(TYPE_void, TYPE_timestamp, BATcount(b), TRANSIENT);
        if (dst == NULL) {
                BBPunfix(b->batCacheid);
                throw(SQL, "sql.timestamp", MAL_MALLOC_FAIL);
@@ -124,9 +146,20 @@ batnil_2time_timestamp(bat *res, const b
                        timestamp r;
                } u;
                msg = nil_2time_timestamp(&u.r, v, digits);
-               if (msg)
-                       break;
-               BUNins(dst, BUNhead(bi, p), &u.r, FALSE);
+               if (msg) {
+                       BBPunfix(dst->batCacheid);
+                       BBPunfix(b->batCacheid);
+                       return msg;
+               }
+               BUNappend(dst, &u.r, FALSE);
+       }
+       if (!BAThdense(b)) {
+               /* legacy */
+               BAT *b2 = VIEWcreate(b, dst);
+               BBPunfix(dst->batCacheid);
+               dst = b2;
+       } else {
+               BATseqbase(dst, b->hseqbase);
        }
        BBPkeepref(*res = dst->batCacheid);
        BBPunfix(b->batCacheid);
@@ -145,7 +178,7 @@ batstr_2time_daytimetz(bat *res, const b
                throw(SQL, "batcalc.str_2time_daytime", "Cannot access 
descriptor");
        }
        bi = bat_iterator(b);
-       dst = BATnew(b->htype, TYPE_daytime, BATcount(b), TRANSIENT);
+       dst = BATnew(TYPE_void, TYPE_daytime, BATcount(b), TRANSIENT);
        if (dst == NULL) {
                BBPunfix(b->batCacheid);
                throw(SQL, "sql.daytime", MAL_MALLOC_FAIL);
@@ -158,9 +191,20 @@ batstr_2time_daytimetz(bat *res, const b
                        daytime r;
                } u;
                msg = str_2time_daytimetz(&u.r, &v, digits, tz);
-               if (msg)
-                       break;
-               BUNins(dst, BUNhead(bi, p), &u.r, FALSE);
+               if (msg) {
+                       BBPunfix(dst->batCacheid);
+                       BBPunfix(b->batCacheid);
+                       return msg;
+               }
+               BUNappend(dst, &u.r, FALSE);
+       }
+       if (!BAThdense(b)) {
+               /* legacy */
+               BAT *b2 = VIEWcreate(b, dst);
+               BBPunfix(dst->batCacheid);
+               dst = b2;
+       } else {
+               BATseqbase(dst, b->hseqbase);
        }
        BBPkeepref(*res = dst->batCacheid);
        BBPunfix(b->batCacheid);
@@ -186,7 +230,7 @@ batdaytime_2time_daytime(bat *res, const
                throw(SQL, "batcalc.daytime_2time_daytime", "Cannot access 
descriptor");
        }
        bi = bat_iterator(b);
-       dst = BATnew(b->htype, TYPE_daytime, BATcount(b), TRANSIENT);
+       dst = BATnew(TYPE_void, TYPE_daytime, BATcount(b), TRANSIENT);
        if (dst == NULL) {
                BBPunfix(b->batCacheid);
                throw(SQL, "sql.daytime", MAL_MALLOC_FAIL);
@@ -199,9 +243,20 @@ batdaytime_2time_daytime(bat *res, const
                        daytime r;
                } u;
                msg = daytime_2time_daytime(&u.r, v, digits);
-               if (msg)
-                       break;
-               BUNins(dst, BUNhead(bi, p), &u.r, FALSE);
+               if (msg) {
+                       BBPunfix(dst->batCacheid);
+                       BBPunfix(b->batCacheid);
+                       return msg;
+               }
+               BUNappend(dst, &u.r, FALSE);
+       }
+       if (!BAThdense(b)) {
+               /* legacy */
+               BAT *b2 = VIEWcreate(b, dst);
+               BBPunfix(dst->batCacheid);
+               dst = b2;
+       } else {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to