protocol-buffers

High performance object serialization library supporting sum types

放肆的年华 提交于 2019-12-07 01:37:19
问题 I wonder if any of the high performance serialization libraries (like Google protocol buffers) support sum types. Sum types are tagged unions, basically the ability to say that something is either A, B, or C. Sum types are used in languages such as Haskell and ML which support Algebraic Data Types 回答1: If by "like Google protocol buffers" you mean ability to generate code for multiple languages then probably such thing doesn't exist. Emulating sum types in languages which don't support them

How protobuf-net serialize DateTime?

夙愿已清 提交于 2019-12-06 23:52:01
问题 I'm working on a project consisting on Client/Server. Client is written in Python (will run on linux) and server in C#. I'm communicating through standard sockets and I'm using protobuf-net for protocol definition. However, I'm wondering how would protobuf-net handle DateTime serialization. Unix datetime differs from .net standard datetime, so how should I handle this situation? Thanks 回答1: DateTime is spoofed via a multi-field message that is not trivial, but not impossible to understand. In

package com.google.protobuf does not exist on OS X Maverick

江枫思渺然 提交于 2019-12-06 21:49:10
问题 I am on OS X Mavericks and starting learning about protobuf, i download the example from https://code.google.com/p/protobuf/downloads/list I am successfully able to create the .java file from the proto but while compiling the existing java code using make java, i am getting following error com/example/tutorial/AddressBookProtos.java:91: package com.google.protobuf does not exist com.google.protobuf.GeneratedMessage ^ com/example/tutorial/AddressBookProtos.java:12: package com.google.protobuf

How to delete arbitrary objects in repeated field? (protobuf)

橙三吉。 提交于 2019-12-06 18:43:22
问题 I have some entries in the repeated field in my proto. Now I want delete some of them. How can I accomplish this? There is a function to delete the last element, but I want to delete arbitrary elements. I cant just swap them because the order is important. I could swap with next until end, but isn't there a nicer solution? 回答1: According to the API docs, there isn't a way to arbitrarily remove an element from within a repeated field, just a way to remove the last one. ... We don't provide a

Print human friendly Protobuf message

江枫思渺然 提交于 2019-12-06 17:14:03
问题 I couldn't find anywhere a possibility to print a human friendly content of a Google Protobuf message. Is there an equivalent in Python for Java's toString() or C++'s DebugString() ? 回答1: If you're using the protobuf package, the print function/statement will give you a human-readable representation of the message, because of the __str__ method :-). 回答2: Here's an example for read/write human friendly text file using protobuf 2.0 in python . from google.protobuf import text_format read from a

Java IDL for gRPC / protobuf (Protocl Buffers)

我是研究僧i 提交于 2019-12-06 17:09:22
问题 Is it possible to define Protocol Buffers using Java? That is instead of service Greeter { rpc SayHello (HelloRequest) returns (HelloReply) {} } I would like to have public interface Greeter { @Grpc HelloReply sayHello (HelloRequest req); } @GrpcMessage() public class HelloReply{ @GrpcField(1) string name; } That is annotation like Hibernate/JPA over my POJO, instead of heaps of generated code. I only could find Protocol Buffers Dynamic Schema https://github.com/os72/protobuf-dynamic 回答1:

Protobuf-net: Using Hidden Members does not work

你。 提交于 2019-12-06 16:38:14
Using types with hidden fields leads to an "Unable to determine member" Exception (V2 via RuntimeTypeModel without any attributes). Removing the Length check in this line in MetaType.cs solves the problem for this special use case. if(members != null && members.Length == 1) mi = members[0]; But I fear there is a reason for the length check, so simply removing it might not be an adequate solution. Using members[0] works in this case, because the hidden base class members go at the end of the array. Simplified Example of my use case: public class SharedType { public int Number { get; set; } }

How do I represent a UUID in a protobuf message?

百般思念 提交于 2019-12-06 16:34:31
问题 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 messages do not yet support the UUID type. I've read that the best approach is to have a UUID message type. So I'm guessing my User message would import my UUID message proto definition and use it as a field type like so: import "myproject/UUID.proto"; message User { required UUID id; required string

Why is a publicly visible Bazel ProtoBuf target 'not declared'

北战南征 提交于 2019-12-06 13:55:38
I'm attempting to use Bazel's Protocol Buffer Rules to compile (generate) Python language bindings and any dependencies. The layout of my project is simple, with a single directory, proto , containing the .proto file and BUILD file. WORKSPACE BUILD.six |-- proto | |-- example.proto | |-- BUILD My WORKSPACE file: workspace(name = "com_example") http_archive( name = "com_google_protobuf", strip_prefix = "protobuf-3.4.1", urls = ["https://github.com/google/protobuf/archive/v3.4.1.zip"], ) new_http_archive( name = "six_archive", build_file = "six.BUILD", url = "https://pypi.python.org/packages

Google protocol buffers and servlets

心不动则不痛 提交于 2019-12-06 13:35:37
问题 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