I'm trying to serialize a large primitive array of int in Java, and
I'm testing using 1,000,000 elements. My .proto message is just a
packed repeated field of type int32. To serialize, I just create a
builder and loop through the array, adding elements one at a time. I
took a peek at the underlying implementation and it seems that it uses
an ArrayList. However, there's no way to reserve the size of the
ArrayList, so serializing is slower than it could be. In fact, it's
faster for me to just serialize the data an ObjectOutputStream to put
the data in a protocol buffer bytes message.
Is there a way for me to do the serialization faster? I took a peek
through the API but didn't see anything obvious. I saw
CodedOutputStream as well, but I didn't understand the intent of that
class. Could anyone please explain what it's used for?
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to
For more options, visit this group at