I am writing a MapReduce job in Scalding and having difficulties compiling code that looks perfectly legitimate to me.
val persistenceBins = List[Int](1000 * 60 * 60, 2 * 1000 * 60 * 60, 4 * 1000 * 60 * 60)
val persistenceValues = persistenceBins.map(bin: Int => (bin, getPersistenceValues(connections, bin)) )
connections is RichPipe. getPersistenceValues is defined in the same class as the above code, as:
def getPersistenceValues(connections: RichPipe, binSize: Int): RichPipe = { ... }
I keep getting errors of the kind:
Error:(45, 87) ')' expected but '(' found.
val persistenceValues = persistenceBins.map(bin: Int => (bin, getPersistenceValues(connections, bin)) )
^
Error:(45, 107) ';' expected but ')' found.
val persistenceValues = persistenceBins.map(bin: Int => (bin, getPersistenceValues(connections, bin)) )
^
I can't figure out what's going on. The errors look meaningless to me. What am I doing wrong?
In your case you cannot skip parentheses. This code should help you understand what is wrong.
scala> val persistenceBins = List[Int](1000 * 60 * 60, 2 * 1000 * 60 * 60, 4 * 1000 * 60 * 60)
persistenceBins: List[Int] = List(3600000, 7200000, 14400000)
scala> val persistenceValues = persistenceBins.map((bin: Int) => (bin, 0))
persistenceValues: List[(Int, Int)] = List((3600000,0), (7200000,0), (14400000,0))