I am new to ProtocolBuffer and wanted to verify that I am doing the
right thing here:

I have  proto definitions as:

Person {
  required string fname =1;
  required string lname = 2;
  required string email = 3;
}

MyResponse {
   repeated Person persons = 1;
}

What is the most effecient way to generate a myResponse with 100
persons? Is this effecieint?

// assume I have a array of hashmap of person data.
// there is the myResponseBuilder which is a builder for MyResponse.

for (int i = 0; i < 100; i++)
   Person.Builder personBuilder = Person.newBuilder();
   personBuilder.setFname(nameFromMap);
   personBuilder.setLname(nameFromMap);
   personBuilder.setEmail(emailFromMap);

   myResponseBuilder.addPerson(personBuilder);
}

Is this the right way to do this? Or is there a better effecient way
instead of creating a builder for each person data? Any pointers
appreciated! Thanks!

--

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.


Reply via email to