天道酬勤,学无止境

protobuf-java

NullPointerException in ProtoBuf when Kryo serialization is used with Spark

I am getting the following error in my spark application when it is trying to serialize a protobuf field which is a map of key String and value float. Kryo serialization is being used in the spark app. Caused by: java.lang.NullPointerException at com.google.protobuf.UnmodifiableLazyStringList.size(UnmodifiableLazyStringList.java:68) at java.util.AbstractList.add(AbstractList.java:108) at com.esotericsoftware.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:134) at com.esotericsoftware.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:40) at com

2021-04-30 20:55:22    分类:问答    apache-spark   kryo   protobuf-java

Protocol Buffers: How to parse a .proto file in Java

I am trying to dynamically parse a given .proto file in Java to decode a Protobuf-encoded binary. I have the following parsing method, in which the "proto" string contains the content of the .proto file: public static Descriptors.FileDescriptor parseProto (String proto) throws InvalidProtocolBufferException, Descriptors.DescriptorValidationException { DescriptorProtos.FileDescriptorProto descriptorProto = DescriptorProtos.FileDescriptorProto.parseFrom(proto.getBytes()); return Descriptors.FileDescriptor.buildFrom(descriptorProto, null); } Though, on execution the previous method throws an

2021-04-20 19:09:27    分类:问答    java   protocol-buffers   protobuf-java