-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[SPARK-17850][Core]Add a flag to ignore corrupt files (branch 1.6) #15454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
|
||
package org.apache.spark.rdd | ||
|
||
import java.io.EOFException | ||
import java.text.SimpleDateFormat | ||
import java.util.Date | ||
|
||
|
@@ -84,6 +85,9 @@ class NewHadoopRDD[K, V]( | |
|
||
private val shouldCloneJobConf = sparkContext.conf.getBoolean("spark.hadoop.cloneConf", false) | ||
|
||
private val ignoreCorruptFiles = | ||
sparkContext.conf.getBoolean("spark.files.ignoreCorruptFiles", true) | ||
|
||
def getConf: Configuration = { | ||
val conf: Configuration = confBroadcast.value.value | ||
if (shouldCloneJobConf) { | ||
|
@@ -171,7 +175,11 @@ class NewHadoopRDD[K, V]( | |
|
||
override def hasNext: Boolean = { | ||
if (!finished && !havePair) { | ||
finished = !reader.nextKeyValue | ||
try { | ||
finished = !reader.nextKeyValue | ||
} catch { | ||
case _: EOFException if ignoreCorruptFiles => finished = true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a behavior change to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I am slightly worried about this change of behavior too. |
||
} | ||
if (finished) { | ||
// Close and release the reader here; close() will also be called when the task | ||
// completes, but for tasks that read from many files, it helps to release the | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't use
IOException
to keep the default behavior is same as before.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good