I am working with Graphx and trying to add features to edges. I have a csv file with Id1, Id2, Weight, Type
I am able to get the Ids and one feature - either weight or type. Is there a way to save multiple features for an edge. Here is a snippet of my code:
val edgesWriterWriterCollaborated: RDD[Edge[String]] = sc.textFile(edgeWeightedWriterWriterCollaborated).map {
line =>
val row = line.split(",")
Edge(row(0).toLong, row(1).toLong, row(2))
}
This gives me an error:
val edgesWriterWriterCollaborated: RDD[Edge[Tuple2]] = sc.textFile(edgeWeightedWriterWriterCollaborated).map {
line =>
val row = line.split(",")
Edge(row(0).toLong, row(1).toLong, (row(2), row(3)))
}
Update:
I fixed my code as so:
case class WriterWriterProperties(weight: String, edgeType: String)
val edgesWriterWriterCollaborated: RDD[Edge[WriterWriterProperties]] = sc.textFile(edgeWeightedWriterWriterCollaborated).map {
line =>
val row = line.split(",")
Edge(row(0).toLong, row(1).toLong, WriterWriterProperties(row(2), row(3)))
}
However when I try to print:
graph4.triplets.foreach(println)
I am getting an error: Caused by: java.io.NotSerializableException