thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Piscium <>
Subject Re: usage without RPC
Date Mon, 12 Mar 2012 22:39:55 GMT
On 12 March 2012 17:16, Rush Manbert <> wrote:
> Of course you can use Thrift without using the RPC part. We do this in many different
forms, mostly with custom protocols that we have derived from the binary protocol.
> The attachment contains a C++ file that uses the TFileTransport to write data into a
file and then read it back. Note that it includes ThriftTest.h, which is generated from thriftSrcDistro/test/ThriftTest.thrift.
> If you use the JSON protocol (by commenting out line 20 that defines DENSE and uncommenting
line 18 that defines JSON), you will get the data serilized as a string. The binary protocol
also works. I'm not sure about the dense protocol.
> You can see that the basic method to serialize is to make a Thrift structure, then call
its write() method, passing a protocol.
> I can't comment on the C support. Haven't tried it.

Hi Rush,

Thanks for taking the time to answer my query. In hindsight I should
have not mentioned the function SerializeToString as I really don't
know for sure what it does, and per your answer it probably does not
do what I thought it did. So I will now say a few words about what I
am trying to accomplish.

I have a main program that gets data from a few places (example,
database), takes some user input, does some calculations and then
calls a visualization function to present the data to the user (or
print it, or save to file). The problem I face is how the main program
should pass the data to that function. Because the data is
heterogeneous and has a somewhat complicated structure I am exploring
the idea of the main program serializing the data, which will then be
deserialized by the function.

There are several advantages to this approach: a clean interface
between the program and function that is documented in a readable
format in the .thrift file, and easier maintenance. Obviously there is
a cost in terms of serialization overhead, though my guess is that the
overhead would be less than 20% of the time taken to create the
display so I don't mind.

Looking at Thrift, it seems that the best would be to use the binary
protocol. As for transport layer my _guess_ is that what I need is a
memory buffer. Do you know if such a memory buffer could be used for
my intended purpose, that is, pass data from the core of the program
to the function?

View raw message