Do-it-yourself links in protobuf posts

Is it good to have such a message?

message A { required int64 some_number = 1; // .... some more fields optional A sub_a = 123; } 

The reason is that my current protocol stores are stored directly in A, and moving A to another message will result in massive conversions of the stored data.

2.2.0 protoc compiles it in order. Could this be a problem with serialization / deserialization, and this is supported by protobuf-net.

+6
source share
2 answers

This is a completely accurate definition and should work in any implementation (including protobuf-net); do you see any problem? HOWEVER! you may need the computational impact of serialization - in particular, to serialize a sub-message, the size of the auxiliary messages must be known first . A deeply recursive method (if necessary a linked list) can cause some problems.

Is there a reason this might not be just a repeated message? that would be far from me.

+7
source

I do not know about protobuf-net, but this should be absolutely normal. I suspect that if this does not work in protobuf-net, Mark will consider this a mistake and fix it ... this is definitely the attitude that I will take in my C # port :)

(Actually, I cannot easily understand how this will be a problem ... it does not seem like messages will be represented by structures where recursion will be a problem.)

This should be pretty easy to check - I suggest you try with a small message and see if you have any problems. All you have to do is create a message and check if it can be serialized and deserialized correctly, perhaps between different platforms.

EDIT: Obviously, you need to make sure that there are no actual loops in terms of the messages themselves ...

+2
source

Source: https://habr.com/ru/post/887682/


All Articles