Thanks for the reply.  I think I understand what is happening here but
have an additional question.

You stated three rules.  When you say "...singular embedded messages/
groups will be merged.", does that imply that the other rules are
simply applied recursively?

That is, suppose the .proto was defined like so:

message Collection {
  required string foo;
  repeated Mydata;

message MyData {
  required float bar;
  required float time;
  required AmpData;

message AmpData {
  required int type;

Based on your statements I would think that the "cat procedure" I
inquired about would provide the functionality I desire because, even
though both MyData and AmpData contain singular primitives, they are
part a repeated embedded message and therefore should be merged/

Moreover, based on my interpretation, all data from the individual
0.dat, 1.dat, ... files would be present in the fullday.dat file,
minus any top level singular primitive fields.  That is, it appears
that the only data I stand to lose is the top-level primitives in
message Collection, which I can live with given my alternatives.

Is that a correct assumption?

Thanks again.

On Apr 1, 3:56 pm, Kenton Varda <> wrote:
> Concatenating encoded protocol messages has the effect of merging them, with
> the same semantics as the MergeFrom() method.  That is, repeated fields will
> be concatenated, singular primitive fields will take the *last* value, and
> singular embedded messages/groups will be merged.
> In your case, your concatenated message would contain the value of "foo"
> from the last message in your set, but the repeated MyData would be
> concatenated.
> On Wed, Apr 1, 2009 at 11:47 AM, le <> wrote:
> > I'm currently using protocol buffers to serialize variable-rate real-
> > time data.  Per requirements I must serialize this data and make it
> > available every X seconds.  At the end of the day we are required to
> > have a single file that contains all of the data.
> > So, after searching this group I discovered a posting that said
> > something to the effect of combing binary messages and decoding them,
> > implying I could do what I want: combine binary messages.
> > Essentially, say I have a collection of protocol buffers on disk:
> > 0.dat, 1.dat, etc.  If I cat them to a single file does this violate
> > anything in terms of the (de-)serialization process?
> > This is what I am thinking:
> > 1) Produce collection of binary proto files: 0.dat, 1.dat, ...
> > 2) cat *.dat > fullday.dat
> > 3) decode fullday.dat, using the _same_ existing code that de-
> > serializes 0.dat, 1.dat, etc.
> > I have tested this exact scenario on my own and all of my data appears
> > to be present but I am looking for some sort of confirmation.
> > FYI, the proto file has structure similar to this (if it matters):
> > message Collection {
> >  required string foo;
> >  repeated MyData;
> > }
> > message MyData {
> >  float bar;
> > }
> > ... where each instance of 0.dat, 1.dat contains a message type of
> > Collection.
> > Thanks!
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to