Re: [protobuf] Is there a C++ placement new() operator for messages?
On Tue, Oct 28, 2014 at 4:41 PM, Michael Wagner mikepwag...@gmail.com wrote: I would like to use Google Protocol Buffers in a memory constrained environment - not so much that the environment is low on memory as much as memory usage is tracked on a per subsystem basis. Generally, in this environment for other non-Google Protocol Buffers, I use the C++ placement new operator, which allows me to allocate a buffer from a specializes allocator and pass the address of that buffer to the new() operator. char* fooAllocation = memoryBroker-Allocate(MY_SUBSYSTEM_ID, MAX_FOO_SIZE); class Foo foo* = new (fooAllocation); When I am done with foo, I can call memoryBroker-Free(MY_SUBYSTEM_ID, MAX_FOO_SIZE, foo); That allows memoryBroker to keep accurate stats on memory usage by subsystem. I'd like to do the same with a GPB message. Is there some way to do that? Not possible with the current implementation but the next version of protobuf will include arena support and with that you will be able to allocate a message and all its sub-fields on an arena. For example: void ProcessData(const string data) { google::protobuf::ArenaOptions options; options.initial_block = memoryBroker-Allocate(MY_SUBSYSTEM_ID, MAX_FOO_SIZE); options.initial_block_size = MAX_FOO_SIZE; options.max_block_size = 0; // prevent arena to allocate heap memory by itself. { google::protobuf::Arena arena(options); MyMessage* message = google::protobuf::Arena::CreateMessageMyMessage(arena); if (message-ParseFromString(data)) { // use message... } cout Memory used for protobuf message: arena.SpaceUsed() endl; } memoryBroker-Free(MY_SUBSYSTEM_ID, MAX_FOO_SIZE, options.initial_block); } Mike -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
[protobuf] Python: metclass customization
Hi al! I'm seeking for way to replace original Protobuf's metaclasses with my own ones. What is the best way to do that? -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
[protobuf] Not able to import proto files
Hi, I am using protobuf and having the problem explain below: import statement problem http://stackoverflow.com/questions/26232622/google-protobuf-java-issue-in-import-of-proto-files-in-one-another Could someone please look into the same and let me know what could be done in order to resolve the same. Please let me know If any additional information is needed, any help would be appreciated. Thanks Regards, *Piyush Tiwari* *tiwari.piyu...@gmail.com* -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
Re: [protobuf] Not able to import proto files
The problem is not the imports. It's because you have only defined a message named a but are trying to reference something named A and hence the error message: A is not defined... To fix the problem, you need to update the message names. According to protobuf style guide, https://developers.google.com/protocol-buffers/docs/style they should be named in CamelCase style. And then, you probably will find the generated Java code still doesn't compile and that's because you set the outer-class name to exactly the same name which is already used for the message. So you need to update the java_outer_classname as well. After that they should compile just fine. On Wed, Oct 29, 2014 at 12:34 AM, piyush tiwari tiwari.piyu...@gmail.com wrote: Hi, I am using protobuf and having the problem explain below: import statement problem http://stackoverflow.com/questions/26232622/google-protobuf-java-issue-in-import-of-proto-files-in-one-another Could someone please look into the same and let me know what could be done in order to resolve the same. Please let me know If any additional information is needed, any help would be appreciated. Thanks Regards, *Piyush Tiwari* *tiwari.piyu...@gmail.com tiwari.piyu...@gmail.com* -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
[protobuf] Re: Python: metclass customization
For example, for such Python code, generated by Protobuf: class MyService(_service.Service): __metaclass__ = service_reflection.GeneratedServiceType DESCRIPTOR = _MYSERVICE class MyService_Stub(MyService): __metaclass__ = service_reflection.GeneratedServiceStubType DESCRIPTOR = _MYSERVICE Will such code, that will be inserted to insertion point by my own plugin, be a solid slution, that will not break after new Protobuf releases? class MyService_CustomStub(MyService): __metaclass__ = my_own.GeneratedServiceStubType DESCRIPTOR = MyService.DESCRIPTOR On Wednesday, October 29, 2014 10:31:39 AM UTC+3, Andrew Pashkin wrote: Hi al! I'm seeking for way to replace original Protobuf's metaclasses with my own ones. What is the best way to do that? -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
[protobuf] Re: Issue 226 in protobuf: Python API doesn't support reading/writing delimited messages
Comment #8 on issue 226 by vladimir...@gmail.com: Python API doesn't support reading/writing delimited messages https://code.google.com/p/protobuf/issues/detail?id=226 You have few use cases in your codebase? Lame reason. Disappointing. -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.