Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/15370#discussion_r82142910
--- Diff:
core/src/main/scala/org/apache/spark/rdd/ReliableCheckpointRDD.scala ---
@@ -93,19 +95,39 @@ private[spark] class ReliableCheckpointRDD[T: ClassTag](
* Read the content of the checkpoint file associated with the given
partition.
*/
override def compute(split: Partition, context: TaskContext):
Iterator[T] = {
- val file = new Path(checkpointPath,
ReliableCheckpointRDD.checkpointFileName(split.index))
+ val file = getPath(split)
ReliableCheckpointRDD.readCheckpointFile(file, broadcastedConf,
context)
}
+ /**
+ * Return the part file with current format by default. If not found,
check for part file with
+ * old format.
+ */
+ private def getPath(split: Partition): Path = {
+ val path = new Path(checkpointPath,
ReliableCheckpointRDD.checkpointFileName(split.index))
+ val fs = path.getFileSystem(broadcastedConf.value.value)
+
+ if (fs.exists(path)) {
+ path
+ } else {
+ val oldFormatPath =
+ new Path(checkpointPath,
+ ReliableCheckpointRDD.checkpointFileName(split.index, oldFormat
= true))
+ if (fs.exists(oldFormatPath)) oldFormatPath else path
+ }
+ }
+
}
private[spark] object ReliableCheckpointRDD extends Logging {
/**
- * Return the checkpoint file name for the given partition.
+ * Return the checkpoint file name for the given partition based on the
format requested.
+ * Old format is supported so that we can successfully parse previously
checkpointed files.
*/
- private def checkpointFileName(partitionIndex: Int): String = {
- "part-%05d".format(partitionIndex)
+ private def checkpointFileName(partitionIndex: Int, oldFormat: Boolean =
false): String = {
+ if (oldFormat) "part-%05d".format(partitionIndex) else
"part-%010d".format(partitionIndex)
--- End diff --
Just output 10 digits always here I think. If there are instances that look
for this name, they can be made more flexible.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]