簡體   English   中英

Spark無法捕獲大小超出Integer.MAX_VALUE錯誤的異常?

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

在進行重新分區操作(減小分區大小)時出現此異常。

由以下原因引起:java.lang.IllegalArgumentException:大小超過Integer.MAX_VALUE

在嘗試捕獲此異常時,在try-catch塊下方以某種方式不起作用。 它沒有捕獲到異常。

 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
    }

但是,如果我使異常類型更通用,它就會開始捕獲異常。

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

那么背后的原因是什么呢?

火花是否以某種方式在內部引發了另一個異常,而不是錯誤消息?

注意異常消息中的“由...引起”; 這意味着IllegalArgumentException導致異常的原因 ,您應該在堆棧跟蹤之前查看異常類和消息本身。 看起來像

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

另請參見在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