Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Apache Spark Graph Processing

You're reading from  Apache Spark Graph Processing

Product type Book
Published in Sep 2015
Publisher
ISBN-13 9781784391805
Pages 148 pages
Edition 1st Edition
Languages

Transforming the vertex and edge attributes


The map operator is a core method for transforming distributed datasets or RDDs in Spark. Similarly, property graphs also have three map operators defined as follows:

class Graph[VD, ED] {
  def mapVertices[VD2](mapFun: (VertexId, VD) => VD2): Graph[VD2, ED]
  def mapEdges[ED2](mapFun: Edge[ED] => ED2): Graph[VD, ED2]
  def mapTriplets[ED2](mapFun: EdgeTriplet[VD, ED] => ED2): Graph[VD, ED2]
}

Each of these methods is called on a property graph with vertex attribute type VD and edge attribute type ED. Each of them also takes a user-defined mapping function mapFun that performs one of the following:

  • For mapVertices, mapFun takes a pair of (VertexId, VD) as input and returns a transformed vertex attribute of type VD2.

  • For mapEdges, mapFun takes an Edge object as input and returns a transformed edge attribute of type ED2.

  • For mapTriplets, mapFun takes an EdgeTriplet object as input and returns a transformed edge attribute of type ED2.

Note

In each...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}