Joining average stats into a graph
The previous example shows us how flexible the aggregateMessages
operator is. We can define the type Msg
of the messages to be aggregated to fit our needs. Moreover, we can select which nodes receive the messages. Finally, we can also define how we want to merge the messages.
As a final example, let's aggregate many statistics about each team and join this information into the nodes of the graph:
- To start, we create its own class for the team stats:
// Average Stats of All Teams case class TeamStat( wins: Int = 0 // Number of wins ,losses: Int = 0 // Number of losses ,ppg: Int = 0 // Points per game ,pcg: Int = 0 // Points conceded per game ,fgp: Double = 0 // Field goal percentage ,tpp: Double = 0 // Three point ...
Get Apache Spark Graph Processing now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.