Questions tagged [protocol-buffers]

For questions about Google's protocol buffers

Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages.

https://developers.google.com/protocol-buffers

7638 questions
45
votes
1 answer

Upgrading protobuf from version 2 to 3 - incompatible with protobuf default values

I'm trying to upgrade to using protobuf version 3, and stay backwards compatible with version 2. Seems to work except for one thing - in proto-2 you could set your own default values, but in proto 3, you can't. If you chose a default value in…
John Caron
  • 1,367
  • 1
  • 10
  • 15
45
votes
2 answers

'optional repeated' with google protobuf for Java

I am using Google Protobuf using java. I wrote a statement like optional repeated string users = 9; When I tried to compile I am getting an error like message.proto:39:57: Missing field number. All I wanted was to create an array of…
Harikrishnan
  • 3,664
  • 7
  • 48
  • 77
44
votes
2 answers

Google Protobuf ByteString vs. Byte[]

I am working with google protobuf in Java. I see that it is possible to serialize a protobuf message to String, byte[], ByteString, etc: (Source: https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/MessageLite) I…
Rahim Pirbhai
  • 445
  • 1
  • 4
  • 6
43
votes
5 answers

Google Protocol Buffers - Storing messages into file

I'm using google protocol buffer to serialize equity market data (ie. timestamp, bid,ask fields). I can store one message into a file and deserialize it without issue. How can I store multiple messages into a single file? Not sure how I can separate…
DD.
  • 21,498
  • 52
  • 157
  • 246
43
votes
14 answers

protoc-gen-go-grpc: program not found or is not executable

go version: go version go1.14 linux/amd64 go.mod module [redacted] go 1.14 require ( github.com/golang/protobuf v1.4.0-rc.2 google.golang.org/grpc v1.27.1 google.golang.org/protobuf v1.20.0 // indirect ) I am running the following…
Ayush Gupta
  • 8,716
  • 8
  • 59
  • 92
43
votes
4 answers

Thrift vs Protocol buffers

I've been using PB for quite a while now, but, Thrift has constantly been at the back of my mind. The primary advantages of thrift, as I see it are: Native collections (i.e, vector, set etc) vs PBs repeated providing functionality similar to, but…
please delete me
  • 711
  • 2
  • 9
  • 17
42
votes
11 answers

Correct format of protoc go_package?

I have an existing project in Go where I'm using Protocol buffers / gRPC. Until recent the go_package option was optional and the resulting Go package name would be the same as the proto package name. This file lives in the project root. The…
Tim
  • 1,585
  • 1
  • 18
  • 23
42
votes
5 answers

How to convert from Json to Protobuf?

I'm new to using protobuf, and was wondering if there is a simple way to convert a json stream/string to a protobuf stream/string in Java? For example, protoString = convertToProto(jsonString) I have a json string that I want to parse into a…
Karan Tibrewal
  • 467
  • 1
  • 5
  • 4
42
votes
1 answer

Import and usage of different package files in protobuf?

I have imported an other proto which having different package name than mine. For usage of messages from other package, have accessed that message with package name. For Example : other.proto package muthu.other; message Other{ required float…
Muthurathinam
  • 962
  • 2
  • 11
  • 19
42
votes
9 answers

Integrate Protocol Buffers into Maven2 build

I'm experimenting with Protocol Buffers in an existing, fairly vanilla Maven 2 project. Currently, I invoke a shell script every time I need to update my generated sources. This is obviously a hassle, as I would like the sources to be generated…
Max A.
  • 4,842
  • 6
  • 29
  • 27
42
votes
2 answers

How do I generate a .proto file from a C# class decorated with attributes?

Trying to get my mind around google protobuf. I found some implementation of protobuf in C# but they seems to lack one feature: the ability to generate .proto files automatically from an existing C# class decorated with attributes. The reason I want…
Stécy
  • 11,951
  • 16
  • 64
  • 89
41
votes
2 answers

Protobuf3: How to describe map of repeated string?

The Official documentation about map type says: map map_field = N; ...where the key_type can be any integral or string type (so, any scalar type except for floating point types and bytes). The value_type can be any…
lz96
  • 2,816
  • 2
  • 28
  • 46
41
votes
2 answers

google protobuf maximum size

I have some repeating elements in my protobuf message. At runtime the length of the message could be anything - I see some questions already asked like this one - [1]: Maximum serialized Protobuf message size I have a slightly different question…
Robin Bajaj
  • 2,002
  • 4
  • 29
  • 47
40
votes
3 answers

How to decode binary/raw google protobuf data

I have a coredump with encoded protobuf data and I want to decode this data and see the content. I have the .proto file which defines this message in raw protocol buffer. My proto file looks like this: $ cat my.proto message header { …
brokenfoot
  • 11,083
  • 10
  • 59
  • 80
40
votes
2 answers

How to design for a future additional enum value in protocol buffers?

One of the attractive features of protocol buffers is that it allows you extend the message definitions without breaking code that uses the older definition. In the case of an enum according to the documentation: a field with an enum type can only…
glennr
  • 2,069
  • 2
  • 26
  • 37