Can protocol buffer support partial reading?

67 views
Skip to first unread message

ill W

unread,
May 27, 2019, 7:26:45 AM5/27/19
to Protocol Buffers
I am using protocol buffer in C++ and I notice that if I use an old protocol buffer generated code and parse a new protocol buffer file, it will crash. 

Is there any way to partial parse the file like just ignore the unrecognized structure in my new file and get the supported total file?  

For example, If I support new layer in caffe model, can I parse the caffe model without compiling my code and get all the supported layer in my old code?

I have read the protobuf api and find ParsePartialFromIstream function, but it still don't work. 


 

Marc Gravell

unread,
May 27, 2019, 3:03:41 PM5/27/19
to ill W, Protocol Buffers
What exactly happens? Protocol buffers are designed to be forwards compatible, so adding fields etc is usually fine and expected. Depending on the implementation unexpected fields may be ignored or stored as extension fields. So: is that what you did? And: what happened?

Note: changing the data type (or meaning) of an existing field is *not* forwards compatible.

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To post to this group, send email to prot...@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/f65a1540-da98-4813-b012-afad4f665841%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ill W

unread,
May 27, 2019, 11:35:31 PM5/27/19
to Protocol Buffers
Yes, I add fields in my new protocol buffers types without changing any data type of an existing fields. After I posted my problems, I tried member function ParsePartialFromCodedStream in the message class, and it told me that I have UnknownFields, and is it the way protocol buffers designed to be forwards compatible? I can just use the function provided in unknownfield and get what I need?

在 2019年5月28日星期二 UTC+8上午3:03:41,Marc Gravell写道:
What exactly happens? Protocol buffers are designed to be forwards compatible, so adding fields etc is usually fine and expected. Depending on the implementation unexpected fields may be ignored or stored as extension fields. So: is that what you did? And: what happened?

Note: changing the data type (or meaning) of an existing field is *not* forwards compatible.

On Mon, 27 May 2019, 12:26 ill W, <tianzha...@gmail.com> wrote:
I am using protocol buffer in C++ and I notice that if I use an old protocol buffer generated code and parse a new protocol buffer file, it will crash. 

Is there any way to partial parse the file like just ignore the unrecognized structure in my new file and get the supported total file?  

For example, If I support new layer in caffe model, can I parse the caffe model without compiling my code and get all the supported layer in my old code?

I have read the protobuf api and find ParsePartialFromIstream function, but it still don't work. 


 

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prot...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages