8,446 questions
413
votes
4
answers
242k
views
Why were `required` and `optional` removed in Protocol Buffers 3?
I noticed that required and optional have been removed in the new syntax.
Why were required/optional removed in proto3? Such keywords introduce constraints which should improve robustness.
proto2:
...
320
votes
15
answers
154k
views
Biggest differences of Thrift vs Protocol Buffers? [closed]
What are the biggest pros and cons of Apache Thrift vs Google's Protocol Buffers?
266
votes
9
answers
373k
views
How to define an optional field in protobuf 3
I need to specify a message with an optional field in protobuf (proto3 syntax). In terms of proto 2 syntax, the message I want to express is something like:
message Foo {
required int32 bar = 1;
...
246
votes
2
answers
215k
views
Can I define a grpc call with a null request or response?
Does the rpc syntax in proto3 allow null requests or responses?
e.g. I want the equivalent of the following:
rpc Logout;
rpc Status returns (Status);
rpc Log (LogData);
Or should I just create a null ...
245
votes
1
answer
91k
views
google protocol buffers vs json vs XML [closed]
I would like to know the merits & de-merits of
Google Protocol Buffers
JSON
XML
I want to implement one common framework for two application, one in Perl and second in Java. So, would like to ...
240
votes
9
answers
85k
views
protobuf vs gRPC
I try to understand protobuf and gRPC and how I can use both. Could you help me understand the following:
Considering the OSI model what is where, for example is Protobuf at layer 4?
Thinking through ...
164
votes
1
answer
75k
views
What's the difference between Protocol Buffers and Flatbuffers?
Both are serialization libraries and are developed by Google developers. Is there any big difference between them? Is it a lot of work to convert code using Protocol Buffers to use FlatBuffers?
149
votes
3
answers
255k
views
Date and time type for use with Protobuf
I'm considering to use Protocol Buffers for data exchange between a Linux and a Windows based system.
Whats the recommended format for sending date/time (timestamp) values? The field should be small ...
140
votes
15
answers
264k
views
Installing Google Protocol Buffers on mac
I would like to install the older version of Google Protocol Buffers (protobuf-2.4.1) on Mac using the command line/Terminal app.
I tried with brew install protobuf, but the latest version 2.5.0 has ...
140
votes
4
answers
169k
views
How to assign to repeated field?
I am using protocol buffers in python and I have a Person message
repeated uint64 id
but when I try to assign a value to it like:
person.id = [1, 32, 43432]
I get an error: Assigment not allowed for ...
135
votes
6
answers
44k
views
What are the key differences between Apache Thrift, Google Protocol Buffers, MessagePack, ASN.1 and Apache Avro?
All of these provide binary serialization, RPC frameworks and IDL. I'm interested in key differences between them and characteristics (performance, ease of use, programming languages support).
If you ...
117
votes
7
answers
172k
views
Protobuf to json in python
I have an object that I de-serialize using protobuf in Python. When I print the object it looks like a python object, however when I try to convert it to json I have all sorts of problems.
For ...
112
votes
19
answers
215k
views
Error "protoc-gen-go: program not found or is not executable"
I am trying to build a sample application with Go gRPC, but I am unable to generate the code using "protoc"
I have installed the required libraries and Go packages using:
go get -u google....
110
votes
3
answers
105k
views
What does the protobuf text format look like?
Google Protocol Buffers can not only be serialized in binary format, also be serialized as text, known as textproto. However I can't easily find examples of such text; what would it look like?
...
108
votes
2
answers
46k
views
TensorFlow saving into/loading a graph from a file
From what I've gathered so far, there are several different ways of dumping a TensorFlow graph into a file and then loading it into another program, but I haven't been able to find clear examples/...
104
votes
11
answers
140k
views
How to solve "AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key"?
I encountered it while executing from object_detection.utils import label_map_util in jupyter notebook. It is actually the tensorflow object detection tutorial notebook(it comes with the tensorflow ...
102
votes
2
answers
64k
views
Protobuf RPC Service method without parameters
I'm trying to describe an RPC service using Google's Protocol Buffers
service WhoamiService {
rpc WhoAreYou() returns (Whoami) {}
}
message Whoami {
optional bytes request_id = 1;
optional ...
99
votes
5
answers
79k
views
What is the correct Protobuf content type?
JSON has application/json as a standard. For protobuf some people use application/x-protobuf, but I saw something as odd as application/vnd.google.protobuf being proposed. Do we have an RFC or some ...
98
votes
4
answers
64k
views
Protocol Buffers versus JSON or BSON [closed]
Does anyone have any information on the performance characteristics of Protocol Buffers versus BSON (binary JSON) or versus JSON in general?
Wire size
Serialization speed
Deserialization speed
These ...
93
votes
17
answers
291k
views
ImportError: No module named google.protobuf
I am following this guide and using the exact sample of addressbook.proto.
Post the content of compiler generated addressbook_pb2.py file as well.
When I run the following simple program, there is ...
93
votes
5
answers
103k
views
Google Protocol Buffers: JavaScript Example
Is it a good choice to use Google Protocol Buffers in JavaScript or is it better to do it with JSON?
Also it'd be great if someone can give me a simple example about Protocol Buffers implementation ...
92
votes
7
answers
184k
views
Error using import in .proto file
I tried importing a proto file named test1.proto to another proto file named test2.proto using the import statement
import "com/test/test1.proto";
But i get the following error
com/test/test1.proto:...
91
votes
4
answers
71k
views
Protocol Buffer vs Json - when to choose one over the other?
Can anyone explain when to use protocol buffer instead of JSON (and vice versa) for a microservices architecture? Both for synchronous and asynchronous communication.
90
votes
3
answers
64k
views
Why are there no custom default values in proto3?
The proto2 version of Protocol Buffers allows to specify default values for message elements:
optional double scaling_factor = 3 [default = 1.0];
Why is this no longer possible in proto3? I consider ...
89
votes
4
answers
97k
views
How do I represent a UUID in a protobuf message?
I want to attach a UUID to a field in my protobuf User message example.
message User {
// field containing id as UUID type
required string email;
optional string name;
}
I know that protobuf ...
88
votes
1
answer
85k
views
How to return an array in Protobuf service rpc
I have the following schema in my .proto file:
service MyService {
rpc GetItem (ItemQuery) returns (Item) {
}
}
message ItemQuery {
int id = 1;
}
message Item {
int id = 1;
...
85
votes
8
answers
48k
views
How to bring a gRPC defined API to the web browser
We want to build a Javascript/HTML gui for our gRPC-microservices. Since gRPC is not supported on the browser side, we thought of using web-sockets to connect to a node.js server, which calls the ...
84
votes
4
answers
163k
views
Handling null values in protobuffers
I am working on something which fetches data from database and constructs protobuff message. Given the possibility that null values can be fetched from the database for certain fields , I will get ...
84
votes
2
answers
97k
views
Inheritance in protocol buffers
How to handle inheritance in Google Protocol Buffers 3.0?
Java equivalent code:
public class Bar {
String name;
}
public class Foo extends Bar {
String id;
}
What would be Proto ...
83
votes
1
answer
92k
views
How to get top-level protobuf enum value name by number in python?
For example, I have proto-file File.proto:
enum Test {
ONE = 1;
TWO = 2;
}
I generate file File_pb2.py with protoc from File.proto.
I want in a python-code get string "ONE" (that corresponds to ...
82
votes
11
answers
224k
views
Java: JSON -> Protobuf & back conversion
I have an existing system, which is using protobuf-based communication protocol between GUI and server. Now I would like to add some persistence, but at the moment protobuf messages are straight ...
81
votes
1
answer
44k
views
Protocol buffer: does changing field name break the message?
With protocol buffer, does changing field name of a message still let it compatible backward? I couldn't find any cite about that.
Eg: original message
message Person {
required string name = 1;
...
79
votes
3
answers
63k
views
AttributeError: Assignment not allowed to composite field "task" in protocol message object
I'm using protocol-buffers python lib to send data,but it's have some problems, so
Traceback (most recent call last):
File "test_message.py", line 17, in <module>
ptask.task = task
File ...
78
votes
5
answers
89k
views
Protobuf cannot find shared libraries
I have installed protobuf by using following commands:
./configure
make
make check
make install
However when I run protoc I get following error:
protoc: error while loading shared libraries: ...
76
votes
16
answers
100k
views
Unable to build protobuf to go endpoint
using protobuf version 2.6.1 ( which i installed via homebrew)
I am trying to run
$ protoc --go_out=../cloud/ *.proto
I keep receiving this error.
$ protoc-gen-go: program not found or is not ...
76
votes
1
answer
128k
views
How to add an int array in a protobuf message
I have to compose a protobuf message which should have 1 integer variables and a integer array.
package protobuf;
message myProto {
optional uint32 message_id =1;
optional int update = 2;
//here I ...
74
votes
2
answers
61k
views
Splitting protocol buffer definitions into multiple .proto files
I would like to include a protocol definition file in another protocol file. For example:
// base.proto:
message P_EndPoint {
required int32 id = 1;
required string host = 2;
required int32 ...
73
votes
1
answer
43k
views
Protobuf: Will set_allocated_* delete the allocated object?
I have this small protobuf code (simplified, only the necessary is contained):
message ParamsMessage {
required int32 temperature = 1;
}
message MasterMessage {
enum Type { GETPARAMS = 1; ...
72
votes
11
answers
37k
views
Are there C++ equivalents for the Protocol Buffers delimited I/O functions in Java?
I'm trying to read / write multiple Protocol Buffers messages from files, in both C++ and Java. Google suggests writing length prefixes before the messages, but there's no way to do that by default (...
72
votes
3
answers
155k
views
How to encode byte[] in proto buffs
Is there an equivalent to int8 or byte type in proto buffs? I would like to send a byte array object.
71
votes
8
answers
67k
views
Performance comparison of Thrift, Protocol Buffers, JSON, EJB, other?
We're looking into transport/protocol solutions and were about to do various performance tests, so I thought I'd check with the community if they've already done this:
Has anyone done server ...
71
votes
2
answers
27k
views
Protocol buffers - unique numbered tag - clarification?
I'm using protocol buffers and everything is working fine. except that the fact that I don't understand - why do I need the numbered tags in the proto file :
message SearchRequest {
required ...
70
votes
11
answers
29k
views
boost serialization vs google protocol buffers? [closed]
Does anyone with experience with these libraries have any comment on which one they preferred? Were there any performance differences or difficulties in using?
69
votes
8
answers
43k
views
Generate Protobuf documentation? [closed]
Does anyone know of a good tool to generate Google Protobuf documentation using the .proto source files?
66
votes
6
answers
61k
views
what's the right way to do polymorphism with protocol buffers?
I'm trying to long-term serialize a bunch of objects related by a strong class hierarchy in java, and I'd like to use protocol buffers to do it due to their simplicity, performance, and ease of ...
66
votes
1
answer
24k
views
Is there a definitive *nix command line tool for inspecting protocol buffers? [closed]
I'm looking for a command-line utility that will, at a minimum, render binary protobuf data in human-readable form. Filtering and selection options (along the lines of cut for text) would be nice, ...
65
votes
13
answers
155k
views
Install Protocol Buffers on Windows
I am unable to find clear instructions to install Google Protocol Buffers (including compiler) on Windows x64 platform.
I went through the instructions README file for compiler and source:
For ...
62
votes
2
answers
58k
views
What is the point of google.protobuf.StringValue?
I've recently encountered all sorts of wrappers in Google's protobuf package. I'm struggling to imagine the use case. Can anyone shed the light: what problem were these intended to solve?
Here's ...