天道酬勤,学无止境

protocol-buffers

Protobuf-net creating typemodel with interface and abstract baseclass

I'm trying to serialize a model using the great Protobuf-NET. I cannot use the attributes (objects are unknown at compile-time),so I constructed a TypeModel. My object model consist of a class TestDataObject, this class has a property of ITestDataExtension. The abstract baseclass TestDataExtensionBase implements this interface and the class TestDataExtension (myDataObjectExtA in code) inherits from this baseclass. My TypeModel is constructed like this: System.IO.MemoryStream tmpMemoryStream = new System.IO.MemoryStream(); RuntimeTypeModel model = TypeModel.Create(); MetaType basetype = model

2021-11-29 02:38:11    分类:问答    c#   .net   protocol-buffers   protobuf-net

Protocol buffers and UTF-8

The history of Encoding Schemes / multiple Operating Systems and Endian-nes have led to a mess in terms of encoding all forms of string data (--i.e., all alphabets); for this reason protocol buffers only deals with ASCII or UTF-8 in its string types, and I can't see any polymorphic overloads that accept the C++ wstring. The question then is how is one expected to get a UTF-16 string into a protocol buffer ? Presumably I need to keep the data as a wstring in my application code and then perform a UTF-8 conversion before I stuff it into (or extract from) the message. What is the simplest -

2021-11-29 01:49:41    分类:问答    c++   unicode   utf-8   protocol-buffers   portability

Facing NoSuchMethodError for io.netty.util.AttributeKey.valueOf() method with grpc and protobuf Hello world example

After running GreetingServerTest.java tests I am getting below given errors. I am using grpc 1.1.0-SNAPSHOT libraries and trying to implement basic Helloword example of grpc given in there git repo. Can anybody please suggest which libraries I am missing or there's anything else I need to do. java.lang.NoSuchMethodError: io.netty.util.AttributeKey.valueOf(Ljava/lang/Class;Ljava/lang/String;)Lio/netty/util/AttributeKey; at io.grpc.netty.Utils.<clinit>(Utils.java:87) at io.grpc.netty.NettyServer.allocateSharedGroups(NettyServer.java:187) at io.grpc.netty.NettyServer.start(NettyServer.java:116)

2021-11-29 01:20:59    分类:问答    java   maven-2   netty   protocol-buffers   grpc-java

Android protobuf nano usage

I am trying to generate java files from below proto file using protobuf nano. I got some basic instruction on how to proceed in this SO thread. I have this proto file, personal.proto: package tutorial; option java_package = "com.example.tutorial"; option java_outer_classname = "AddressBookProtos"; message Person { required string name = 1; required int32 id = 2; optional string email = 3; enum PhoneType { MOBILE = 0; HOME = 1; WORK = 2; } message PhoneNumber { required string number = 1; optional PhoneType type = 2 [default = HOME]; } repeated PhoneNumber phone = 4; } message AddressBook {

2021-11-28 22:59:36    分类:问答    java   android   maven   protocol-buffers

Maximum serialized Protobuf message size

Is there a way to get the maximal size of a certain protobuf message after it will be serialized? I'm referring to messages that don't contain "repeated" elements. Note that I'm not referring to the size of a protobuf message with a specific content, but to the maximum possible size that it can get to (in the worst case).

2021-11-28 19:28:18    分类:问答    protocol-buffers

Using Protocol Buffers for implementing RPC in ZeroMQ

I have a simple setup of one client and one server. The client wants to execute a method in the server using ZeroMQ for communications. I am going to use the REQ and REP sockets because they are suitable for this use case. Nevertheless I have a doubt about the protobuf definitions. I think these two options can be used for achieving the goal: message ControlService{ string control = 1; int32 serverId = 2; bool block = 3; double temperature = 4; } Where "control" contains the name of the method to be executed remotely. The other alternative can be: message InputParameters{ int32 serverId = 1

2021-11-28 10:44:38    分类:问答    protocol-buffers   zeromq

自动将 protobuf 规范编译为 setup.py 中的 python 类(Automate compilation of protobuf specs into python classes in setup.py)

问题 我有一个 python 项目,它使用 google protobufs 作为通过网络进行通信的消息格式。 从.proto文件生成Python文件是直截了当使用protoc程序。 如何为项目配置我的setup.py文件,以便它自动调用protoc命令? 回答1 在类似的情况下,我最终得到了这段代码(setup.py,但其编写方式允许提取到某些外部 Python 模块中以供重用)。 请注意,我从 protobuf 源代码分发的 setup.py 文件中获取了 generate_proto 函数和一些想法。 from __future__ import print_function import os import shutil import subprocess import sys from distutils.command.build_py import build_py as _build_py from distutils.command.clean import clean as _clean from distutils.debug import DEBUG from distutils.dist import Distribution from distutils.spawn import find_executable from nose.commands

2021-11-28 06:59:03    分类:技术分享    python   protocol-buffers   distutils   distutils2

Protocol buffer3 and json

Protocol buffer v3 claims, that library is json friendly (https://developers.google.com/protocol-buffers/docs/proto3#json), but I cannot find how to achieve get that mapping. Should I add some plugin, or some option into protoc, or call something special instead SerializeTo/ParseFrom? Is it someone who use that feature?

2021-11-28 06:29:07    分类:问答    c++   json   protocol-buffers   proto3

python example for reading multiple protobuf messages from a stream

I'm working with data from spinn3r, which consists of multiple different protobuf messages serialized into a byte stream: http://code.google.com/p/spinn3r-client/wiki/Protostream "A protostream is a stream of protocol buffer messages, encoded on the wire as length prefixed varints according to the Google protocol buffer specification. The stream has three parts: a header, the payload, and a tail marker." This seems like a pretty standard use case for protobufs. In fact, protobuf core distribution provides CodedInputStream for both C++ and Java. But, it appears that protobuf does not provide

2021-11-28 05:23:08    分类:问答    python   stream   protocol-buffers

Serialize C++ object to send via sockets to Python - best approach?

I need to create a network communication between two different frameworks, one written in C++ and the other in Python. To exchange data, I want to create some kind of flexible structure (basically a struct) in C++, which is serialised, sent through sockets to Python and then deserialised. What is the most common way to do this? I'm sure that Boost could do it on either side, since there is boost python, but I don't want to blow up the project requirements that much. So is there maybe a smaller library or whatever another elegant solution except specifying an own binary data format? UPDATE: So

2021-11-28 03:02:04    分类:问答    python   c++   serialization   deserialization   protocol-buffers