Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Nikita Pettik <korablev@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v2 1/4] tuple: don't truncate float in :update()
Date: Mon, 10 Feb 2020 22:18:46 +0100	[thread overview]
Message-ID: <cadc5095-dca2-406d-c045-3e6c3587c3f5@tarantool.org> (raw)
In-Reply-To: <20200210144115.GH1110@tarantool.org>

Hi! Thanks for the review!

On 10/02/2020 15:41, Nikita Pettik wrote:
> On 04 Feb 23:53, Vladislav Shpilevoy wrote:
>> diff --git a/src/box/xrow_update_field.c b/src/box/xrow_update_field.c
>> index 7c0f5fb5e..6ac29de5d 100644
>> --- a/src/box/xrow_update_field.c
>> +++ b/src/box/xrow_update_field.c
>> @@ -32,6 +32,8 @@
>>  #include "tuple_format.h"
>>  #include "mp_extension_types.h"
>>  
>> +#include <float.h>
>> +
>>  /* {{{ Error helpers. */
>>  
>>  /** Take a string identifier of a field being updated by @a op. */
>> @@ -400,13 +402,15 @@ xrow_update_arith_make(struct xrow_update_op *op,
>>  			unreachable();
>>  			break;
>>  		}
> 
> Patch is ok, but I'd add a brief comment here like:
> 
> If value fits into float, then store it as a float;
> store it as double otherwise.
> 
> Up to you.

Added a comment:

================================================================================

diff --git a/src/box/xrow_update_field.c b/src/box/xrow_update_field.c
index 6ac29de5d..0540e8c3e 100644
--- a/src/box/xrow_update_field.c
+++ b/src/box/xrow_update_field.c
@@ -403,6 +403,12 @@ xrow_update_arith_make(struct xrow_update_op *op,
 			break;
 		}
 		float fc = (float) c;
+		/*
+		 * If fits into float - store as a float.
+		 * Otherwise as a double. Fits means, that the
+		 * value precision is not truncated by float, and
+		 * its value is inside the float range.
+		 */
 		if ((lowest_type == XUPDATE_TYPE_DOUBLE && c != (double) fc) ||
 		    (lowest_type == XUPDATE_TYPE_FLOAT &&
 		     (c >= FLT_MAX || c <= -FLT_MAX))) {

  reply	other threads:[~2020-02-10 21:18 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-04 22:53 [Tarantool-patches] [PATCH v2 0/4] Don't truncate float in update Vladislav Shpilevoy
2020-02-04 22:53 ` [Tarantool-patches] [PATCH v2 1/4] tuple: don't truncate float in :update() Vladislav Shpilevoy
2020-02-10 14:41   ` Nikita Pettik
2020-02-10 21:18     ` Vladislav Shpilevoy [this message]
2020-02-19 21:36       ` Nikita Pettik
2020-02-04 22:53 ` [Tarantool-patches] [PATCH v2 2/4] tuple: pass tuple format to xrow_update_*_store() Vladislav Shpilevoy
2020-02-10 16:51   ` Nikita Pettik
2020-02-10 21:18     ` Vladislav Shpilevoy
2020-02-04 22:53 ` [Tarantool-patches] [PATCH v2 3/4] tuple: allow xrow_update sizeof reserve more memory Vladislav Shpilevoy
2020-02-10 16:05   ` Nikita Pettik
2020-02-04 22:53 ` [Tarantool-patches] [PATCH v2 4/4] tuple: use field type in update of a float/double Vladislav Shpilevoy
2020-02-10 16:16   ` Nikita Pettik
2020-02-10 21:18     ` Vladislav Shpilevoy
2020-02-05 11:09 ` [Tarantool-patches] [PATCH v2 0/4] Don't truncate float in update Konstantin Osipov
2020-02-05 22:11   ` Vladislav Shpilevoy
2020-02-20  6:15 ` Kirill Yukhin
2020-02-20 13:27   ` Nikita Pettik
2020-02-20 20:30   ` Vladislav Shpilevoy

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=cadc5095-dca2-406d-c045-3e6c3587c3f5@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 1/4] tuple: don'\''t truncate float in :update()' \
    /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