Re: [protobuf] Optional,Repated fields and Submessages
On Wed, Jun 1, 2011 at 3:45 PM, aara aara.cool...@gmail.com wrote: I actually have 3 questions. 1.When we specify default values for optional fields,the default value gets assigned automatically when we ourselves dont assign it a value. But why doesnt the has_member field get set to 1??? It still remains zero. To clarify the default value a bit: In your code, if you don't set_somefield() explicitly: 1) has_somefield() will return false. 2) somefield() will return the default value. 3) the default value won't be serialized into the wire. that said, if you don't set any field in your message, the serialized bytes will be empty. Each field has a default value, e.g. 0 for int, for string. You can override the default value by set [default=xxx] in the .proto file, but it won't change the behavior described above. 2.Can we not specify default values for repeated fields too??? The protoc-c compiler throws an error. Do you mean you want to set default values for repeated fields? No, you can't. 3. In nested submessages, we have to call the INIT function for each of the submessages manually. Why doesnt the calling of the INIT function for the main message recursively call the INIT functions of the nested messages??? This becomes tedious when we have numerous nested messages. What INIT function were you referring to? I'm not aware of this INIT function in protobuf code base. Please let me know the solutions of these problems as soon as possible Thanks. -- 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 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 protobuf@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.
Re: [protobuf] Optional,Repated fields and Submessages
I am working on a C code base... INIT functions are used in this case instead of a constructor in C++. Thanks for your reply. On Thu, Jun 2, 2011 at 3:33 PM, Pherl Liu liuj...@google.com wrote: On Wed, Jun 1, 2011 at 3:45 PM, aara aara.cool...@gmail.com wrote: I actually have 3 questions. 1.When we specify default values for optional fields,the default value gets assigned automatically when we ourselves dont assign it a value. But why doesnt the has_member field get set to 1??? It still remains zero. To clarify the default value a bit: In your code, if you don't set_somefield() explicitly: 1) has_somefield() will return false. 2) somefield() will return the default value. 3) the default value won't be serialized into the wire. that said, if you don't set any field in your message, the serialized bytes will be empty. Each field has a default value, e.g. 0 for int, for string. You can override the default value by set [default=xxx] in the .proto file, but it won't change the behavior described above. 2.Can we not specify default values for repeated fields too??? The protoc-c compiler throws an error. Do you mean you want to set default values for repeated fields? No, you can't. 3. In nested submessages, we have to call the INIT function for each of the submessages manually. Why doesnt the calling of the INIT function for the main message recursively call the INIT functions of the nested messages??? This becomes tedious when we have numerous nested messages. What INIT function were you referring to? I'm not aware of this INIT function in protobuf code base. Please let me know the solutions of these problems as soon as possible Thanks. -- 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 protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en. -- Regards, Aaradhana -- 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 protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
Re: [protobuf] How can I set multi proto_path
Yes, you can. See: http://code.google.com/apis/protocolbuffers/docs/proto.html#generating On Wed, Jun 1, 2011 at 2:39 PM, jonason jonason...@hotmail.com wrote: can I set multi proto_path? -- 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 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 protobuf@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.
Re: [protobuf] Numeric range not supported?
We also have another internal thread talking about the restriction support for protobuf. Basically we think the restriction or value validation function of protobuf should be implemented in the upper layer due to various concerns.. On Mon, May 30, 2011 at 6:54 PM, Marco Tedone marco.ted...@gmail.comwrote: Hi all, I'm checking the protobuf language definition and I couldn't find anywhere support for numeric range. In XSD, for instance, one could have: simpleType name=ZeroToTen restriction base=int minInclusive value=0 / maxInclusive value=10 / /restriction /simpleType However I couldn't find equivalent translation in the proto language definition. I could find defaults and enums, but not number ranges. Regards, Marco -- 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 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 protobuf@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.
Re: [protobuf] Problem with reading class
That one will parse from binary encoded data. Looks like your sample_message.txt is in ASCII format. In short: Binary format: serialize: msg.writeTo() / msg.toByteArray() parsing: MyMessage.parseFrom() / builder.mergeFrom() ASCII format: serialize: msg.toString() / TextFormat.printToString() parsing: TextFormat.merge() You should use them in pair. On Thu, May 26, 2011 at 1:18 AM, ch007 ravithej...@gmail.com wrote: Hi all, I wrote a reading class to print the data in the message to the console. the problem is i am not able to print any thing on the console. code is running fine. I think the problem is with the following part. File myFile = new File (C:/Documents and Settings/ch007/Desktop/ sample_message.txt); FileInputStream fis = new FileInputStream(myFile); Good good = Good.parseFrom(fis); if(good==null) { System.out.println(problem in reading message); } if(good.hasMessageId()) { System.out.println(MessageId: +good.getMessageId()); } in the sample_message.txt there is messageid but in the output it is not printing any messaage id. Same problem with all other fields.I am not able to get any of the fields. I followed the address book tutorial and trid to implement this. please help me Is the below line correct? Nta2Sse nta2sse = Nta2Sse.parseFrom(fis); thanks -- 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 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 protobuf@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.
Re: [protobuf] Best Practices on updating generated Message object
You can probably use sub-builders in this case: e.g. myBuilder.getPriceBuilder().setValue(123); See http://code.google.com/apis/protocolbuffers/docs/reference/java-generated.html#messagein sub builders section. On Thu, May 26, 2011 at 2:58 PM, veaven vea...@gmail.com wrote: Hi, What's the best practices on updating generated Message objects? I use google-protobuf to generate Java classes according to proto file, since these classes are immutable so I need to use its Builder to copy/close the object and then update it. It is okay for a few update on the message object, however, it will not perform well if I do multiple update on its field in different methods several times, because it asked me to copy/clone the object everytime. I know I can pass Builder object instead of message object, but the builder object also asked me to copy/clone its reference. E.g. // I want to update MyObject's instance myobject MyObject.Builder myBuilder = MyObject .newBuilder( myobject); //copy clone myBuilder.setPrice(Price.newBuilder(tmdObject.getPrice()).setValue(123));// 1st copy clone myBuilder.setPrice(Price.newBuilder(tmdObject.getPrice()).setValue(456));// 2nd copy clone myobject = myBuilder.build(); Can we reduce the copyclone during update an object? Could you please let me know what is the best way to update an existing protobuf object? David -- 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 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 protobuf@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.
[protobuf] Re: Issue 296 in protobuf: Deploy protobuf-java 2.4.1 JAR to Maven Repository
Comment #2 on issue 296 by george.c...@gmail.com: Deploy protobuf-java 2.4.1 JAR to Maven Repository http://code.google.com/p/protobuf/issues/detail?id=296 protobuf 2.4.1 came out at the end of April. Is there an issue with the Java package that's holding up a corresponding Maven release? I would have presumed Java (and Maven, however much I personally dislike it) were important enough that keeping the Maven releases in sync version-number-wise with the main protobuf releases would be viewed as something worth while? Even if the plan is to let the version numbers diverge (which would be quite confusing) the current protobuf-java version, i.e. 2.4.0a, implies it's an alpha. Even if there are no actual code changes to be released maybe it's worth bumping the version number just to give that warm non-alpha feel to the thing. -- 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 protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
[protobuf] Re: Issue 296 in protobuf: Deploy protobuf-java 2.4.1 JAR to Maven Repository
Comment #3 on issue 296 by sergei.s...@gmail.com: Deploy protobuf-java 2.4.1 JAR to Maven Repository http://code.google.com/p/protobuf/issues/detail?id=296 Hardly surprising, given that maven ecosystem is systematically neglected by protobuf team. Protoc maven plugin is effectively abandoned, artifacts in the central repo are stale or out of sync with protobuf releases. I would rather have a java artifact in central for every protobuf release, even if there are no changes in java implementation. Having java artifact versions out of sync with the main package versions is very confusing. -- 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 protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
[protobuf] Re: Issue 294 in protobuf: PyIter_Next returns a New Reference so you must Py_DECREF it when done
Updates: Cc: f...@google.com Comment #1 on issue 294 by liuj...@google.com: PyIter_Next returns a New Reference so you must Py_DECREF it when done http://code.google.com/p/protobuf/issues/detail?id=294 Thanks for reporting this. Adding Frank to take a look. -- 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 protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
[protobuf] Re: Issue 296 in protobuf: Deploy protobuf-java 2.4.1 JAR to Maven Repository
Comment #5 on issue 296 by sergei.s...@gmail.com: Deploy protobuf-java 2.4.1 JAR to Maven Repository http://code.google.com/p/protobuf/issues/detail?id=296 Please have a look at the following guide: http://maven.apache.org/guides/mini/guide-central-repository-upload.html You may want to register with Sonatype -- you jump through the initial set-up hoops once, and then the whole process is automated: https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide -- 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 protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
Re: [protobuf] Numeric range not supported?
On Thu, Jun 2, 2011 at 5:55 PM, Wenbo Zhu wen...@google.com wrote: On Thu, Jun 2, 2011 at 3:41 AM, Pherl Liu liuj...@google.com wrote: We also have another internal thread talking about the restriction support for protobuf. Basically we think the restriction or value validation function of protobuf should be implemented in the upper layer due to various concerns.. Protobuf definition is different than schema for documents. Constraints may be specified externally or in the form of custom options. I wonder if there is any standard meta-schema language that could be applied to both XML and non-XML data. UML is probably not a good choice here. On Mon, May 30, 2011 at 6:54 PM, Marco Tedone marco.ted...@gmail.comwrote: Hi all, I'm checking the protobuf language definition and I couldn't find anywhere support for numeric range. In XSD, for instance, one could have: simpleType name=ZeroToTen restriction base=int minInclusive value=0 / maxInclusive value=10 / /restriction /simpleType However I couldn't find equivalent translation in the proto language definition. I could find defaults and enums, but not number ranges. Regards, Marco -- 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 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 protobuf@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.
[protobuf] Re: Numeric range not supported?
You can use custom field options to support validation of this type. Take a look at extending com.google.FieldOptions You can create an option field like max_inclusive and then access it at run-time from the FieldDescriptor and use the information for validation. Unfortunately this is still just a suggestion - you will still have to validate with custom-written code. PS: I have done this before and it worked out pretty well because the validation code did not have to have special information about the data structure, just access to the FieldDescriptor at run time. On May 30, 6:54 am, Marco Tedone marco.ted...@gmail.com wrote: Hi all, I'm checking the protobuf language definition and I couldn't find anywhere support for numeric range. In XSD, for instance, one could have: simpleType name=ZeroToTen restriction base=int minInclusive value=0 / maxInclusive value=10 / /restriction /simpleType However I couldn't find equivalent translation in the proto language definition. I could find defaults and enums, but not number ranges. Regards, Marco -- 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 protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.