spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sean Owen <so...@cloudera.com>
Subject Re: documentation - graphx-programming-guide error?
Date Mon, 02 Mar 2015 08:38:38 GMT
You are correct in that the type of messages being sent in that
example is String and so reduceFun must operate on String. Being just
an example, it can do any reasonable "combining of messages". How
about a + " " + b?

Or the message could be changed to an Int.

The mapReduceTriplets example above appears to have the same problem.

I think it's worth opening a PR + JIRA for the fix.

On Mon, Mar 2, 2015 at 7:12 AM, Deborah Siegel <deborah.siegel@gmail.com> wrote:
> Hello,
>
> I am running through examples given on
> http://spark.apache.org/docs/1.2.1/graphx-programming-guide.html
>
> The section for Map Reduce Triplets Transition Guide (Legacy) indicates that
> one can run the following .aggregateMessages code
>
> val graph: Graph[Int, Float] = ...
> def msgFun(triplet: EdgeContext[Int, Float, String]) {
> triplet.sendToDst("Hi") }
> def reduceFun(a: Int, b: Int): Int = a + b
> val result = graph.aggregateMessages[String](msgFun, reduceFun)
>
> I created a graph of the indicated type, and get an error
>
> scala> val result = graph.aggregateMessages[String](msgFun, reduceFun)
> <console>:23: error: type mismatch;
> found   : Int
> required: String
> Error occurred in an application involving default arguments.
> val result = graph.aggregateMessages[String](msgFun, reduceFun)
>
> ^
> What is this example supposed to do? The following would work, although I'll
> admit I am perplexed by the example's intent.
>
> def msgFun(triplet: EdgeContext[Int, Float, (Int,String)]) {
>   triplet.sendToDst(1, "Hi")
> }
> def reduceFun(a: (Int,String), b: (Int,String)): (Int,String) = ((a._1 +
> b._1),a._2)
> val result = graph.aggregateMessages[(Int,String)](msgFun, reduceFun)
>
> Sincerely,
> Deb
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
For additional commands, e-mail: user-help@spark.apache.org


Mime
View raw message