You should be using toByteArray(), not getBytes(), to serialize to
the protobuf wire format.
Oh those variables are byte array wrappers and contains serialized
bytes among other things.
You also need to delimit the messages.
Got it, thanks.
Otherwise, the first ParseFromCodedStream call will consume as many
bytes as are available in the byte array.
Yes , confirmed with some print statements. That does remind me of
some I know at the dining table.
Thanks and cheers
J
On Sun, Dec 12, 2010 at 10:13 PM, Fishtank
<saptarshi.g...@gmail.com> wrote:
Hello,
I have a CodedInputStream created from a byte array (in C++)
CodedInputStream cds((uint8_t*)a,tbytes);
cds.SetTotalBytesLimit(N,M);
I have written bytes to this array (a) from Java like so
b.writeRawBytes(k.getBytes(),0,k.getLength());
b.writeRawBytes(v.getBytes(),0,v.getLength());
Given the number N of k,v pairs written, I'd like to deserialize them.
Notice I haven't prepended byte sizes. I thought I could do
something like this
for(i = 1 to N){
rexp_container->ParseFromCodedStream(&cds) //k
// do something with rexp_container
rexp_container.Clear();
rexp_container->ParseFromCodedStream(&cds) //v
// do something with rexp_container
rexp_container.Clear();
}
Is this the correct way to do it? I get a missing field error (not
supposed to be the case)
I tried ParsePartialFromCodedStream but I get incorrect results.
Is it okay to provide a CodedInputStream and pick of the messages
one by one?
Cheers
Joy
[1] PB ERROR[LOGLEVEL_ERROR](google/protobuf/message_lite.cc:123)
Can't parse message of type "REXP" because it is missing required
fields: rclass
--
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 protobuf+unsubscr...@googlegroups.com
.
For more options, visit this group at http://groups.google.com/group/protobuf?hl=en
.
--
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 protobuf+unsubscr...@googlegroups.com
.
For more options, visit this group at http://groups.google.com/group/protobuf?hl=en
.
--
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
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/protobuf?hl=en.