Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-33431

Simplifying equality of the instance of Option and Some(value)

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Won't Fix
    • 3.1.0
    • None
    • Spark Core, SQL
    • None

    Description

      There are some code like "InstanceOfOption == Some(value)",

      for example "TaskSetManager#handleSuccessfulTask" method:

      def handleSuccessfulTask(tid: Long, result: DirectTaskResult[_]): Unit = {
        ...
        if (successful(index) && killedByOtherAttempt.contains(tid)) {
          ...
          val resultSizeAcc = result.accumUpdates.find(a =>
            a.name == Some(InternalAccumulator.RESULT_SIZE)) 
          ...
      }
      

      We need create a new Option instance "Some(InternalAccumulator.RESULT_SIZE)"  to compare equivalently with a.name.

      In this scenario, can use the "Option#contains" method to avoid creating new option instance

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            LuciferYang Yang Jie
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: