Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org,
	Konstantin Osipov <kostja@tarantool.org>
Cc: Alexander Turenko <alexander.turenko@tarantool.org>,
	Morgan-iv <ivushkinalex@gmail.com>
Subject: [tarantool-patches] Re: [PATCH] box: add tuple:size function
Date: Wed, 17 Oct 2018 23:36:53 +0300	[thread overview]
Message-ID: <516dab0e-c9d5-5dcd-0984-9d2283b5ff85@tarantool.org> (raw)
In-Reply-To: <20181017181447.GC28587@chai>



On 17/10/2018 21:14, Konstantin Osipov wrote:
> * Vladislav Shpilevoy <v.shpilevoy@tarantool.org> [18/10/17 21:12]:
> 
>> Also, some people can use it right now to allocate a
>> buffer of a correct size before calling box_tuple_to_buf.
>> I understand, that box_tuple_to_buf(tuple, NULL, 0) returns
>> bsize as well, but some people could miss it, or just use
>> box_tuple_bsize because it looks better when you write like
>> this:
>>
>>      size = box_tuple_bsize(tuple)
>>      buf = alloc(size)
>>      box_tuple_to_buf(tuple, buf, size)
>>
>> than like this:
>>
>>      size = box_tuple_to_buf(tuple, NULL, 0) // <- difference
>>      buf = alloc(size)
>>      box_tuple_to_buf(tuple, buf, size)
>>
>> Even if we close eyes on the fact, that a user of
>> the first way will allocate more data than needed,
>> imagine, that then he does something like this:
>>
>>      send(sockfd, buf, size)
>>
>> Now, he send some garbage uninitialized data of 14
>> bytes at the end of buf.
> 
> Is there any known use?
> 

It is a strange question, especially from you. Open
source public API's nature is to be assumed as being
used right now in a real project. When a product is
free and open source, you can not be sure how many
users do you have exactly and who uses which API, so
you HAVE to assume that each API function is used
somewhere in all possible ways.

At first, it can be used in some GitHub project as
Alexander underlined, in some connectors. At second,
not all projects are hosted on GH. Out API can be
used in any imaginable proprietary project.

As I said, I knew you will not believe me, but if you
asked about why somebody needs 'send' in their Tarantool
module, I would answer this:

* it can be a customer's proxy - he could create own
   TCP server in front of Tarantool to send/receive
   tuples with very simplified protocol, easier than
   IProto, or to just convert to protocol of another DB;

* it is not necessary 'send'. It can be 'write' to a
   disk. For example, Tarantool is an extra light and
   fast in-memory cache for some non-critical data, that
   is persisted by user's facilities, or in another DB,
   having disk storage;

* it can be Mons-like weird way to get tuple data
   without iterating over it via box_tuple_iterator nor
   copying into buf:

       const char *tuple_whole_data = box_tuple_field(tuple, 0);
       size_t tuple_msgpack_size = box_tuple_size(tuple);
       /*
        * then use whole range
        * [tuple_whole_data, tuple_whole_data + tuple_msgpack_size]
        */

   I know that it is illegal way, but it works now, and allows to
   do not copy data.
   

      parent reply	other threads:[~2018-10-17 20:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-27 17:55 [tarantool-patches] " AlexeyIvushkin
2018-10-03 14:20 ` [tarantool-patches] " Vladislav Shpilevoy
2018-10-03 15:05   ` Vladislav Shpilevoy
2018-10-05 10:23 ` [tarantool-patches] " Vladimir Davydov
2018-10-06 13:58   ` [tarantool-patches] " Vladislav Shpilevoy
2018-10-08 10:16     ` Vladimir Davydov
2018-10-10 10:25       ` Vladislav Shpilevoy
2018-10-16 18:21 ` Konstantin Osipov
2018-10-17  7:28   ` Alexander Turenko
2018-10-17 15:29     ` Konstantin Osipov
2018-10-17 15:50       ` Alexander Turenko
2018-10-18 18:11         ` Konstantin Osipov
2018-10-18 18:15           ` Alexander Turenko
2018-10-17 18:06       ` Vladislav Shpilevoy
2018-10-17 18:10         ` Vladislav Shpilevoy
2018-10-17 18:14         ` Konstantin Osipov
2018-10-17 18:20           ` Alexander Turenko
2018-10-17 20:36           ` Vladislav Shpilevoy [this message]

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=516dab0e-c9d5-5dcd-0984-9d2283b5ff85@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=alexander.turenko@tarantool.org \
    --cc=ivushkinalex@gmail.com \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH] box: add tuple:size function' \
    /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