From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 60035469719 for ; Thu, 27 Feb 2020 13:12:52 +0300 (MSK) References: <08e87903-c00a-9f8a-ff25-5199eb6be0f8@tarantool.org> <14136e7a-c642-8c59-4371-b30e1604446f@tarantool.org> From: Oleg Babin Message-ID: Date: Thu, 27 Feb 2020 13:12:50 +0300 MIME-Version: 1.0 In-Reply-To: <14136e7a-c642-8c59-4371-b30e1604446f@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH vshard 1/1] router: bucket_id_strcrc32 and bucket_id_mpcrc32 List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy , tarantool-patches@dev.tarantool.org On 27/02/2020 03:22, Vladislav Shpilevoy wrote: > Yep, I knew that. Precision loss is why I discarded my first draft > patch, using tonumber() for all cdata numbers. The point is that > if you insert ffi.cast(double), then you should pass ffi.cast(double) > to bucket_id function as well. You calculate hash from what is > inserted. Not from what is returned. From how I imagine this. My main consern that user can modify returned value and then put it again. But ok, I see that we can't cover all possible cases - I hope this issue or some note in documentation makes developers to think about such problem. > > This also makes MessagePack encoding useless, because if we > have only Lua numbers and strings, then crc32(tostring()) will > work fine too. > > I can add a third function bucket_id_nstrcrc32. Stands for > Number String Crc32 - n str crc32. This will call tonumber() > for all cdata numbers before calling crc32(tostring(...)) on > them. > > Sounds good? > Let's stay as is and should not overcomplcate API. -- Oleg Babin