[Tarantool-patches] [PATCH vshard 1/1] router: bucket_id_strcrc32 and bucket_id_mpcrc32

Oleg Babin olegrok at tarantool.org
Thu Feb 27 13:12:50 MSK 2020


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


More information about the Tarantool-patches mailing list