How can I use proto3 with Hadoop/Spark?

前端 未结 2 480
萌比男神i
萌比男神i 2020-12-31 19:54

I\'ve got several .proto files which rely on syntax = \"proto3\";. I also have a Maven project that is used to build Hadoop/Spark jobs (Hadoop 2.7.1 and Spark 1

相关标签:
2条回答
  • 2020-12-31 20:13

    Turns out this kinda thing is documented here: https://maven.apache.org/plugins/maven-shade-plugin/examples/class-relocation.html

    Just need to relocate the protobuffers and the VerifyError goes away:

              <relocations>
                <relocation>
                  <pattern>com.google.protobuf</pattern>
                  <shadedPattern>shaded.com.google.protobuf</shadedPattern>
                </relocation>
              </relocations>
    
    0 讨论(0)
  • 2020-12-31 20:23

    Same solution as Dranxo's but with sbt assembly

    assemblyShadeRules in assembly := Seq(
      ShadeRule.rename("com.google.protobuf.*" -> "shadedproto.@1").inProject
        .inLibrary("com.google.protobuf" % "protobuf-java" % protobufVersion)
    )
    
    0 讨论(0)
提交回复
热议问题