Hi Klaus,

what you describe sounds like some kind of dynamic data structures, created at run time. For performance reasons Thrift focuses on structures known at compile time. That does not mean that structures etc. are fix forever, they can be enhanced over time due to soft versioning, but still everything must be known at compile time. Conserquently, modifying the IDL file means you have to (at least) recompile your projects.

In ProtoBuf, I could write a message dynamically. This allowed
me to create a message with certain content at runtime. This
was based on some reflection mechanisms. [...] Can I write a
message dynamically at runtime without using the
classes generated out of the .thrift file?

I would not say that it is not possible from a technical standpoint, but there is next to none existing support in Thrift. If you need a dynamic message structure at runtime, I see two basic options:

(1) Define a generic message format that makes it possible to compose arbitrarily complex structures from it. The basic idea is the same as with e.g. a VARIANT structure, which can hold a lot of different data inside the same structure.

(2) Consider using Apache Avro instead. Here's a good article http://www.infoq.com/articles/ApacheAvro

HTH,
JensG


-----Ursprüngliche Nachricht----- From: Klaus Kraft
Sent: Saturday, May 24, 2014 5:49 PM
To: [email protected]
Subject: Data migration in Thrift / Possibilty to create message dynamically at runtime?

Hi all,

so far I gained some experiences with Apache Avro and Google ProtoBuf. Now
I wanted to play around with Thrift a bit.
One of the thrings I'm mainly interested in is data migration. Lets say I
have defined certain structs.
I know that thrift can deal with additions, deletions and renamings.

But can I also deal with more complex migration scenarios, e.g., when I
move a field of a struct
into another struct? Or splitting a field of a struct into two fields (of
the same struct)?
The crucial point here is to be able to write migration classes or so which
prevent me from
loosing data.

In ProtoBuf, I could write a message dynamically. This allowed me to create
a message with
certain content at runtime. This was based on some reflection mechanisms.
Is something like this
also possible in Thrift? Can I write a message dynamically at runtime
without using the
classes generated out of the .thrift file?

Thanks in advance.

Reply via email to