Changeset: 9a35d2a98ddf for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9a35d2a98ddf Modified Files: clients/Tests/exports.stable.out monetdb5/modules/atoms/mtime.c monetdb5/modules/atoms/mtime.mal Branch: default Log Message:
One more bulk implementation addition at mtime module. Also removed redudant declaration of batmtime.diff(val1:bat[:date], val2:bat[:date]) :bat[:int]. Later we should move batmtime functions into a proper file diffs (89 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 @@ -1556,7 +1556,8 @@ str MTIMEdaytime_fromseconds(daytime *re str MTIMEdaytime_fromseconds_bulk(bat *ret, bat *bid); str MTIMEdaytime_fromstr(daytime *ret, const char *const *s); str MTIMElocal_timezone_msec(lng *ret); -str MTIMEseconds_since_epoch(int *ret, const timestamp *t); +str MTIMEseconds_since_epoch(int *ret, const timestamp *src); +str MTIMEseconds_since_epoch_bulk(bat *ret, const bat *bid); str MTIMEsql_day(lng *ret, const lng *src); str MTIMEsql_day_bulk(bat *ret, const bat *bid); str MTIMEsql_hours(int *ret, const lng *src); 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 @@ -45,7 +45,6 @@ mal_export str MTIMEcurrent_timestamp(ti mal_export str MTIMEdate_fromstr(date *ret, const char *const *s); mal_export str MTIMEtimestamp_fromstr(timestamp *ret, const char *const *s); -mal_export str MTIMEseconds_since_epoch(int *ret, const timestamp *t); mal_export str MTIMEdaytime_fromstr(daytime *ret, const char *const *s); mal_export str MTIMEdaytime_fromseconds(daytime *ret, const lng *secs); mal_export str MTIMEdaytime_fromseconds_bulk(bat *ret, bat *bid); @@ -393,13 +392,8 @@ func1(MTIMEtimestamp_timestamp, MTIMEtim #define mkts(dt) timestamp_create(dt, daytime_create(0, 0, 0, 0)) func1(MTIMEtimestamp_fromdate, MTIMEtimestamp_fromdate_bulk, "timestamp", date, timestamp, mkts, COPYFLAGS) -str -MTIMEseconds_since_epoch(int *ret, const timestamp *t) -{ - lng df = timestamp_diff(*t, unixepoch); - *ret = is_lng_nil(df) ? int_nil : (int) (df / 1000000); - return MAL_SUCCEED; -} +#define seconds_since_epoch(t) is_timestamp_nil(t) ? int_nil : (int) (timestamp_diff(t, unixepoch) / 1000000); +func1(MTIMEseconds_since_epoch, MTIMEseconds_since_epoch_bulk, "seconds_since_epoch", timestamp, int, seconds_since_epoch, COPYFLAGS) #define mktsfromsec(sec) (is_int_nil(sec) ? \ timestamp_nil : \ 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 @@ -134,18 +134,26 @@ comment "Equality of two daytimes"; # address MTIMEcurrent_timestamp # comment "unix-time (epoch) support: seconds since the Unix epoch"; +module batmtime; module mtime; command epoch(t:timestamp):int address MTIMEseconds_since_epoch comment "unix-time (epoch) support: seconds since epoch"; +command batmtime.epoch(t:bat[:timestamp]) :bat[:int] +address MTIMEseconds_since_epoch_bulk; command epoch(t:int):timestamp address MTIMEtimestamp_fromsecond comment "convert seconds since epoch into a timestamp"; +command batmtime.epoch(t:bat[:int]) :bat[:timestamp] +address MTIMEtimestamp_fromsecond_bulk; + command epoch(t:lng):timestamp address MTIMEtimestamp_frommsec comment "convert milli seconds since epoch into a timestamp"; +command batmtime.epoch(t:bat[:lng]) :bat[:timestamp] +address MTIMEtimestamp_frommsec_bulk; module calc; pattern calc.==(v:timestamp,w:timestamp):bit @@ -173,7 +181,6 @@ pattern calc.>=(v:timestamp,w:timestamp) address CMDvarGE comment "Equality of two timestamps"; -module batmtime; module mtime; # command date_sub_sec_interval(t:date,s:int):date # address MTIMEdate_sub_sec_interval_wrap @@ -399,10 +406,6 @@ command diff(val1:date, val2:date) :int address MTIMEdate_diff comment "returns the number of days between 'val1' and 'val2'."; -command batmtime.diff(val1:bat[:date], val2:bat[:date]) :bat[:int] -address MTIMEdate_diff_bulk -comment "returns the number of days - between 'val1' and 'val2'."; command dayofyear(d:date) :int address MTIMEdate_extract_dayofyear _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list