Converting Protocol Buffers (ProtoBuf) to JSON for ingestion. A web service might store user data in a protobuf schema that looks as follows. Simpletech duo pro drive users manual. Do NOT manually. C,protocol-buffers I have a lot of protobuf messages for which I currently use a manually written lookup function to generate the message by its name. Since the messages get more and more as the project evolves, I'm getting tired of maintaining this lookup code by hand. So, is there a way. Jul 21, 2017 The purpose of ProfaneDB is to store Protobuf messages in a key-value database (namely RocksDB), avoiding duplication, and providing an easy interface to retrieve objects. This is done in two steps: Define a âschemaâ. When it comes to a KV database, what we really need is just a key. Save nested messages and store a reference to their key.
- Allow User To Manually Populate Protobuf Messages Windows 10
- Allow User To Manually Populate Protobuf Messages Free
![Allow Allow](/uploads/1/2/6/8/126890492/442593171.jpeg)
Allow User To Manually Populate Protobuf Messages Windows 10
ProtobufEnvelope - allows creating a protobuf message without the .proto file dynamically.
Allow User To Manually Populate Protobuf Messages Free
ProtobufEnvelope.java
importcom.google.protobuf.DescriptorProtos; |
importcom.google.protobuf.Descriptors; |
importcom.google.protobuf.DynamicMessage; |
importcom.google.protobuf.Message; |
importjava.util.HashMap; |
/** |
* ProtobufEnvelope - allows creating a protobuf message without the .proto file dynamically. |
* |
* @author Florian Leibert |
*/ |
publicclassProtobufEnvelope { |
privateHashMap<String, Object> values =newHashMap(); |
privateDescriptorProtos.DescriptorProto.Builder desBuilder; |
privateint i =1; |
publicProtobufEnvelope() { |
desBuilder =DescriptorProtos.DescriptorProto.newBuilder(); |
i =1; |
} |
public<T>voidaddField(StringfieldName, TfieldValue, DescriptorProtos.FieldDescriptorProto.Typetype) { |
DescriptorProtos.FieldDescriptorProto.Builder fd1Builder =DescriptorProtos.FieldDescriptorProto.newBuilder() |
.setName(fieldName).setNumber(i++).setType(type); |
desBuilder.addField(fd1Builder.build()); |
values.put(fieldName, fieldValue); |
} |
publicMessageconstructMessage(StringmessageName) |
throwsDescriptors.DescriptorValidationException { |
desBuilder.setName(messageName); |
DescriptorProtos.DescriptorProto dsc = desBuilder.build(); |
DescriptorProtos.FileDescriptorProto fileDescP =DescriptorProtos.FileDescriptorProto.newBuilder() |
.addMessageType(dsc).build(); |
Descriptors.FileDescriptor[] fileDescs =new Descriptors.FileDescriptor[0]; |
Descriptors.FileDescriptor dynamicDescriptor =Descriptors.FileDescriptor.buildFrom(fileDescP, fileDescs); |
Descriptors.Descriptor msgDescriptor = dynamicDescriptor.findMessageTypeByName(messageName); |
DynamicMessage.Builder dmBuilder = |
DynamicMessage.newBuilder(msgDescriptor); |
for (String name : values.keySet()) { |
dmBuilder.setField(msgDescriptor.findFieldByName(name), values.get(name)); |
} |
return dmBuilder.build(); |
} |
publicvoidclear() { |
desBuilder =DescriptorProtos.DescriptorProto.newBuilder(); |
i =1; |
values.clear(); |
} |
publicstaticvoidmain(String[] args) throwsException { |
ProtobufEnvelope pe =newProtobufEnvelope(); |
int i =1; |
for (; i <5; i++) { |
pe.<String>addField('Field'+ i, i *1000+'FOO', DescriptorProtos.FieldDescriptorProto.Type.TYPE_STRING); |
} |
for (; i <10; i++) { |
pe.<Integer>addField('Field'+ i, i *1000, DescriptorProtos.FieldDescriptorProto.Type.TYPE_INT32); |
} |
Message m = pe.constructMessage('TestMessage'); |
System.out.println(m); |
} |
} |
commented Feb 25, 2015
Iphone 6s plus user manual ios 9 7. ðŸâx8D
|
commented Nov 9, 2015
very useful!
|
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment