Re: [protobuf] Question around extending a "base" protobuf in 2.5.0 or 3.0.0 beta
On Mon, Feb 22, 2016 at 3:07 PM, Marcos Juarezwrote: > Is there a way to have a "base" protobuf with a set of common fields, and > then have projects/apps extend that with their own custom fields? We're > trying to minimize copy/pasting of the same fields all over the place, for > messages that will have a lot of common fields, that then need > specialization within different parts of the codebase. > > Say something like: > > message BaseProtobuf { > required int id = 1; > required int field1 = 2; > required string label = 3; > } > > and then multiple files like: > > message CustomProtobuf1 extend BaseProtobuf { > required int customId = 11; > optional string customLabel = 12; > } > > message CustomProtobuf2 extend BaseProtobuf { > required int anotherCustomId = 11; > optional string customLabel = 12; > } > > Of course, at compile time, the user would have to specify the location of > the base protobuf definitions, if any, since protoc would need all of them > to generate the java source code. > > I do know about the import functionality, but that's more targeted for > type and enum definitions, not for inheriting base fields, so it doesn't > really address my question above. > Protobuf doesn't support inheritance. I suggest using composition instead. Such as: message CustomProtobuf1 { optional BaseProtobuf base = 1; required int customId = 11; optional string customLabel = 12; } > > Thanks, > > Marcos Juarez > > -- > 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 https://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 https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
Re: [protobuf] Configuration Language for Protobufs
On Mon, Feb 22, 2016 at 3:28 PM, pcman312wrote: > Are there any good languages (with compilers) that let's you specify the > data within a proto rather than the proto itself? I want to create files > with configuration data in them, but they need to be compiled into proto > format. I know Google has GCL, but as far as I can tell that isn't > available in open source form, so I'm looking for an alternative. Ideally > I'd like to be able to write a file that has the configuration data, then > have it automatically compiled into a binary proto file as a part of my > build process. > You can write the configuration file in protobuf text format and then convert them to proto binary format using the protocol compiler in the build process. > 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 https://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 https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
Re: [protobuf] Transform data from one schema to another
On Mon, Feb 22, 2016 at 4:30 AM, Tim Richardsonwrote: > I have a data modelling problem and I'm wondering if protobuf could be the > right tool to help me solve this problem. > > I have data in one schema and i want to transform it to another schema. > > message Dataset { > required string title = 1; > required string description = 2; > } > message Study { > required string title = 1; > required string title = 2; > } > > > e.g I would like to transform two messages into a nested message. > > message Dataset { > required string title = 1; > required string description = 2; > repeated Study studies = 3; > > message Study { > required string title = 1; > required string title = 2; > } > > > Are there any features or patterns in protobuf which would help me with > this? > Do you have many different transformations that you want to do with a similar pattern? Protobuf's reflection API may be of help here. You can use the reflection API to inspect the message definitions and create new schemas. You can find examples of how to use the reflection API in the documentation of the Message interface: https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.message > > > -- > 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 https://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 https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
[protobuf] //:protobuf_java target not working
Hi bazel-discuss and protobuf, I am bringing in protobuf as an external bazel repository: git_repository( name = "protobuf_repo", commit = "32daf513ced8d51e8de6cc8d800cfc972c4df5d6", init_submodules = True, remote = "https://github.com/google/protobuf.git;, ) and using the protobuf_java target as a dependency in my bazel java libraries. This fails generating the following message: ... > # @protobuf_repo//:gen_well_known_protos_java [action 'Executing genrule @protobuf_repo//:gen_well_known_protos_java'] (cd /private/var/tmp/_bazel_rohit/a10731376421707628e091029859af4a/beam && \ exec env - \ PATH='' \ TMPDIR=/var/folders/p2/yz_3gtqd4z9d15l2ptzcjbsmgn/T/ \ /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; bazel-out/host/bin/external/protobuf_repo/protoc --java_out=bazel-out/local_darwin-fastbuild/genfiles/external/protobuf_repo/wellknown.jar -Isrc external/protobuf_repo/src/google/protobuf/any.proto external/protobuf_repo/src/google/protobuf/api.proto external/protobuf_repo/src/google/protobuf/compiler/plugin.proto external/protobuf_repo/src/google/protobuf/descriptor.proto external/protobuf_repo/src/google/protobuf/duration.proto external/protobuf_repo/src/google/protobuf/empty.proto external/protobuf_repo/src/google/protobuf/field_mask.proto external/protobuf_repo/src/google/protobuf/source_context.proto external/protobuf_repo/src/google/protobuf/struct.proto external/protobuf_repo/src/google/protobuf/timestamp.proto external/protobuf_repo/src/google/protobuf/type.proto external/protobuf_repo/src/google/protobuf/wrappers.proto && mv bazel-out/local_darwin-fastbuild/genfiles/external/protobuf_repo/wellknown.jar bazel-out/local_darwin-fastbuild/genfiles/external/protobuf_repo/wellknown.srcjar') ERROR: /private/var/tmp/_bazel_rohit/a10731376421707628e091029859af4a/external/protobuf_repo/BUILD:461:1: Couldn't build file external/protobuf_repo/wellknown.srcjar: Executing genrule @protobuf_repo//:gen_well_known_protos_java failed: bash failed: error executing command /bin/bash -c ... (remaining 1 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1. src: warning: directory does not exist. external/protobuf_repo/src/google/protobuf/any.proto: File does not reside within any path specified using --proto_path (or -I). You must specify a --proto_path which encompasses this file. Note that the proto_path must be an exact prefix of the .proto file names -- protoc is too dumb to figure out when two paths (e.g. absolute and relative) are equivalent (it's harder than you think). The warning has the clue, and if I were to replace the import path (-Isrc) with -Iexternal/protobuf_repo/src. Is there an equivalent of bazel workspace_root that can be used for the cmd in this genrule in protobuf/BUILD? genrule( name = "gen_well_known_protos_java", srcs = WELL_KNOWN_PROTOS, outs = [ "wellknown.srcjar", ], cmd = "$(location :protoc) --java_out=$(@D)/wellknown.jar" + " -Isrc $(SRCS) " + " && mv $(@D)/wellknown.jar $(@D)/wellknown.srcjar", tools = [":protoc"], ) Thanks, Rohit Saboo -- 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 https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
[protobuf] Question around extending a "base" protobuf in 2.5.0 or 3.0.0 beta
Is there a way to have a "base" protobuf with a set of common fields, and then have projects/apps extend that with their own custom fields? We're trying to minimize copy/pasting of the same fields all over the place, for messages that will have a lot of common fields, that then need specialization within different parts of the codebase. Say something like: message BaseProtobuf { required int id = 1; required int field1 = 2; required string label = 3; } and then multiple files like: message CustomProtobuf1 extend BaseProtobuf { required int customId = 11; optional string customLabel = 12; } message CustomProtobuf2 extend BaseProtobuf { required int anotherCustomId = 11; optional string customLabel = 12; } Of course, at compile time, the user would have to specify the location of the base protobuf definitions, if any, since protoc would need all of them to generate the java source code. I do know about the import functionality, but that's more targeted for type and enum definitions, not for inheriting base fields, so it doesn't really address my question above. Thanks, Marcos Juarez -- 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 https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
[protobuf] Transform data from one schema to another
I have a data modelling problem and I'm wondering if protobuf could be the right tool to help me solve this problem. I have data in one schema and i want to transform it to another schema. message Dataset { required string title = 1; required string description = 2; } message Study { required string title = 1; required string title = 2; } e.g I would like to transform two messages into a nested message. message Dataset { required string title = 1; required string description = 2; repeated Study studies = 3; message Study { required string title = 1; required string title = 2; } Are there any features or patterns in protobuf which would help me with this? -- 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 https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
[protobuf] extract_includes.bat file path with spaces does not copy any of the headers on Windows 10 System
I was going to write this as an Issue on the Github, but thought i'd ask here instead prior to making a issue out of something that may not be one. This was during an attempt to just get the tutorial working. I'm running on a Windows 10 system, and using VS 2013. I was attempting to run the extract_includes.bat in my release directory that was compiled using nmake, and nothing was copying over. Running tests.exe worked fine though. In either case, I needed to modify the .bat file to include quotes ("") around the file paths that had spaces. I'm not sure if this is necessarily an issue or just due to my setup. I'd be interested in perhaps tracking down how the .bat is being created and see if it's related to the actual creation. But, i don't want to go searching down a rabbit hole if it's just a problem that i created myself. Any tips or suggestions? Thanks. -- 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 https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
[protobuf] Configuration Language for Protobufs
Are there any good languages (with compilers) that let's you specify the data within a proto rather than the proto itself? I want to create files with configuration data in them, but they need to be compiled into proto format. I know Google has GCL, but as far as I can tell that isn't available in open source form, so I'm looking for an alternative. Ideally I'd like to be able to write a file that has the configuration data, then have it automatically compiled into a binary proto file as a part of my build process. -- 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 https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
[protobuf] Re: Unable to get through error: Protocol message contained an invalid tag (zero).
Unable to get thhrocol error: protocol messages -- 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 https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.