火花KRYO寄存器阵列类

问题描述 投票:6回答:1

我想注册一个数组类(火花与Java KRYO激活),日志显示一个明确的信息:

Class is not registered: org.apache.spark.sql.execution.datasources.InMemoryFileIndex$SerializableBlockLocation[]

我已经写了几个组合,但这些不工作:

        kryo.register(Class.forName("org.apache.spark.sql.execution.datasources.InMemoryFileIndex$SerializableBlockLocation[]")); // ERROR
        kryo.register(Class.forName("org.apache.spark.sql.execution.datasources.InMemoryFileIndex$SerializableBlockLocation[].class")); // ERROR
        kryo.register(Class.forName("org.apache.spark.sql.execution.datasources.InMemoryFileIndex$SerializableBlockLocation$Array")); // ERROR
        kryo.register(Class.forName("[org.apache.spark.sql.execution.datasources.InMemoryFileIndex$SerializableBlockLocation")); // ERROR
        kryo.register(Class.forName("[Lorg.apache.spark.sql.execution.datasources.InMemoryFileIndex$SerializableBlockLocation")); // ERROR
        kryo.register(Class.forName("Array[org.apache.spark.sql.execution.datasources.InMemoryFileIndex$SerializableBlockLocation]")); // ERROR
        kryo.register(Class.forName("[[org.apache.spark.sql.execution.datasources.InMemoryFileIndex$SerializableBlockLocation"));  // ERROR

我也试着写一个注册类没有Class.forName但Java不能解析符号InMemoryFileIndex$SerializableBlockLocation

kryo.register(org.apache.spark.sql.execution.datasources.InMemoryFileIndex$SerializableBlockLocation[].class);

所有其他类我KryoRegister.class工作。

java apache-spark kryo
1个回答
3
投票

我发现了一个类似的问题here,请尝试:

kryo.register(Array.newInstance(Class.forName("org.apache.spark.sql.execution.datasources.InMemoryFileIndex$SerializableBlockLocation"), 0)
                        .getClass());
© www.soinside.com 2019 - 2024. All rights reserved.