1

我们正在使用 Avrohugger 工具从 Avro 模式生成 scala 类文件。但是 scala 类文件在编译期间因“JVM Spec Violation 255 Parameter Limit Exceeded”而失败。

我已经尝试了多种选择来解决这个问题,但仍然没有解决方案。

一种方法是将剩余的主构造函数(256(列总数)- 254(允许的列))添加为案例类中的字段。当我尝试访问案例类中的字段时,我收到另一个错误为“未知参数名称 XXX enter code here”(XXX 是在案例类中定义的字段)“256 个参数,但预期有 254 个参数”(这是因为我在案例类中放置了 254 个参数作为主要构造函数,并将 2 个附加参数作为值)。

我如何使用 Avrohugger 解决这个问题。

我已经创建了 scala Schema 文件并编辑了 scala 文件,但是在检索案例类的主体内定义的其他列时失败。

修改后的文件如下所示:

case class Apple(col1, col2, .... col254) extends 
org.apache.avro.specificRecordBase with ParsedData{

var col255 = None: Option[String]
var col256 = None: Option[String]

def this() = this(None, .......None) // count is 254

def get ( ) ....   // i have included all the 256 col
def put () ....     // i have included all the 256 col

def getSchema(): org.apache.avro.Schema =  A.schema

}

object Apple{

val SCHEMA = new org.apache.avro.Schema.Parse( <schema definition>) // all 
the 256 columns

   }

此模式在代码中用作:

object Job extends App {

Apple(
 col1 = "1",
 col2 - None,
 ..
col254 = "Hello"
col255 = "Something"
col257 = "Something Else"
)

}

4

0 回答 0