简体   繁体   English

Spark无法捕获大小超出Integer.MAX_VALUE错误的异常?

[英]Spark cannot catch Size exceeds Integer.MAX_VALUE error exception?

I get this Exception while making repartition operation(decreasing partition size). 在进行重新分区操作(减小分区大小)时出现此异常。

Caused by: java.lang.IllegalArgumentException: Size exceeds Integer.MAX_VALUE 由以下原因引起:java.lang.IllegalArgumentException:大小超过Integer.MAX_VALUE

While trying to catch this exception somehow below try-catch block doesn't work. 在尝试捕获此异常时,在try-catch块下方以某种方式不起作用。 It didn't catch the exception. 它没有捕获到异常。

 try{
      someDF.repartition(10)
        .persist(StorageLevel.MEMORY_AND_DISK)
        .write.mode("overwrite").format(format).save(temp_location)
    }
    catch {
      case ex: java.lang.IllegalArgumentException => {
      // Do something else
    }

But if I make exception type more generic it started to catch exception. 但是,如果我使异常类型更通用,它就会开始捕获异常。

 try{
      someDF.repartition(10)
        .persist(StorageLevel.MEMORY_AND_DISK)
        .write.mode("overwrite").format(format).save(temp_location)
    }
    catch {
      case ex: Exception => {
      // Do something else
    }

So what is the reason behind it? 那么背后的原因是什么呢?

Does spark somehow throw an other exception internally, different than written as error message? 火花是否以某种方式在内部引发了另一个异常,而不是错误消息?

Note "caused by" in the exception message; 注意异常消息中的“由...引起”; it means IllegalArgumentException is the cause of the exception and you should look at the stack trace before it for the exception class and message itself. 这意味着IllegalArgumentException导致异常的原因 ,您应该在堆栈跟踪之前查看异常类和消息本身。 It'll look like 看起来像

Exception in thread "<thread-name>" <exception-class>: <message>

See also Setting Exception cause in java which gives this example stack trace: 另请参见在Java中设置“异常原因”,该示例给出了此示例堆栈跟踪:

Exception in thread "main" java.lang.RuntimeException: Some other message
    at Exceptions.main(Exceptions.java:4)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.RuntimeException: Some message
    at Exceptions.main(Exceptions.java:3)
    ... 5 more

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM