Changeset: 3a0b127f84e3 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3a0b127f84e3 Modified Files: clients/Tests/exports.stable.out gdk/gdk_time.c gdk/gdk_time.h monetdb5/modules/atoms/mtime.c monetdb5/modules/atoms/mtime.mal monetdb5/modules/mal/batmtime.mal Branch: default Log Message:
Added missing bulk implementations for some mtime module functions. I have to install an older version of the liblas library to approve the MAL exports :( diffs (192 lines): diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -453,6 +453,7 @@ int date_year(date dt) __attribute__((__ daytime daytime_add_usec(daytime tm, lng usec) __attribute__((__const__)); daytime daytime_add_usec_modulo(daytime tm, lng usec) __attribute__((__const__)); daytime daytime_create(int hour, int minute, int second, int usec) __attribute__((__const__)); +lng daytime_diff(daytime d1, daytime d2) __attribute__((__const__)); ssize_t daytime_fromstr(const char *buf, size_t *len, daytime **d, bool external); int daytime_hour(daytime tm) __attribute__((__const__)); int daytime_min(daytime tm) __attribute__((__const__)); @@ -1518,15 +1519,18 @@ str MTIMEdate_extract_century(int *ret, str MTIMEdate_extract_century_bulk(bat *ret, const bat *bid); str MTIMEdate_extract_day(int *ret, const date *src); str MTIMEdate_extract_day_bulk(bat *ret, const bat *bid); -str MTIMEdate_extract_dayofweek(int *ret, const date *d); -str MTIMEdate_extract_dayofyear(int *ret, const date *d); +str MTIMEdate_extract_dayofweek(int *ret, const date *src); +str MTIMEdate_extract_dayofweek_bulk(bat *ret, const bat *bid); +str MTIMEdate_extract_dayofyear(int *ret, const date *src); +str MTIMEdate_extract_dayofyear_bulk(bat *ret, const bat *bid); str MTIMEdate_extract_decade(int *ret, const date *src); str MTIMEdate_extract_decade_bulk(bat *ret, const bat *bid); str MTIMEdate_extract_month(int *ret, const date *src); str MTIMEdate_extract_month_bulk(bat *ret, const bat *bid); str MTIMEdate_extract_quarter(int *ret, const date *src); str MTIMEdate_extract_quarter_bulk(bat *ret, const bat *bid); -str MTIMEdate_extract_weekofyear(int *ret, const date *d); +str MTIMEdate_extract_weekofyear(int *ret, const date *src); +str MTIMEdate_extract_weekofyear_bulk(bat *ret, const bat *bid); str MTIMEdate_extract_year(int *ret, const date *src); str MTIMEdate_extract_year_bulk(bat *ret, const bat *bid); str MTIMEdate_fromstr(date *ret, const char *const *s); @@ -1534,7 +1538,8 @@ str MTIMEdate_sub_msec_interval(date *re str MTIMEdate_submonths(date *ret, const date *d, const int *m); str MTIMEdate_to_str(str *ret, const date *d, const char *const *format); str MTIMEdaytime_daytime(daytime *dst, const daytime *src); -str MTIMEdaytime_diff_msec(lng *ret, const daytime *t1, const daytime *t2); +str MTIMEdaytime_diff_msec(lng *ret, const daytime *v1, const daytime *v2); +str MTIMEdaytime_diff_msec_bulk(bat *ret, const bat *bid1, const bat *bid2); str MTIMEdaytime_extract_hours(int *ret, const daytime *src); str MTIMEdaytime_extract_hours_bulk(bat *ret, const bat *bid); str MTIMEdaytime_extract_minutes(int *ret, const daytime *src); diff --git a/gdk/gdk_time.c b/gdk/gdk_time.c --- a/gdk/gdk_time.c +++ b/gdk/gdk_time.c @@ -266,6 +266,15 @@ daytime_create(int hour, int min, int se return istime(hour, min, sec, usec) ? mkdaytime(hour, min, sec, usec) : daytime_nil; } +/* return the difference in milliseconds between the two daytimes */ +lng +daytime_diff(daytime d1, daytime d2) +{ + if (is_daytime_nil(d1) || is_daytime_nil(d2)) + return lng_nil; + return (d1 - d2) / 1000; +} + int daytime_hour(daytime tm) { diff --git a/gdk/gdk_time.h b/gdk/gdk_time.h --- a/gdk/gdk_time.h +++ b/gdk/gdk_time.h @@ -59,6 +59,8 @@ gdk_export int date_day(date dt) gdk_export daytime daytime_create(int hour, int minute, int second, int usec) __attribute__((__const__)); +gdk_export lng daytime_diff(daytime d1, daytime d2) + __attribute__((__const__)); gdk_export daytime daytime_add_usec(daytime tm, lng usec) __attribute__((__const__)); #define daytime_add_sec(t, s) daytime_add_usec(t, (s)*LL_CONSTANT(1000000)) diff --git a/monetdb5/modules/atoms/mtime.c b/monetdb5/modules/atoms/mtime.c --- a/monetdb5/modules/atoms/mtime.c +++ b/monetdb5/modules/atoms/mtime.c @@ -50,12 +50,8 @@ mal_export str MTIMEtimestamp_sub_month_ mal_export str MTIMEtimestamp_add_month_interval(timestamp *ret, const timestamp *t, const int *m); mal_export str MTIMEtime_sub_msec_interval(daytime *ret, const daytime *t, const lng *ms); mal_export str MTIMEtime_add_msec_interval(daytime *ret, const daytime *t, const lng *ms); -mal_export str MTIMEdaytime_diff_msec(lng *ret, const daytime *t1, const daytime *t2); mal_export str MTIMEdate_submonths(date *ret, const date *d, const int *m); mal_export str MTIMEdate_addmonths(date *ret, const date *d, const int *m); -mal_export str MTIMEdate_extract_dayofyear(int *ret, const date *d); -mal_export str MTIMEdate_extract_weekofyear(int *ret, const date *d); -mal_export str MTIMEdate_extract_dayofweek(int *ret, const date *d); mal_export str MTIMEtimestamp_century(int *ret, const timestamp *t); mal_export str MTIMEtimestamp_decade(int *ret, const timestamp *t); mal_export str MTIMEtimestamp_year(int *ret, const timestamp *t); @@ -209,6 +205,7 @@ NAMEBULK(bat *ret, const bat *bid1, cons } func2(MTIMEdate_diff, MTIMEdate_diff_bulk, "diff", date, date, int, date_diff) +func2(MTIMEdaytime_diff_msec, MTIMEdaytime_diff_msec_bulk, "diff", daytime, daytime, lng, daytime_diff) #define func2chk(NAME, NAMEBULK, MALFUNC, INTYPE1, INTYPE2, OUTTYPE, FUNC) \ mal_export str NAME(OUTTYPE *ret, const INTYPE1 *v1, const INTYPE2 *v2); \ @@ -370,16 +367,6 @@ MTIMEtime_add_msec_interval(daytime *ret } str -MTIMEdaytime_diff_msec(lng *ret, const daytime *t1, const daytime *t2) -{ - if (is_daytime_nil(*t1) || is_daytime_nil(*t2)) - *ret = lng_nil; - else - *ret = (*t1 - *t2) / 1000; - return MAL_SUCCEED; -} - -str MTIMEdate_submonths(date *ret, const date *d, const int *m) { if (is_date_nil(*d) || is_int_nil(*m)) @@ -413,31 +400,13 @@ func1(MTIMEdate_extract_year, MTIMEdate_ func1(MTIMEdate_extract_quarter, MTIMEdate_extract_quarter_bulk, "quarter", date, int, date_quarter, SETFLAGS) func1(MTIMEdate_extract_month, MTIMEdate_extract_month_bulk, "month", date, int, date_month, SETFLAGS) func1(MTIMEdate_extract_day, MTIMEdate_extract_day_bulk, "day", date, int, date_day, SETFLAGS) +func1(MTIMEdate_extract_dayofyear, MTIMEdate_extract_dayofyear_bulk, "dayofyear", date, int, date_dayofyear, SETFLAGS) +func1(MTIMEdate_extract_weekofyear, MTIMEdate_extract_weekofyear_bulk, "weekofyear", date, int, date_weekofyear, SETFLAGS) +func1(MTIMEdate_extract_dayofweek, MTIMEdate_extract_dayofweek_bulk, "dayofweek", date, int, date_dayofweek, SETFLAGS) func1(MTIMEdaytime_extract_hours, MTIMEdaytime_extract_hours_bulk, "hours", daytime, int, daytime_hour, COPYFLAGS) func1(MTIMEdaytime_extract_minutes, MTIMEdaytime_extract_minutes_bulk, "minutes", daytime, int, daytime_min, SETFLAGS) func1(MTIMEdaytime_extract_sql_seconds, MTIMEdaytime_extract_sql_seconds_bulk, "seconds", daytime, int, daytime_sec_usec, SETFLAGS) -str -MTIMEdate_extract_dayofyear(int *ret, const date *d) -{ - *ret = date_dayofyear(*d); - return MAL_SUCCEED; -} - -str -MTIMEdate_extract_weekofyear(int *ret, const date *d) -{ - *ret = date_weekofyear(*d); - return MAL_SUCCEED; -} - -str -MTIMEdate_extract_dayofweek(int *ret, const date *d) -{ - *ret = date_dayofweek(*d); - return MAL_SUCCEED; -} - static inline lng TSDIFF(timestamp t1, timestamp t2) { diff --git a/monetdb5/modules/atoms/mtime.mal b/monetdb5/modules/atoms/mtime.mal --- a/monetdb5/modules/atoms/mtime.mal +++ b/monetdb5/modules/atoms/mtime.mal @@ -388,9 +388,15 @@ command dayofyear(d:date) :int address MTIMEdate_extract_dayofyear comment "Returns N where d is the Nth day of the year (january 1 returns 1)"; +command batmtime.dayofyear(d:bat[:date]):bat[:int] +address MTIMEdate_extract_dayofyear_bulk; + command weekofyear(d:date) :int address MTIMEdate_extract_weekofyear comment "Returns the week number in the year."; +command batmtime.weekofyear(d:bat[:date]):bat[:int] +address MTIMEdate_extract_weekofyear_bulk; + # command week(d:date) :int # address MTIMEdate_extract_weekofyear # comment "Returns the week number in the year."; @@ -398,6 +404,8 @@ command dayofweek(d:date) :int address MTIMEdate_extract_dayofweek comment "Returns the current day of the week where 1=monday, .., 7=sunday"; +command batmtime.dayofweek(d:bat[:date]):bat[:int] +address MTIMEdate_extract_dayofweek_bulk; # command add(v:timestamp, msecs:lng) :timestamp # address MTIMEtimestamp_add diff --git a/monetdb5/modules/mal/batmtime.mal b/monetdb5/modules/mal/batmtime.mal --- a/monetdb5/modules/mal/batmtime.mal +++ b/monetdb5/modules/mal/batmtime.mal @@ -470,6 +470,10 @@ command diff(b1:bat[:date],b2:bat[:date] address MTIMEdate_diff_bulk comment "Difference of two sets of date."; +command diff(b1:bat[:daytime],b2:bat[:daytime]) :bat[:lng] +address MTIMEdaytime_diff_msec_bulk +comment "Difference of two sets of daytime."; + command diff(b1:bat[:timestamp],b2:bat[:timestamp]) :bat[:lng] address MTIMEtimestamp_diff_msec_bulk comment "Difference of two sets of timestamp."; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list