Apache thrift and flatbuffers interoperability

310 views
Skip to first unread message

Arun Sharma

unread,
Feb 4, 2017, 5:28:16 PM2/4/17
to FlatBuffers

Couple of things that may be useful to people interested in flatbuffers and thrift:

* thrift2fbs.py - does some basic conversion of thrift structs/types to flatbuffer equiavelnt
* fbs/parser.py - PLY grammar for flatbuffers

This should make it possible to do templated code generation using libraries like python-jinja2.

 -Arun

https://github.com/adsharma/thriftpy/commits/fbs

Wouter van Oortmerssen

unread,
Feb 6, 2017, 4:05:16 PM2/6/17
to Arun Sharma, FlatBuffers
Very cool!

--
You received this message because you are subscribed to the Google Groups "FlatBuffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flatbuffers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

agallego

unread,
Feb 7, 2017, 3:29:30 PM2/7/17
to FlatBuffers
Thanks Arun! this is super helpful.. 

Arun Sharma

unread,
Feb 9, 2017, 3:30:23 PM2/9/17
to FlatBuffers

There is now a python-jinja2 based code generation framework. It's incomplete, doesn't really work, but hopefully gets the idea across.

https://github.com/adsharma/thriftpy/commit/244a30d5fc6b1365607a0229c025e21f73193e92

To support the somewhat more complex code to generate keys and values from a flatbuffer for a kvstore, I'll need to make intrusive changes to flatc. I felt that's not fair to the rest of the flatc users many of who may not care about these use cases and hence the idea.

Alexander Gallego

unread,
Feb 10, 2017, 1:06:57 PM2/10/17
to Arun Sharma, FlatBuffers
I actually have some code i"m changing to flatbuffers: 


from an old thrift service API. 

I would be interested in a library that could do the transformations inline. 

This just seems to generate the same code as flatcc?$  were you thinking of dynamically parsing the thrift struct and generating flatbuffers on the fly? 

Or just consume the .thrift schema and convert it to a .fbs schema




Sincerely,
Alexander Gallego

---*---
------*
*  *  *



--
You received this message because you are subscribed to a topic in the Google Groups "FlatBuffers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/flatbuffers/fhR5VH7qz-I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to flatbuffers+unsubscribe@googlegroups.com.

Arun Sharma

unread,
Feb 10, 2017, 2:44:09 PM2/10/17
to FlatBuffers
> Or just consume the .thrift schema and convert it to a .fbs schema

This is what the thrif2fbs.py does.

However, it shouldn't be hard to chain them together since it's python code anyway.

Potential implementation strategy:

In generate_fbs here:
https://github.com/adsharma/thriftpy/blob/aecb6cd343468a6819d4fe3621478498ffb13823/tests/thrift2fbs.py#L35

Instead of generating the fbs code, we could be generating a parsed fbs representation such as the one generated by fbs/parser/parser.py and then feed it to flatc.py to bypass one step.

This was something I coded up during a hackathon and I can't really promise anything. But welcome collaboration from other interested developers to take it forward.

 -Arun
To unsubscribe from this group and all its topics, send an email to flatbuffers...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages