protocol-buffers

scalapb how to generate code from protobuf files in test directory?

二次信任 提交于 2019-12-13 03:43:30
问题 I'd like to generate code from protobuf files in test directory. project/test/protobuf/myproto.proto This doesn't work. PB.targets in Test := Seq( scalapb.gen() -> (sourceManaged in Test).value ) Looks like scalapb only generates files for protos in main/protobuf directory. 回答1: You need to enable ScalaPB code generator for your test configuration. Add this to build.sbt : Project.inConfig(Test)(sbtprotoc.ProtocPlugin.protobufConfigSettings) 来源: https://stackoverflow.com/questions/49693643

Protobuf object data not being read in Objective C

我是研究僧i 提交于 2019-12-13 03:37:23
问题 I use the metasyntactic classes in order to handle Google Protobuf objects in Objective C. This works fine when making and sending protobuf objects to a server. However I am having trouble reading protobuf data that is sent back from the server which I cannot seem to parse. I use this code in the didReceiveData method: - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{ UserId *identity = [UserId parseFromData:data]; NSLog(@"identity firstname = %@", identity

Protobuf data serializer

泄露秘密 提交于 2019-12-12 22:48:22
问题 this dataserializer is great for performance. but I keep getting stuck on datacolumns that has datatype of System.Object causing the serializer to throw an exception:Cannot serialize data column of type 'System.Object'. is there any way around it? 回答1: The protobuf format is designed to suit scenarios where the data is predictable to the receiver, and does not suit "object" scenarios very well, however, depending on the data layout a few things are possible: if the "object" data is a nested

How to de-serialize the file in Java by using Protocol-buffer?

无人久伴 提交于 2019-12-12 21:38:58
问题 Want to create a serialized file in C# and then want to de-serialize the same in Java. For this , i am using Protocol buffer library. Here want i have done: In C#, I added protobuf-net.dll and the class which is to be serialized is represented as: Person.cs [ProtoBuf.ProtoContract] public class Person { [ProtoBuf.ProtoMember(1)] public int Id {get;set;} [ProtoBuf.ProtoMember(2)] public string Name { get; set; } } and in the main method, serialized it like this: var person = new Person { Id =

proto2 with Spark cannot run

a 夏天 提交于 2019-12-12 21:08:27
问题 I've a proto file with syntax proto2 Also, I need to use Spark (2.0.2) and HBase. My project is built using Gradle. Right now, when I run my Java code, I get this error: Exception in thread "main" org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 3.0 failed 1 times, most recent failure: Lost task 0.0 in stage 3.0 (TID 3, localhost): java.lang.NoSuchMethodError: com.google.protobuf.Descriptors$Descriptor.getOneofs()Ljava/util/List; at com.google.protobuf

How to convert existing POCO classes in C# to google Protobuf standard POCO

*爱你&永不变心* 提交于 2019-12-12 19:26:42
问题 I have POCO classes , I use NewtonSoft json for seralization. Now i want to migrate it to Google protocol buff. Is there any way i can migrate all my classes (not manually) so that i can use google protocol buff for serialization and deseralization. 回答1: Do you just want it to work? The absolute simplest way to do this would be to use protobuf-net and add [ProtoContract(ImplicitFields = ImplicitFields.AllPublic)] . What this does is tell protobuf-net to make up the field numbers , which it

Maven and java: how to generate code from protobuf files in test directory?

大兔子大兔子 提交于 2019-12-12 18:34:25
问题 My question is very similar to this question but for maven and java. I am testing grpc, and want to put to a simple helloworld.proto in the test/proto folder. However the file doesn't generate a java file (unlike the proto file in /src/main/proto). So my question is how to generate code for proto in the test folder? 回答1: First, follow the documentation to use the org.xolstice.maven.plugins protobuf-maven-plugin. Alternatively, you can copy the example pom.xml (this is pinned to the v1.19.0

how to use extensions from protocol buffers to maintain 'general' message

孤人 提交于 2019-12-12 18:05:04
问题 My client-server communication looks like this: there are some so called annoucements which are seperate messages used to exchange information. The idea is that annoucement is the common part of every message. Actually I suppose it will be the type of the message. The type decide what is the content. In UML class diagram Annoucement would be the class all other messages inherit. I want to implement that idea in communication between two applications one written in C++ the other in C#. I

still not find package, after 'mvn install'

大憨熊 提交于 2019-12-12 17:24:41
问题 I'm trying to use Google protocol buffer for Java(I'm a newbie about Java, just trying). First of all, I'm using OSX and I've installed protocol buffer with brew install protobuf command. protoc command works okay. I've generated MyProtocol.java by protoc. I've installed protocol buffer for Java as its instruction(README.txt). mvn install command created .m2 directory and I can find protobuf-java-2.4.1.jar file somewhere in the directory. I wrote simple test Java code just importing

How to know which protobuf message the byte array is?

一世执手 提交于 2019-12-12 16:03:32
问题 I want to use protobuf instead of Json to communicate between message queue. I know how to deal with it when there is only one proto message. Assume that the proto file is: //person.proto syntax = "proto3"; option java_outer_classname = "PersonProto"; message Person { int32 id = 2; string name = 1; string email = 3; } Now, i can deal with it with the approach below: PersonProto.Person person = PersonProto.Person.newBuilder() .setEmail("123@test.com") .setId(1) .setName("name-test") .build();