protocol-buffers

Google protocol buffers and servlets

狂风中的少年 提交于 2019-12-04 19:25:08
I am wondering how I can use google protocol buffers to accept a request and send a response back to a client? I am thinking about writing a servlet which will take a request. Is the following trail of thought the correct way to implement this: 1. Have a .proto file which is the message definition for the incoming request. 2. Write a servlet which accepts this request, does various tasks like querying database and then sends a response. Will this response require a separate .proto message definition with all the fields that make up the response? 3. Will the client just invoke the doGet()

Extending Protobuf Messages

守給你的承諾、 提交于 2019-12-04 19:00:41
问题 I have many different schemas, however there are a set of fields which every schema contains. I was wondering if there was a way to have a different schema extend a parent schema and inherit its fields. For example this is what I want: message Parent { required string common1 = 0; optional string common2 = 1; } message Child1 { // can we extend the Parent? // I want common1, common2 to be fields here required int c1 = 2; required string c2 = 3; } message Child2 { // can we extend Parent? // I

How to determine message type in protobuf so that I can use that type.parsefrom(byte[ ])

非 Y 不嫁゛ 提交于 2019-12-04 17:42:11
问题 I am trying to send protobuf data from cpp side to java side. I have multiple message types defined in .proto On Cpp side, I have enums for every message type and I am adding it to the buf output as follows: uint8_t* __temp = (uint8_t*)(buf); *__temp++ = (type) >> 8; *__temp = (type) & 0x00FF; How do I get this 'type' that I have added to the buf, so that I can achieve something like MessageType parseFrom(byte[] data); 回答1: It is not clear what is the exact requirement. But I assume you are

Generating a Protocol Buffers definition

我怕爱的太早我们不能终老 提交于 2019-12-04 17:28:31
I have a large set of XML files of a propriatary schema -the XML files define binary communication protocol (message structure). I'd like to leverage Google's protocol buffers technology. I am using existing code to load the XML files into an object model (in memory). I'd like to generate a .proto file from that object model. so basically what I am looking for is code/library (in C#/.NET) that represents the .proto file format as an object model and can save that object model into a .proto file. I took a look at Jon Skeet's dotnet-protobufs, I think I understand what it does (generate c# code

How to use protobuf-net with immutable value types?

我怕爱的太早我们不能终老 提交于 2019-12-04 17:28:15
问题 Suppose I have an immutable value type like this: [Serializable] [DataContract] public struct MyValueType : ISerializable { private readonly int _x; private readonly int _z; public MyValueType(int x, int z) : this() { _x = x; _z = z; } // this constructor is used for deserialization public MyValueType(SerializationInfo info, StreamingContext text) : this() { _x = info.GetInt32("X"); _z = info.GetInt32("Z"); } [DataMember(Order = 1)] public int X { get { return _x; } } [DataMember(Order = 2)]

use protobuf3 with some lib which depends on protobuf2 in Java

随声附和 提交于 2019-12-04 17:02:09
I'm using protobuf3 to represent our data, while we need hbase to store the data, it seems like hbase depends on protobuf2. When i write the following line to create our hbase table admin.createTable(desc); then I got an Excepiton: NoClassDefFoundError: com/google/protobuf/LiteralByteString I've tried using gradle's shadow plugin to relocate com.google.protobuf to shadow.google.com, then it throw a similar message NoClassDefFoundError: shadow/google/protobuf/LiteralByteString . Create a sub-project, and name it 'hbase-wrapper' Move the dependencies for hbase to the new project Shadow protobuf

How would you encode a Map<String, Object> using Protocol Buffers?

[亡魂溺海] 提交于 2019-12-04 16:52:12
问题 I'm trying to use Protocol Buffers for message serialization. My message format should contain Map< String, Object > entries ... but how do I write the .proto definition? As far as I know, Protocol Buffers does not have a build-in Map type. I could model around that using repeating fields. But the big problem I have is, that you need to define all your types. I want my message to be flexible, so I can't specify the types. Any ideas? 回答1: I'd model a tuple with a key and a value (probably one

protobuf-net enum serialization

岁酱吖の 提交于 2019-12-04 16:39:56
问题 What needs to be done in order to serialize enums with protobuf-net? I'm getting the below error when serializing a class having an enum property, if the DataMember attribute is removed from the property declaration it works fine. "System.InvalidOperationException: Only data-contract classes (and lists/arrays of such) can be processed" 回答1: I suspect they are actually 2 different scenarios, but with regard to the code sample added by Andrew, this is because it can't figure out (in advance)

I want to downgrade my protobuf version in order to working with gcc-4.9 and matlab. so have anybody can taking a good solution?

送分小仙女□ 提交于 2019-12-04 16:29:36
xy@xy-desktop:/usr/bin$ sudo apt-get install libprotobuf-dev protobuf-compiler Reading package lists... Done Building dependency tree Reading state information... Done libprotobuf-dev is already the newest version (2.6.1-1.3). protobuf-compiler is already the newest version (2.6.1-1.3). 0 upgraded, 0 newly installed, 0 to remove and 361 not upgraded. xy@xy-desktop:/usr/bin$ protoc --version libprotoc 3.0.2 It seems you have installed protobuf 3.0.2 from some external source whose binary is probably in /usr/local/bin, while the protobuf 2.6.1 installed from repo has its binary in /usr/bin. Try

Several shared object using same proto leading the the error: file already exists in database

南笙酒味 提交于 2019-12-04 15:58:42
An error related to protobuf3 I have a project that have an c++ executable core, and several shared objects (.so, .dll) called plugins. When the core launches, it will load those plugins with dlopen. The core and plugins using protobuf as communication protocol, so they have to compile the generated .pb.cc and .ph.h files into their binaries to have the copy of the serializer/deserializer. And libprotobuf.so link to both the core and plugins. When I launch the core, it crushes with error: file already exists in database, same error in #863 I'm using protobuf-3 beta2, and Ubuntu 14.04. This