2

Trying to run one of apache sparks example codes (https://github.com/apache/spark/blob/master/examples/src/main/scala/org/apache/spark/examples/graphx/AggregateMessagesExample.scala) I get the following compile error

too many arguments for method sendToDst: (msg: (Int, Double))Unit
[error] Error occurred in an application involving default arguments.
[error]         triplet.sendToDst(1, triplet.srcAttr)
[error]                          ^
[error] one error found

But looking at the mehtods it seems to be correct. Not sure what is wrong here.

Georg Heiler
  • 16,916
  • 36
  • 162
  • 292
  • send to dist expects a single tuple2[Int,Double] but you are passing in an Int and Double as two individual arguments – puhlen Jan 31 '17 at 18:41

1 Answers1

4

It looks like the method you are calling expects a single argument (a Tuple2) and you are passing in 2 arguments.

Try

triplet.sendToDst((1, triplet.srcAttr))
Angelo Genovese
  • 3,398
  • 17
  • 23
  • Thanks. Tuple works fine. Are case classes supported as well? Or would you rather suggest to stay with primitives here? – Georg Heiler Jan 31 '17 at 18:42
  • Sorry, I don't understand the question. – Angelo Genovese Jan 31 '17 at 18:44
  • For passing messages using this aggregate messages function would you suggest to use type safe case classes instead of a tuple of primitives? Or would you rather suggest to stay with primitives for performance reasons ( less object creation in JVM) – Georg Heiler Jan 31 '17 at 18:45
  • I'm not familiar enough with graphx to really comment, my answer was based entirely on the error message in your original question. – Angelo Genovese Jan 31 '17 at 18:47
  • Tuples are also typed. In a REPL you can verify that val a = (1, "Word") produces a tuple a with type a: (Int, String) – Metropolis Jan 31 '17 at 18:48
  • I wanted to do that already, but SF told me to wait at least 10 minutes :) will do it now. – Georg Heiler Jan 31 '17 at 19:23
  • @GeorgHeiler You can look at the type signature of the method to see what types are allowed. Tuples are objects too so you don't save on object creation over a case class. I would not expect a large difference in performance if any. – puhlen Feb 01 '17 at 03:33