protocol-buffers

Protobuf doesn't serialize default values

丶灬走出姿态 提交于 2019-12-06 06:29:15
I'm using Protobuf for python. I've been trying to use default values but everytime I run SerializeToString() i get nothing. For example, here is my .proto file object message Test{ optional string lol = 1 [default="HI"]; optional int32 num = 2 [default=200]; } I run test = packets_pb2.Test() print(test.num) print(test.SerializeToString()) and get 200 for print(test.num) but no results (empty) for SerializeToString() I want my default values to be serialized. Any idea how to get this done? Thanks in advance. This is working as intended. Default values are not sent on the wire. Instead, the

Linking protobuf library with code (Google protocol buffers)

烈酒焚心 提交于 2019-12-06 03:20:35
问题 I am getting linking error when I try to compile a test code. I'm using cygwin on windows 7. Initial steps like ./configure, make, make test & make install went fine I'm also able to generate .pb.cc and .pb.h with protoc command. But when I try to compile my test code, it gets many linking errors. I'm sure those errors are because it is unable to link to library. Cygwin has protobuf static library and linking library in /usr/local/lib . include files are present in /usr/local/include I tried

How to send / receive binary data serialized with Protocol Buffers using ZMQ

青春壹個敷衍的年華 提交于 2019-12-06 03:15:00
I need to send an object (serialized with GPB) on a ZMQ socket. Currently the code have an extra copy. How do I directly write serialized array into message_t s data? ABT_CommunicationProtocol introPacket; // Fill the packet message_t introMessage; size_t dataLenght = introPacket.ByteSize(); char* temp = new char[dataLenght]; introPacket.SerializeToArray(temp, dataLenght); // write data to temp memcpy(introMessage.data(), temp, dataLenght); // copy data to message this->serverRquest.send(introMessage); Don't use zmq_send but zmq_sendmsg int cgi_msg_cnx_pool::PbToZmq(::google::protobuf::Message

What's the different between .proto and .prototxt file

南楼画角 提交于 2019-12-06 03:01:37
问题 In caffe project, there are both .proto file and .prototxt file. From Google Protocol Buffer documentation, .proto file defines the protocol, so what about the .prototxt , is it defined in Google Protocol Buffer, what's the different between them? 回答1: The .proto file is used to describe the structure (the 'protocol') of the data to be serialized. The protobuf compiler can turn this file into python/or C++/or Java code to serialize and deserialize data with that structure For the .prototxt

Data format compatibility between protobuf versions

末鹿安然 提交于 2019-12-06 02:13:36
问题 I was wondering if protocol buffer's serialized data format remains constant across protobuf compiler and client library versions. In other words, do I need to use the same compiler version to generate my Python, Java, and C++ classes? And do these clients all need to use the same version of protobuf libraries? This post sort of addresses my question, but its accepted answer is specific to the OP's protobuf version. 回答1: Yes, that is pretty much the idea. It shouldn't matter which library you

Protocol Buffers Java RPC Stack

☆樱花仙子☆ 提交于 2019-12-05 23:21:43
问题 According to this Wikipedia entry: "Protocol Buffers is very similar to Facebook’s Thrift protocol, except it does not include a concrete RPC stack to use for defined services. Since Protocol Buffers was open sourced, a number of RPC stacks have emerged to fill this gap." However, there are no examples of RPC stacks cited. Can anyone suggest a Java-based implementation of an RPC stack? 回答1: If you want Java-based RPC stack, it's RMI. However, it doesn't work well cross platform. I've been

Dropwizard and Protocol Buffers by example

霸气de小男生 提交于 2019-12-05 22:51:18
Please note: Although this question specifically mentions Dropwizard, I believe anyone with Jersey/JAX-RS experience should be able to answer this question, as I would imagine Dropwizard is just following Jersey/JAX-RS conventions under the hood. I have a Dropwizard service that reds/writes in JSON and works beautifully. I would like to now switch it to read/write binary data (to minimize network bandidth). I see there is the Dropwizard-Protobuf lib but I have a few concerns about implementing binary serialization in Dropwizard. First off, here's the important stuff from my current (JSON

Protocol Buffers with Extensions

巧了我就是萌 提交于 2019-12-05 22:08:13
I'm perhaps overlooking something, but I'm attempting to wrestle protocol buffers into an easy method for providing extensions later. That seems a bit unclear so I'll jump directly into the problem. I am writing an assembly to support various tasks, one of which includes describing structured data. Perfect time to use protocol buffers. The primary class to use protocol buffers is called StateDefinition. Here's the .proto file I came up with for it: package Kannon.State; message StateDefinition { enum StateTypes { GRAPHICS = 0; AUDIO = 1; MIND = 2; PHYSICS = 3; NETWORK = 4; GENERIC = 5; }

What are features of using Proguard in project with Protocol Buffers?

梦想与她 提交于 2019-12-05 21:15:54
I have a project in where Google Protocol Buffers are used. Once I try to obfuscate it with ProGuard it seems that protobuf causes problem. All my own classes I package into mybuildedclasses.jar . Google code is packaged into protbuf.jar mybuildedclasses.jar protobuf.jar other external jars After that I am trying to obfuscate mybuildedclasses.jar . Config file is similar to this one . Eventually all jars are packaged inside another fat jar. I run the program and once message is tried to be sent this kind of Exceptions are printed. Caused by: java.lang.RuntimeException: Generated message class

does protobuf need a network packet header?

为君一笑 提交于 2019-12-05 19:37:34
问题 I am using 'protobuf' for C/S network program using TCP. here is my steps for client: 1, pack data into a 'protobuf' 2, get size in bytes of the pack and construct a length-prefix frame 3, write the frame+pack to socket and then the server: 1, read Length-prefix frame from socket and get the length N 2, read N bytes from socket and fill the data into protobuf instance 3, get "value"s from protobuf by "key"s it seems a little complicated I think, is there some kind of auto-generated length