Recursive data structures in Protocol Buffers, Apache Thrift or any other Data structure serialization protocol?

StackOverflow https://stackoverflow.com//questions/21004562

Question

I have enough theoretical knowledge about the Protocol Buffers, Apache Thrift and about other Data Structure serialization protocols. My questionis that if i need to define a recursive data structure(Linked Lists, Search Trees etc..) or some relationship between different objects, is there any built in standard way Protocol Buffers or Apache Thrift provides to set a link between different structures (we use pointers in normal programming practice)? or we have to continue like using pointers to make a link between different Data structure objects ?

I want to do it with C++ API

Thank you in Advance! :)

Was it helpful?

Solution

Both allow a message of type X to contain other messages of type X, neither allows a message to contain itself (unlike, say, Java serialisation). Doing otherwise would be very expensive for an unusual case.

But don't send your actual data model over either; instead work out your own efficient wire representation and use the serialisation protocol to transport it.

OTHER TIPS

I know this is million years old, but here's something: AMF (ActionScript Message Format). And, before you run away screaming into the night... It's not really that bad. And, unlike the more popular ones it can do circular references, no problem there. Many moons ago I wrote a decoder for this format. In the heydays of Flash there used to be implementations for some other languages, if memory serves, there were two or three Java libraries, a Python library, a PHP one, a .NET one, maybe more. There also was one written in C.

The format itself may be seen as a superset of JSON, even though it appeared long before it. It was intended for serializing a language derived from JavaScrip, but with some type annotations, so it had some sort of typing constraints. Its human-readable form is the ActionScript code (very similar to JavaScript with some extra keywords related to type annotations). The specification is open and can be found here: http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/amf/pdf/amf-file-format-spec.pdf

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top