Syntax understanding of scala function


override def generateJob(time: Time): Option[Job] = {
    parent.getOrCompute(time) match {
      case Some(rdd) =>
        val jobFunc = () => createRDDWithLocalProperties(time, displayInnerRDDOps) {
          foreachFunc(rdd, time)
        }
        Some(new Job(time, jobFunc))
      case None => None
    }
  }

val jobFunc = () => createRDDWithLocalProperties(time, displayInnerRDDOps) {
          foreachFunc(rdd, time)
        }
        
        createRDDWithLocalProperties 
        
Mar.01,2021

I don't know what other code looks like in your context, but if you're just trying to figure out what curly braces are for, here's an example:

val a = 1
val b = 2

val func = abstractAdd(a,b){
  addImpl
}

def abstractAdd(a: Int, b: Int)(tryDo: (Int, Int) => Int): Int = {
  tryDo(a, b)
}

def addImpl(a: Int, b: Int): Int = a + b

We have an operation abstractAdd that doesn't know how to add. In addition to passing in a and b to add, we also need to pass in a function that actually implements the addition. func implements the addition operation completely.

knowledge points involved: Coriarization , higher order functions


.  createRDDWithLocalProperties
createRDDWithLocalProperties(time, displayInnerRDDOps) {
          foreachFunc(rdd, time)
        }
        
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e479c6-44c3c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e479c6-44c3c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?