Github user dhruve commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15370#discussion_r82181763
  
    --- 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 --
    
    This is again required for getting the actual path to part file while 
reconstructing the RDD. If we do not plan to parse the old code, we can default 
it to 10 digits.


---
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]

Reply via email to