Changeset: 7246d7d75c53 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7246d7d75c53
Modified Files:
        sql/backends/monet5/sql.mal
        sql/backends/monet5/sql_cast.h
        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
Branch: Oct2014
Log Message:

Added missing MAL interface, removed unused C functions.


diffs (truncated from 427 to 300 lines):

diff --git a/sql/backends/monet5/sql.mal b/sql/backends/monet5/sql.mal
--- a/sql/backends/monet5/sql.mal
+++ b/sql/backends/monet5/sql.mal
@@ -624,6 +624,24 @@ command calc.second_interval( sc:int, v:
 address int_dec2second_interval
 comment "cast int decimal to a second_interval";
 
+command sql.dec_round( v:wrd, r:wrd ) :wrd 
+address wrd_dec_round_wrap
+comment "round off the value v to nearests multiple of r";
+command batsql.dec_round( v:bat[:oid,:wrd], r:wrd ) :bat[:oid,:wrd] 
+address wrd_bat_dec_round_wrap
+comment "round off the value v to nearests multiple of r";
+
+command sql.round( v:wrd, d:int, s:int, r:bte) :wrd
+address wrd_round_wrap
+comment "round off the decimal v(d,s) to r digits behind the dot (if r < 0, 
before the dot)";
+command batsql.round( v:bat[:oid,:wrd], d:int, s:int, r:bte) :bat[:oid,:wrd]
+address wrd_bat_round_wrap
+comment "round off the decimal v(d,s) to r digits behind the dot (if r < 0, 
before the dot)";
+
+command calc.second_interval( sc:int, v:wrd, ek:int, sk:int ) :lng
+address wrd_dec2second_interval
+comment "cast wrd decimal to a second_interval";
+
 command sql.dec_round( v:lng, r:lng ) :lng 
 address lng_dec_round_wrap
 comment "round off the value v to nearests multiple of r";
diff --git a/sql/backends/monet5/sql_cast.h b/sql/backends/monet5/sql_cast.h
--- a/sql/backends/monet5/sql_cast.h
+++ b/sql/backends/monet5/sql_cast.h
@@ -22,8 +22,6 @@
  */
 
 #define CAST_INTEGER_2_NUMERIC_2(T1,T2)                                        
\
-sql5_export str T1##_2_##T2(T2 *res, const T1 *v);                     \
-sql5_export str bat##T1##_2_##T2(bat *res, const bat *v);              \
 sql5_export str T1##_dec2_##T2(T2 *res, const int *s1, const T1 *v);   \
 sql5_export str bat##T1##_dec2_##T2(bat *res, const int *s1, const bat *v); \
 sql5_export str T1##_dec2dec_##T2(T2 *res, const int *S1, const T1 *v, const 
int *d2, const int *S2); \
@@ -48,8 +46,6 @@ CAST_INTEGER_2_NUMERIC_1(lng);
 
 
 #define CAST_FLOATINGPOINT_2_INTEGER_2(T1,T2)                          \
-sql5_export str T1##_2_##T2(T2 *res, const T1 *v);                     \
-sql5_export str bat##T1##_2_##T2(bat *res, const bat *v);              \
 sql5_export str T1##_num2dec_##T2(T2 *res, const T1 *v, const int *d2, const 
int *s2); \
 sql5_export str bat##T1##_num2dec_##T2(bat *res, const bat *v, const int *d2, 
const int *s2)
 
diff --git a/sql/backends/monet5/sql_cast_impl_down_from_flt.h 
b/sql/backends/monet5/sql_cast_impl_down_from_flt.h
--- a/sql/backends/monet5/sql_cast_impl_down_from_flt.h
+++ b/sql/backends/monet5/sql_cast_impl_down_from_flt.h
@@ -39,99 +39,6 @@
 #define FUN(a,b,c,d) CONCAT_4(a,b,c,d)
 
 
-str
-FUN(,TP1,_2_,TP2) (TP2 *res, const TP1 *v)
-{
-       dbl val = *v;
-
-       /* shortcut nil */
-       if (*v == NIL(TP1)) {
-               *res = NIL(TP2);
-               return (MAL_SUCCEED);
-       }
-
-       /* see if the number fits in the data type */
-       if ((dbl) (TP2) val > (dbl) GDKmin(TP2) && val > (dbl) GDKmin(TP2) && 
val <= (dbl) GDKmax(TP2)) {
-               *res = (TP2) val;
-               return (MAL_SUCCEED);
-       } else {
-               throw(SQL, "convert", "22003!value (" "%f" ") exceeds limits of 
type "STRNG(TP2), val);
-       }
-}
-
-str
-FUN(bat,TP1,_2_,TP2) (int *res, const int *bid)
-{
-       BAT *b, *bn;
-       TP1 *p, *q;
-       char *msg = NULL;
-       TP2 *o;
-       dbl val;
-
-       if ((b = BATdescriptor(*bid)) == NULL) {
-               throw(SQL, "batcalc."STRNG(FUN(,TP1,_2_,TP2)), "Cannot access 
descriptor");
-       }
-       bn = BATnew(TYPE_void, TPE(TP2), BATcount(b), TRANSIENT);
-       if (bn == NULL) {
-               BBPreleaseref(b->batCacheid);
-               throw(SQL, "sql."STRNG(FUN(,TP1,_2_,TP2)), MAL_MALLOC_FAIL);
-       }
-       BATseqbase(bn, b->hseqbase);
-       bn->H->nonil = 1;
-       bn->T->nonil = 1;
-       o = (TP2 *) Tloc(bn, BUNfirst(bn));
-       p = (TP1 *) Tloc(b, BUNfirst(b));
-       q = (TP1 *) Tloc(b, BUNlast(b));
-       if (b->T->nonil) {
-               for (; p < q; p++, o++) {
-                       val = *p;
-                       /* see if the number fits in the data type */
-                       if ((dbl) (TP2) val > (dbl) GDKmin(TP2) && val > (dbl) 
GDKmin(TP2) && val <= (dbl) GDKmax(TP2)) {
-                               *o = (TP2) val;
-                       } else {
-                               msg = createException(SQL, "convert", 
"22003!value (" "%f" ") exceeds limits of type "STRNG(TP2), val);
-                               break;
-                       }
-               }
-       } else {
-               for (; p < q; p++, o++) {
-                       if (*p == NIL(TP1)) {
-                               *o = NIL(TP2);
-                               bn->T->nonil = FALSE;
-                       } else {
-                               val = *p;
-                               /* see if the number fits in the data type */
-                               if ((dbl) (TP2) val > (dbl) GDKmin(TP2) && val 
> (dbl) GDKmin(TP2) && val <= (dbl) GDKmax(TP2)) {
-                                       *o = (TP2) val;
-                               } else {
-                                       msg = createException(SQL, "convert", 
"22003!value (" "%f" ") exceeds limits of type "STRNG(TP2), val);
-                                       break;
-                               }
-                       }
-               }
-       }
-       BATsetcount(bn, BATcount(b));
-       bn->hrevsorted = bn->batCount <= 1;
-       bn->tsorted = 0;
-       bn->trevsorted = 0;
-       BATkey(BATmirror(bn), FALSE);
-
-       if (!(bn->batDirty & 2))
-               bn = BATsetaccess(bn, BAT_READ);
-
-       if (b->htype != bn->htype) {
-               BAT *r = VIEWcreate(b, bn);
-
-               BBPkeepref(*res = r->batCacheid);
-               BBPreleaseref(bn->batCacheid);
-               BBPreleaseref(b->batCacheid);
-               return msg;
-       }
-       BBPkeepref(*res = bn->batCacheid);
-       BBPreleaseref(b->batCacheid);
-       return msg;
-}
-
 /* when casting a floating point to an decimal we like to preserve the 
  * precision.  This means we first scale the float before converting.
 */
diff --git a/sql/backends/monet5/sql_cast_impl_down_from_int.h 
b/sql/backends/monet5/sql_cast_impl_down_from_int.h
--- a/sql/backends/monet5/sql_cast_impl_down_from_int.h
+++ b/sql/backends/monet5/sql_cast_impl_down_from_int.h
@@ -36,111 +36,6 @@
 
 
 str
-FUN(,TP1,_2_,TP2) (TP2 *res, const TP1 *v)
-{
-       lng val = *v;
-
-       /* shortcut nil */
-       if (*v == NIL(TP1)) {
-               *res = NIL(TP2);
-               return (MAL_SUCCEED);
-       }
-
-       /* see if the number fits in the data type */
-       if (val > (lng) GDKmin(TP2)
-#if TPE(TP2) != TYPE_wrd || SIZEOF_LNG != SIZEOF_WRD
-           && val <= (lng) GDKmax(TP2)
-#endif
-               ) {
-               *res = (TP2) val;
-               return (MAL_SUCCEED);
-       } else {
-               throw(SQL, "convert", "22003!value (" LLFMT ") exceeds limits 
of type "STRNG(TP2), val);
-       }
-}
-
-str
-FUN(bat,TP1,_2_,TP2) (int *res, const int *bid)
-{
-       BAT *b, *bn;
-       TP1 *p, *q;
-       char *msg = NULL;
-       TP2 *o;
-       lng val;
-
-       if ((b = BATdescriptor(*bid)) == NULL) {
-               throw(SQL, "batcalc."STRNG(FUN(,TP1,_2_,TP2)), "Cannot access 
descriptor");
-       }
-       bn = BATnew(TYPE_void, TPE(TP2), BATcount(b), TRANSIENT);
-       if (bn == NULL) {
-               BBPreleaseref(b->batCacheid);
-               throw(SQL, "sql."STRNG(FUN(,TP1,_2_,TP2)), MAL_MALLOC_FAIL);
-       }
-       BATseqbase(bn, b->hseqbase);
-       bn->H->nonil = 1;
-       bn->T->nonil = 1;
-       o = (TP2 *) Tloc(bn, BUNfirst(bn));
-       p = (TP1 *) Tloc(b, BUNfirst(b));
-       q = (TP1 *) Tloc(b, BUNlast(b));
-       if (b->T->nonil) {
-               for (; p < q; p++, o++) {
-                       val = *p;
-                       /* see if the number fits in the data type */
-                       if (val > (lng) GDKmin(TP2)
-#if TPE(TP2) != TYPE_wrd || SIZEOF_LNG != SIZEOF_WRD
-                           && val <= (lng) GDKmax(TP2)
-#endif
-                               ) {
-                               *o = (TP2) val;
-                       } else {
-                               msg = createException(SQL, "convert", 
"22003!value (" LLFMT ") exceeds limits of type "STRNG(TP2), val);
-                               break;
-                       }
-               }
-       } else {
-               for (; p < q; p++, o++) {
-                       if (*p == NIL(TP1)) {
-                               *o = NIL(TP2);
-                               bn->T->nonil = FALSE;
-                       } else {
-                               val = *p;
-                               /* see if the number fits in the data type */
-                               if (val > (lng) GDKmin(TP2)
-#if TPE(TP2) != TYPE_wrd || SIZEOF_LNG != SIZEOF_WRD
-                                   && val <= (lng) GDKmax(TP2)
-#endif
-                                       ) {
-                                       *o = (TP2) val;
-                               } else {
-                                       msg = createException(SQL, "convert", 
"22003!value (" LLFMT ") exceeds limits of type "STRNG(TP2), val);
-                                       break;
-                               }
-                       }
-               }
-       }
-       BATsetcount(bn, BATcount(b));
-       bn->hrevsorted = bn->batCount <= 1;
-       bn->tsorted = 0;
-       bn->trevsorted = 0;
-       BATkey(BATmirror(bn), FALSE);
-
-       if (!(bn->batDirty & 2))
-               bn = BATsetaccess(bn, BAT_READ);
-
-       if (b->htype != bn->htype) {
-               BAT *r = VIEWcreate(b, bn);
-
-               BBPkeepref(*res = r->batCacheid);
-               BBPreleaseref(bn->batCacheid);
-               BBPreleaseref(b->batCacheid);
-               return msg;
-       }
-       BBPkeepref(*res = bn->batCacheid);
-       BBPreleaseref(b->batCacheid);
-       return msg;
-}
-
-str
 FUN(,TP1,_dec2_,TP2) (TP2 *res, const int *s1, const TP1 *v)
 {
        int scale = *s1;
diff --git a/sql/backends/monet5/sql_cast_impl_up_to_flt.h 
b/sql/backends/monet5/sql_cast_impl_up_to_flt.h
--- a/sql/backends/monet5/sql_cast_impl_up_to_flt.h
+++ b/sql/backends/monet5/sql_cast_impl_up_to_flt.h
@@ -37,76 +37,6 @@
 
 
 str
-FUN(,TP1,_2_,TP2) (TP2 *res, const TP1 *v)
-{
-       /* shortcut nil */
-       if (*v == NIL(TP1)) {
-               *res = NIL(TP2);
-               return (MAL_SUCCEED);
-       }
-
-       /* since the TP2 type is bigger than or equal to the TP1 type, it will
-          always fit */
-       *res = (TP2) *v;
-       return (MAL_SUCCEED);
-}
-
-str
-FUN(bat,TP1,_2_,TP2) (int *res, const int *bid)
-{
-       BAT *b, *bn;
-       TP1 *p, *q;
-       TP2 *o;
-
-       if ((b = BATdescriptor(*bid)) == NULL) {
-               throw(SQL, "batcalc."STRNG(FUN(,TP1,_2_,TP2)), "Cannot access 
descriptor");
-       }
-       bn = BATnew(TYPE_void, TPE(TP2), BATcount(b), TRANSIENT);
-       if (bn == NULL) {
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to