4
我有這樣定義的火花RDD:爲什麼scala方法在函數不可串行的時候?
val dataset = CreateRDD(data.filter(someFilter))
我觀察到以下:
//if filter is defined as function, such as following,
//then spark will throw spark `task not serialisable exception`
val someFilter = (some) => true
//if filter is defined as method, such as following then everything will be fine
def someFilter(some) => true
爲什麼呢?
是,功能/方法都被定義爲在測試規範
這些定義(val/def)在哪裏聲明?他們是否被宣佈爲一個類的成員?一個東西?或者作爲某些方法實現中的局部變量?這些選項之間的行爲可能會有所不同... –
方法不可序列化。 – pedrofurla
是更多的上下文,包括確切的錯誤信息是重要的。可能是因爲某種原因,在第一個例子中,該類正在關閉中被捕獲。 – puhlen