protocol-buffers

Does protobuf-net support nullable types?

情到浓时终转凉″ 提交于 2019-12-30 16:52:10
问题 Is it possible to generate nullable members in protobuf-net? message ProtoBuf1 { optional Int32? databit = 1; optional Nullable<bool> databool = 2; } 回答1: Yes, but it doesn't generate them by default if you are doing codegen from .proto. If this is just C#, of course, you don't need a .proto - just: [ProtoContract] public class ProgoBuf1 { [ProtoMember(1)] public int? Foo {get;set;} [ProtoMember(2)] public float? Bar {get;set;} } If you are working from .proto, you could consider copying and

gRPC / Protobuf interface versioning

只愿长相守 提交于 2019-12-30 04:03:31
问题 Let's say we use gRCP/Protobuf to connect many application. Those application are developped and released at their own team, with their own speed. Over time there will be different version of the the same app (e.g. desktop apps install on user PCs) that use different version on defined interface. While Protobuf is meant to allow backward compatibility, is there a way to know what version of interface is running at different points? The simplest implementation is to have interface version

How can I use proto3 with Hadoop/Spark?

梦想的初衷 提交于 2019-12-30 03:23:06
问题 I've got several .proto files which rely on syntax = "proto3"; . I also have a Maven project that is used to build Hadoop/Spark jobs (Hadoop 2.7.1 and Spark 1.5.2). I'd like to generate data in Hadoop/Spark and then serialize it according to my proto3 files. Using libprotoc 3.0.0, I generate Java sources which work fine within my Maven project as long as I have the following in my pom.xml: <dependency> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-java</artifactId> <version>3.0

Protocol Buffers versus JSON or BSON [closed]

空扰寡人 提交于 2019-12-29 10:06:25
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 months ago . 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 seem like good binary protocols for use over HTTP. I'm just wondering which would be better in the long run for a

How can we put a variant message ( one of a few message types ) inside a protobuf message?

你。 提交于 2019-12-29 06:48:14
问题 How can we put a variant message ( one of a few message types ) inside a protobuf message? message typeA { .... } message typeB { .... } message typeC { [typeB|typeA] payload; } 回答1: You need to do it like this: message TypeC { optional TypeA a = 1; optional TypeB b = 2; } If there are a lot of variants, you might also want to add a tag field so that you don't have to check has_*() for each one. This is covered in the Protobuf docs: https://developers.google.com/protocol-buffers/docs

google protobuf maximum size

心不动则不痛 提交于 2019-12-29 06:39:07
问题 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 here. If my JMS (Java Messaging service) provider (in this case my weblogic or tibco jms server) doesn't have any size limit on the max message size, will protocol buffer compiler complain at all about the maximum message size ? Does the performance

Sending Protobuf Messages with boost::asio

怎甘沉沦 提交于 2019-12-29 04:08:08
问题 I'm trying to hack a client together in C++ using Google's Protocol Buffers and boost::asio. My problem is that I don't know how I can feed the protobuf message to asio. What I have is this: // set up *sock - works PlayerInfo info; info.set_name(name); // other stuff Now I know that the following is wrong, but I'll post it anyways: size_t request_length = info.ByteSize(); boost::asio::write(*sock, boost::asio::buffer(info, request_length)); I got as far as that I know that I have to pack my

Sending Protobuf Messages with boost::asio

 ̄綄美尐妖づ 提交于 2019-12-29 04:06:13
问题 I'm trying to hack a client together in C++ using Google's Protocol Buffers and boost::asio. My problem is that I don't know how I can feed the protobuf message to asio. What I have is this: // set up *sock - works PlayerInfo info; info.set_name(name); // other stuff Now I know that the following is wrong, but I'll post it anyways: size_t request_length = info.ByteSize(); boost::asio::write(*sock, boost::asio::buffer(info, request_length)); I got as far as that I know that I have to pack my

Dictionary in protocol buffers

☆樱花仙子☆ 提交于 2019-12-29 03:56:06
问题 Is there any way to serialize a dictionary using protocol buffers, or I'll have to use Thrift if I need that? 回答1: People typically write down the dictionary as a list of key-value pairs, and then rebuild the dictionary on the other end. message Pair { optional string key = 1; optional string value = 2; } message Dictionary { repeated Pair pairs = 1; } 回答2: For future answer seekers, ProtoBuf now supports Maps natively: message MapMessage { map<string, string> MyMap = 1; } 回答3: You can check

What does the ProtoInclude attribute mean (in protobuf-net)

空扰寡人 提交于 2019-12-29 03:31:05
问题 In the ProtoBuf-Net implementation, what does the ProtoInclude attribute mean, and what does it do? An example would be appreciated. I saw it in this post and I'm not sure what it does. The example was: [Serializable, ProtoContract, ProtoInclude(50, typeof(BeginRequest))] abstract internal class BaseMessage { [ProtoMember(1)] abstract public UInt16 messageType { get; } } [Serializable, ProtoContract] internal class BeginRequest : BaseMessage { [ProtoMember(1)] public override UInt16