protocol-buffers

Protocol Buffers c# (protobuf-net) Message::ByteSize

谁都会走 提交于 2019-12-24 08:58:26
问题 I am looking for the protobuf-net equivalent to the C++ API Message::ByteSize to find out the serialized message length in bytes. 回答1: I haven't played with the C++ API, so you'll have to give me a bit more context / information. What does this method do? Perhaps a sample usage? If you are consuming data from a stream, there are "WithLengthPrefix" versions to automate limiting to discreet messages, or I believe the method to just read the next length from the stream is on the public API. If

Protocol buffer Database abstraction framework

a 夏天 提交于 2019-12-24 07:46:19
问题 Has anyone heard of an enterprise grade database abstraction layer that builds on Google Protocol Buffers I can foresee such a DB tool set would have great possibilities from mobile computing all the way through to enterprise system development. 回答1: I reckon any key-value store (eg. Redis) will do? Maybe Riak would be a decent candidate as it provides a protobuf API. Eventually all you need to do is handle serialization and deserialization but that should be a rather thin layer on top of a

How to Mask certain fields in Protobuf

落花浮王杯 提交于 2019-12-24 07:19:42
问题 I couldnt find a way to mask certain fields in protobuf structure. I did read about the FieldMaskUtil and tried few examples but it seems to do the reverse i.e copy fields which are mentioned in FieldMask which is different from what i wanted. Here's the sample structure and corresponding Test code. Proto: syntax = "proto3"; package model; option java_package = "test.demo.services.protobuf.customer.model"; option java_outer_classname = "CustomerProto"; message Accounts { repeated Account

How can I add my own code to JAVA generated classes from proto file?

牧云@^-^@ 提交于 2019-12-24 07:16:11
问题 I'm using protobuf and I'm generating JAVA classes from the following proto file. syntax = "proto3"; enum Greeting { NONE = 0; MR = 1; MRS = 2; MISS = 3; } message Hello { Greeting greeting = 1; string name = 2; } message Bye { string name = 1; } option java_multiple_files = true; Now I need to add some code to the generated files and I found that is possible using a custom plugin (https://developers.google.com/protocol-buffers/docs/reference/java-generated#plugins). I'm trying to generate

Will protobuf generate bitwise perfect copy if ran on the same input on different langauges/architectures?

与世无争的帅哥 提交于 2019-12-24 06:29:04
问题 If I use the same .proto file, across several machine (arm, x86, amd64 etc.) with implementations written in different languages (c++, python, java, etc.), will the same message result in the exact same byte sequence when serialized across those different configurations? I would like to use these bytes for hashing to ensure that the same message, when generated on a different platform, would end up with the exact same hash. 回答1: "Often, but not quite always" The reasons you might get variance

protobuf-net UseImplicitZeroDefaults and Enum defaults

南楼画角 提交于 2019-12-24 02:28:11
问题 We're trying to use protobuf-net but having trouble understanding UseImplicitZeroDefaults which we now disable in a custom RuntimeTypeModel. We initially used the default RuntimeTypeModel but noticed boolean properties were not being cloned even though a DefaultValue was being specified, i.e. DefaultValue=true but when set to false the cloned property would always be true. We resolved this by creating a custom RuntimeTypeModel which has allowed us to set UseImplicitZeroDefaults to false. But

protobuf-net UseImplicitZeroDefaults and Enum defaults

自作多情 提交于 2019-12-24 02:28:06
问题 We're trying to use protobuf-net but having trouble understanding UseImplicitZeroDefaults which we now disable in a custom RuntimeTypeModel. We initially used the default RuntimeTypeModel but noticed boolean properties were not being cloned even though a DefaultValue was being specified, i.e. DefaultValue=true but when set to false the cloned property would always be true. We resolved this by creating a custom RuntimeTypeModel which has allowed us to set UseImplicitZeroDefaults to false. But

spark-submit - cannot pickle class in package, but can pickle 'same' class in root folder

天涯浪子 提交于 2019-12-24 02:18:58
问题 In my Python-based Spark task 'main.py', I reference a protobuf generated class 'a_pb2.py'. If I place all files in the root directory like / - main.py - a_pb2.py and zip a_pb2.py into 'proto.zip', then run spark-submit --py-files=proto.zip main.py everything runs as expected. However, if I move the protobuf classes to a package, organizing my files like / - main.py - /protofiles - __init__.py - a_pb2.py and zip /protofiles into 'proto.zip', then run spark-submit --py-files=proto.zip main.py

db.model_from_protobuf() equivalents outside of AppEngine?

六月ゝ 毕业季﹏ 提交于 2019-12-24 01:53:02
问题 In Google AppEngine(GAE) environment, I can do following to convert a Protobuf bytestring back to a Datastore model: from google.appengine.ext import db byte_str = .... model = db.model_from_protobuf(byte_str.decode("base64")) Outside of GAE, I normally use the google-cloud-datastore client to access Datastore models: from google.cloud import datastore ... client = datastore.Client(project_id) query = client.query(kind='Event', order=('-date',)) for result in query.fetch(limit=100): print

Generated Protobuf code crashes application

老子叫甜甜 提交于 2019-12-23 20:48:28
问题 I'm trying to implement save-file for application, by using Protocol Buffers by Google. Preparation A simple test .proto file has been created to test functionality: message LessonFile { optional string creator = 1; } Created .pb.cc and .pb.h are included into project. Lib and include directory are specified in project's properties. Problem Including newly generated code into project results application crash during runtime. By debugging crash state, it pointed on this function: