Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache spark 具有多个特征的GraphX边_Apache Spark_Spark Graphx - Fatal编程技术网

Apache spark 具有多个特征的GraphX边

Apache spark 具有多个特征的GraphX边,apache-spark,spark-graphx,Apache Spark,Spark Graphx,我正在使用Graphx,并尝试向边添加功能。我有一个Id1,Id2,重量,类型的csv文件 我能够得到ID和一个特征-重量或类型。是否有一种方法可以为一条边保存多个要素。以下是我的代码片段: val edgesWriterWriterCollaborated: RDD[Edge[String]] = sc.textFile(edgeWeightedWriterWriterCollaborated).map { line => val row = line.split(",")

我正在使用Graphx,并尝试向边添加功能。我有一个Id1,Id2,重量,类型的csv文件

我能够得到ID和一个特征-重量或类型。是否有一种方法可以为一条边保存多个要素。以下是我的代码片段:

val edgesWriterWriterCollaborated: RDD[Edge[String]] = sc.textFile(edgeWeightedWriterWriterCollaborated).map {
  line =>
    val row = line.split(",")
    Edge(row(0).toLong, row(1).toLong, row(2))
}
这给了我一个错误:

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)))
}
更新:

我将我的代码修改为:

    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)))
}
但是,当我尝试打印时:

   graph4.triplets.foreach(println)

我收到一个错误:
,原因是:java.io.NotSerializableException
当然。使用
元组2

Edge(row(0).toLong, row(1).toLong, (row(2), row(3)))
或在您的情况下有意义的任何特定于域的对象:

case class FooBar(foo: String, bar: String)

Edge(row(0).toLong, row(1).toLong, FooBar(row(2), row(3)))

然而,当我尝试以这种方式打印它时:graph3.triplets.foreach(println),我只得到元组中的第一项。我遗漏了什么吗?可能是重复的