[英]Apache Avro Parquet java.lang.NoSuchFieldError: NULL_VALUE
我已经卡了3天了。 我正在尝试使用 Apache Avro 读取镶木地板文件。 我只是从文件列表中读取文件,然后迭代直到所有文件都完成。
该代码在其自己的 scala 文件中运行良好,但是,我怀疑这可能与依赖项和我包含的外部库有关。
有没有其他人有过类似的错误并且能够解决这个问题?
代码
override def generateData(): Option[GenericRecord] = {
val conf: Configuration = new Configuration()
conf.setBoolean(AvroReadSupport.AVRO_COMPATIBILITY, true)
if (filePaths.size == 0){
dataSourceComplete()
None
} else {
x += 1
var line = parquetReader.read()
if (line == null){
println(x)
val nextFile = filePaths.last
filePaths = filePaths.init
println(nextFile)
parquetReader = AvroParquetReader.builder[GenericRecord](HadoopInputFile.fromPath(new Path(nextFile), conf)).withConf(conf).build()
line = parquetReader.read()
}
Some(line)
}
}
错误
Uncaught error from thread [Raphtory-akka.actor.default-dispatcher-17]: NULL_VALUE, shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[Raphtory]
java.lang.NoSuchFieldError: NULL_VALUE
at org.apache.parquet.avro.AvroSchemaConverter.convertFields(AvroSchemaConverter.java:246)
at org.apache.parquet.avro.AvroSchemaConverter.convert(AvroSchemaConverter.java:231)
at org.apache.parquet.avro.AvroReadSupport.prepareForRead(AvroReadSupport.java:130)
at org.apache.parquet.hadoop.InternalParquetRecordReader.initialize(InternalParquetRecordReader.java:183)
at org.apache.parquet.hadoop.ParquetReader.initReader(ParquetReader.java:156)
at org.apache.parquet.hadoop.ParquetReader.read(ParquetReader.java:135)
at com.raphtory.ethereum.spout.EthereumTransactionSpout.generateData(EthereumTransactionSpout.scala:59)
这是我的 build.sbt
scalaVersion := "2.12.11"
Compile / unmanagedJars += baseDirectory.value / "lib/raphtory.jar"
val AkkaVersion = "2.6.14"
libraryDependencies ++= Seq(
"com.lightbend.akka" %% "akka-stream-alpakka-avroparquet" % "3.0.3",
"com.typesafe.akka" %% "akka-stream" % AkkaVersion
)
0
我遇到了同样的问题,所以我想分享一下。 我遇到了着色 jars 和我的应用程序,因为我发现我使用了一些依赖库,这些库引入了与 avro 版本的一些冲突。 所以我在我的 pom.xml 中隐藏了 avro 库——即重命名包,这样它就不会与其他任何东西冲突。
首先是添加 maven-shade-plugin,它允许您 (a) 创建一个 uber JAR 和 (b) 为其内容着色,请参阅此处了解更多信息。 这是一个片段:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.2</version>
...然后我为图书馆遮蔽:
<relocation>
<pattern>org.apache.avro</pattern>
<shadedPattern>[RENAME-HERE].shaded.org.apache.avro</shadedPattern>
</relocation>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.