11 Jan 2011 06:45
Using a ByteBuffer instead of a ByteString?
Nicolae Mihalache <xpromache <at> gmail.com>
2011-01-11 05:45:27 GMT
2011-01-11 05:45:27 GMT
Hello, I recently started to use GPB, great software! :) But I have noticed in java that it is impossible to create a message containing a "bytes" fields without copying some buffers around. For example if I have a encoded message of 1MB with a few regular fields and one big bytes field, decoding the message will make a copy of the entire buffer instead of keeping a reference to it. Even worse when encoding: if I read some data from file, does not seem possible to put it directly into a ByteString so I have to make first a byte[], then copy it into the ByteString and when encoding, it makes yet another byte[]. So my question: is it possible to make an exception from the immutability for the "bytes" fields and use java.nio.ByteBuffers instead of ByteStrings? thanks, nicolae -- -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf <at> googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscribe <at> googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
RSS Feed