Re: Emulate hash_map using map when necessary.
submitted. Thanks for prodding me into fixing this. :) On Fri, Sep 19, 2008 at 6:41 AM, [EMAIL PROTECTED] wrote: You can submit it, the code is correct. Thank you. -- *De :* Kenton Varda [mailto:[EMAIL PROTECTED] *Envoyé :* 18 septembre 2008 17:13 *À :* [EMAIL PROTECTED]; Choinière, Vincent; protobuf@googlegroups.com *Objet :* Re: Emulate hash_map using map when necessary. Any comments on the code? If not, I'll go ahead and submit it. On Thu, Sep 18, 2008 at 1:59 PM, [EMAIL PROTECTED] wrote: Yes, is working. == Test ok on Tru64 (with some other changed in the code for the compiler) == Test ok on Windows Visual Studio 2005 Issue 5682 can be ignored... http://codereview.appspot.com/5683 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to protobuf@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Any small sample Class Service code for Java
On Fri, Sep 19, 2008 at 9:50 AM, Mars [EMAIL PROTECTED] wrote: just want to find some sample code for Class Service: http://code.google.com/apis/protocolbuffers/docs/reference/python/google.protobuf.service.Service-class.html That's the Python version. Shouldn't you be looking at the Java version? http://code.google.com/apis/protocolbuffers/docs/reference/java/com/google/protobuf/Service.html for example: given .proto .java files below, how to use simply use them in some basic Java network program, such as ServerSocket or DatagramSocket? Maybe look at some of the RPC implementations people are working on: http://code.google.com/p/protobuf/wiki/RPCImplementations = # .proto message Req1 { required int32 id = 1; } message Res1 { required string name = 1; } service Serv1 { rpc Func1(Req1) returns (Res1) { option name = name1; } } == // .java public class MyServ implements Serv1 { public EmptyMessage Func1(RPC rpc, Req1 req) throws RpcException { //... } } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to protobuf@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Does SerializeToXxx() guarantee a call to ByteSize()?
You probably shouldn't rely on this. Some of the serialization methods will guarantee this, some won't. What you can do is call ByteSize() yourself, and then use SerializeWithCachedSizes(), which requires that ByteSize() was already called and won't call it again. You'll have to do a small amount of extra setup (allocating a ZeroCopyOutputStream and a CodedOutputStream), but it's pretty straightforward -- you can just copy the code out of message.cc. Another thing that you could do which is specific to your use case: Instead of allocating a byte array to serialize into, just use a string: string bytes; pkt.SerializeToString(bytes); send(fd, bytes.data(), bytes.size(), 0); This is better anyway since it won't break if your messages become larger than SIZE. On Fri, Sep 19, 2008 at 2:12 PM, Leandro Lucarella [EMAIL PROTECTED] wrote: Hi. I guess SerializeToXxx() methods internally calls to ByteSize(), so after a serialization, I can call GetCachedSize(). My question is, first, is this true? =) And second, can I rely on this? The use case is this: pkt.SerializeToArray(buffer, SIZE); send(fd, buffer, pkt.GetCachedSize(), 0); Is this safe or should I use pkt.ByteSize() instead? Thank you. -- Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/ GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) Soñé que tenia un caballo Que me trataba mejor que vos Tenia tan buena onda con ella Era mi yegua, mucho mas que vos --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to protobuf@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Any small sample Class Service code for Java
On 9月20日, 上午3时34分, Kenton Varda [EMAIL PROTECTED] wrote: On Fri, Sep 19, 2008 at 9:50 AM, Mars [EMAIL PROTECTED] wrote: just want to find some sample code for Class Service: http://code.google.com/apis/protocolbuffers/docs/reference/python/goo... That's the Python version. Shouldn't you be looking at the Java version? thank you for your quick response. yes, the page i pasted is the python version, i need a Java version. http://code.google.com/apis/protocolbuffers/docs/reference/java/com/g... for example: given .proto .java files below, how to use simply use them in some basic Java network program, such as ServerSocket or DatagramSocket? Maybe look at some of the RPC implementations people are working on: http://code.google.com/p/protobuf/wiki/RPCImplementations I checked this page before. http://protorpc.likbilen.com/ only binary, no source code. btw, it's more complex than what I want, :) I just want a very basic code to use java server and protobuf rpc together. https://launchpad.net/txprotobuf/ python code. http://code.google.com/p/protobuf-rpc/ not available = # .proto message Req1 { required int32 id = 1; } message Res1 { required string name = 1; } service Serv1 { rpc Func1(Req1) returns (Res1) { option name = name1; } } == // .java public class MyServ implements Serv1 { public EmptyMessage Func1(RPC rpc, Req1 req) throws RpcException { //... } } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to protobuf@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Does SerializeToXxx() guarantee a call to ByteSize()?
Kenton Varda, el 19 de septiembre a las 16:12 me escribiste: You probably shouldn't rely on this. Some of the serialization methods will guarantee this, some won't. What you can do is call ByteSize() yourself, and then use SerializeWithCachedSizes(), which requires that ByteSize() was already called and won't call it again. You'll have to do a small amount of extra setup (allocating a ZeroCopyOutputStream and a CodedOutputStream), but it's pretty straightforward -- you can just copy the code out of message.cc. Another thing that you could do which is specific to your use case: Instead of allocating a byte array to serialize into, just use a string: string bytes; pkt.SerializeToString(bytes); send(fd, bytes.data(), bytes.size(), 0); Thanks for the tip. I didn't do it this way because I use the same buffer for receiving, and I can't use std::string for receiving. I could use two buffers, but now I wonder how std::string is used when serializing. Is the ByteSize() precalculated and space is reserve()ed in the string or it's incrementally expanded as it's serialized? This is better anyway since it won't break if your messages become larger than SIZE. This is not a problem to me, all messages are really short and I have a physical size limit imposed by the lower level (I'm using TIPC RDM sockets) anyway. So I have to drop the message (or abort the program) if it's size is longer than this limit, and I have guaranteed that I can't possibly receive a message that doesn't fit my buffer. -- Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/ GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) HOMBRE DESNUDO AMENAZA A LOS VECINOS CON UNA KATANA DESDE SU BALCON -- Crónica TV --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to protobuf@googlegroups.com 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 -~--~~~~--~~--~--~---