From: Serge Petrenko via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Safin Timur <tsafin@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v5 4/8] box, datetime: messagepack support for datetime
Date: Tue, 17 Aug 2021 15:15:51 +0300 [thread overview]
Message-ID: <9f0f9279-2372-e6f4-b5e7-c0e539a6a9bf@tarantool.org> (raw)
In-Reply-To: <8bec4ec7-71fa-71cf-dd4a-73ce470c7283@tarantool.org>
16.08.2021 03:20, Safin Timur via Tarantool-patches пишет:
>
>
> On 16.08.2021 2:59, Timur Safin wrote:
>> Serialize datetime_t as newly introduced MP_EXT type.
>> It saves 1 required integer field and upto 2 optional
>> unsigned fields in very compact fashion.
>> - secs is required field;
>> - but nsec, offset are both optional;
>>
>> * json, yaml serialization formats, lua output mode
>> supported;
>> * exported symbols for datetime messagepack size calculations
>> so they are available for usage on Lua side.
>>
>> Part of #5941
>> Part of #5946
> ...
>
>> diff --git a/src/lib/core/mp_datetime.c b/src/lib/core/mp_datetime.c
>> new file mode 100644
>> index 000000000..d0a3e562c
>> --- /dev/null
>> +++ b/src/lib/core/mp_datetime.c
> ...
>
>> +
>> +int
>> +mp_snprint_datetime(char *buf, int size, const char **data, uint32_t
>> len)
>> +{
>> + struct datetime date = {0};
>
> Due to old gcc compiler used by CentOS7 I had to modify these 2
> functions - see incremental patch below...
>> +
>> + if (datetime_unpack(data, len, &date) == NULL)
>> + return -1;
>> +
>> + return datetime_to_string(&date, buf, size);
>> +}
>> +
>> +int
>> +mp_fprint_datetime(FILE *file, const char **data, uint32_t len)
>> +{
>> + struct datetime date;
>> +
>> + if (datetime_unpack(data, len, &date) == NULL)
>> + return -1;
>> +
>> + char buf[48];
>> + datetime_to_string(&date, buf, sizeof buf);
>> +
>> + return fprintf(file, "%s", buf);
>> +}
>> +
>
> ----------------------------------------------------------------
> 03:15 $ git diff
> diff --git a/src/lib/core/mp_datetime.c b/src/lib/core/mp_datetime.c
> index d0a3e562c..7e475d5f1 100644
> --- a/src/lib/core/mp_datetime.c
> +++ b/src/lib/core/mp_datetime.c
> @@ -165,7 +165,7 @@ mp_encode_datetime(char *data, const struct
> datetime *date)
> int
> mp_snprint_datetime(char *buf, int size, const char **data, uint32_t
> len)
> {
> - struct datetime date = {0};
> + struct datetime date = {0, 0, 0};
Please, use designated initializers here:
struct datetime date = {
.secs = ...,
.nsec = ...,
...
>
> if (datetime_unpack(data, len, &date) == NULL)
> return -1;
> @@ -176,7 +176,7 @@ mp_snprint_datetime(char *buf, int size, const
> char **data, uint32_t len)
> int
> mp_fprint_datetime(FILE *file, const char **data, uint32_t len)
> {
> - struct datetime date;
> + struct datetime date = {0, 0, 0};
>
> if (datetime_unpack(data, len, &date) == NULL)
> return -1;
> ----------------------------------------------------------------
>
> Sorry for the inconvenience!
>
> [Applied and force pushed]
>
> Timur
--
Serge Petrenko
next prev parent reply other threads:[~2021-08-17 12:17 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-15 23:59 [Tarantool-patches] [PATCH v5 0/8] Initial datetime implementation Timur Safin via Tarantool-patches
2021-08-15 23:59 ` [Tarantool-patches] [PATCH v5 1/8] build: add Christian Hansen c-dt to the build Timur Safin via Tarantool-patches
2021-08-17 12:15 ` Serge Petrenko via Tarantool-patches
2021-08-17 23:24 ` Safin Timur via Tarantool-patches
2021-08-18 8:56 ` Serge Petrenko via Tarantool-patches
2021-08-17 15:50 ` Vladimir Davydov via Tarantool-patches
2021-08-18 10:04 ` Safin Timur via Tarantool-patches
2021-08-15 23:59 ` [Tarantool-patches] [PATCH v5 2/8] lua: built-in module datetime Timur Safin via Tarantool-patches
2021-08-17 12:15 ` Serge Petrenko via Tarantool-patches
2021-08-17 23:30 ` Safin Timur via Tarantool-patches
2021-08-18 8:56 ` Serge Petrenko via Tarantool-patches
2021-08-17 16:52 ` Vladimir Davydov via Tarantool-patches
2021-08-17 19:16 ` Vladimir Davydov via Tarantool-patches
2021-08-18 13:38 ` Safin Timur via Tarantool-patches
2021-08-18 10:03 ` Safin Timur via Tarantool-patches
2021-08-18 10:06 ` Safin Timur via Tarantool-patches
2021-08-18 11:45 ` Vladimir Davydov via Tarantool-patches
2021-08-15 23:59 ` [Tarantool-patches] [PATCH v5 3/8] lua, datetime: display datetime Timur Safin via Tarantool-patches
2021-08-17 12:15 ` Serge Petrenko via Tarantool-patches
2021-08-17 23:32 ` Safin Timur via Tarantool-patches
2021-08-17 17:06 ` Vladimir Davydov via Tarantool-patches
2021-08-18 14:10 ` Safin Timur via Tarantool-patches
2021-08-15 23:59 ` [Tarantool-patches] [PATCH v5 4/8] box, datetime: messagepack support for datetime Timur Safin via Tarantool-patches
2021-08-16 0:20 ` Safin Timur via Tarantool-patches
2021-08-17 12:15 ` Serge Petrenko via Tarantool-patches [this message]
2021-08-17 12:16 ` Serge Petrenko via Tarantool-patches
2021-08-17 23:42 ` Safin Timur via Tarantool-patches
2021-08-18 9:01 ` Serge Petrenko via Tarantool-patches
2021-08-17 18:36 ` Vladimir Davydov via Tarantool-patches
2021-08-18 14:27 ` Safin Timur via Tarantool-patches
2021-08-15 23:59 ` [Tarantool-patches] [PATCH v5 5/8] box, datetime: datetime comparison for indices Timur Safin via Tarantool-patches
2021-08-17 12:16 ` Serge Petrenko via Tarantool-patches
2021-08-17 23:43 ` Safin Timur via Tarantool-patches
2021-08-18 9:03 ` Serge Petrenko via Tarantool-patches
2021-08-17 19:05 ` Vladimir Davydov via Tarantool-patches
2021-08-18 17:18 ` Safin Timur via Tarantool-patches
2021-08-15 23:59 ` [Tarantool-patches] [PATCH v5 6/8] lua, datetime: time intervals support Timur Safin via Tarantool-patches
2021-08-17 12:16 ` Serge Petrenko via Tarantool-patches
2021-08-17 23:44 ` Safin Timur via Tarantool-patches
2021-08-17 18:52 ` Vladimir Davydov via Tarantool-patches
2021-08-15 23:59 ` [Tarantool-patches] [PATCH v5 7/8] datetime: perf test for datetime parser Timur Safin via Tarantool-patches
2021-08-17 19:13 ` Vladimir Davydov via Tarantool-patches
2021-08-15 23:59 ` [Tarantool-patches] [PATCH v5 8/8] datetime: changelog for datetime module Timur Safin via Tarantool-patches
2021-08-17 12:16 ` Serge Petrenko via Tarantool-patches
2021-08-17 23:44 ` Safin Timur via Tarantool-patches
2021-08-18 9:04 ` Serge Petrenko via Tarantool-patches
2021-08-17 12:15 ` [Tarantool-patches] [PATCH v5 0/8] Initial datetime implementation Serge Petrenko via Tarantool-patches
[not found] ` <20210818082222.mofgheciutpipelz@esperanza>
2021-08-18 8:25 ` Vladimir Davydov via Tarantool-patches
2021-08-18 13:24 ` Safin Timur via Tarantool-patches
2021-08-18 14:22 ` Vladimir Davydov via Tarantool-patches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9f0f9279-2372-e6f4-b5e7-c0e539a6a9bf@tarantool.org \
--to=tarantool-patches@dev.tarantool.org \
--cc=sergepetrenko@tarantool.org \
--cc=tsafin@tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH v5 4/8] box, datetime: messagepack support for datetime' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox