protocol-buffers

Loading protobuf format file into pig script using loadfunc pig UDF

核能气质少年 提交于 2019-12-05 00:59:06
问题 I have very little knowledge of pig. I have protobuf format data file. I need to load this file into a pig script. I need to write a LoadFunc UDF to load it. say function is Protobufloader() . my PIG script would be A = LOAD 'abc_protobuf.dat' USING Protobufloader() as (name, phonenumber, email); All i wish to know is How do i get the file input stream. Once i get hold of file input stream, i can parse the data from protobuf format to PIG tuple format. PS: thanks in advance 回答1: Twitter's

Protobuf with NodeJS on Windows

末鹿安然 提交于 2019-12-05 00:57:48
问题 I would like to send simple TCP message to a device (Karotz) from NodeJS Script on Windows. NodeJS correctly installed an working TCP connection working Here is my .proto file (http://wiki.karotz.com/index.php/Voos-message.proto) I compile it to .desc using google's protoc I don't know how to build my message to send it to the device ? I read Google Description And protobuff_for_node and other fork But I don't understand how to install it on windows. Seems complicated because of native

Examining a protobuf message - how to get field values by name?

南楼画角 提交于 2019-12-05 00:54:49
I seem unable to find a way to verify the value of a field inside a protobuf message without explicitly invoking its getter. I see examples around that make usage of Descriptors.FieldDescriptor instances to reach inside the message map, but they are either iterator-based or driven by field number. Once I have the map: Map<Descriptors.FieldDescriptor, Object> allFields = myMsg.getAllFields(); how can I get the value of field "fieldXyz" ? I know that I can use myMsg.getFieldXyz() , but this is not usable in a systematic way. If there is no way to access field values by their names, I'd like to

How to do non blocking socket reads with Protobuf using C#?

狂风中的少年 提交于 2019-12-05 00:15:13
问题 Lets say I want to do non blocking reads from a network socket. I can async await for the socket to read x bytes and all is fine. But how do I combine this with deserialization via protobuf? Reading objects from a stream must be blocking? that is, if the stream contains too little data for the parser, then there has to be some blocking going on behind the scenes so that the reader can fetch all the bytes it needs. I guess I can use lengthprefix delimiters and read the first bytes and then

Print human friendly Protobuf message

孤街醉人 提交于 2019-12-04 22:49:34
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() ? 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 :-). 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 text file f = open('a.txt', 'r') address_book = addressbook_pb2.AddressBook() # replace with your own message

Java IDL for gRPC / protobuf (Protocl Buffers)

我们两清 提交于 2019-12-04 22:17:42
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 Have a look at protostuff: https://github.com/protostuff/protostuff It supports what you want for protobuf

How do I represent a UUID in a protobuf message?

。_饼干妹妹 提交于 2019-12-04 22:15:30
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 email; optional string name; } My question is, how will the UUID message look like, and how will I encode

Protocol Buffer optional integer, distinct from zero

╄→гoц情女王★ 提交于 2019-12-04 22:08:27
In Protocol Buffer version 3, I'm trying to figure out the best way to have a optional integer value, where zero and absent should be distinct cases. Best I can figure is making a type: message int64Option { oneof option { bool empty = 14; int64 value = 15; } } Is this a good idea, or is there a better way? There are two main options for this in proto3. The first is to use a oneof like you suggested, but actually you only need to have one item in the oneof : oneof option { int64 value = 15; } Oneof fields have a notion of presence so you can still determine whether value is absent or zero. The

How to not freeze the UI, and wait for response?

主宰稳场 提交于 2019-12-04 20:51:38
I've been trying since the morning but I didnt achieve what I wanted. I tried DispatchQueue.main.async and completion block but my "Submit" button in the UI still freezes waiting for the data to be returned from the server. This is my code: func createData(request:Crudpb_CreateRequest, with completion: @escaping (String) -> Void) throws { DispatchQueue.main.async { self.response = try! self.client.create(request) // <---- How to handle error for this server call when the server is not available or is down? completion(self.response.result) } } I just noticed Im calling the 1st method from the

Missing input file with protoc in protocol buffer

狂风中的少年 提交于 2019-12-04 19:29:05
问题 I currently have a file called addressbook.proto in next to my protoc.exe. I am having difficulty generating the .h and the .cc file. Here is what I am doing protoc --cpp_out=c:\addressbook.proto However I get the following response Missing input file. Any suggestions on what I might be doing wrong ? 回答1: The -cpp_out tag specifies the output directory for generated c source code. I would suggest trying (if proto is actually stored under the c: directory c:\addressbook.proto) protoc c: