Scala 我们可以将Spark GraphX图形数据导出到Titan graph数据库吗?
我正在检查将Spark GraphX graph导出到Titan graph数据库的可行性Scala 我们可以将Spark GraphX图形数据导出到Titan graph数据库吗?,scala,apache-spark,titan,spark-graphx,Scala,Apache Spark,Titan,Spark Graphx,我正在检查将Spark GraphX graph导出到Titan graph数据库的可行性 ***Used below code to construct graph in Spark GraphX and writing graph to a json file :*** val conf = new SparkConf() val sc = new SparkContext(conf.setAppName("========= G
***Used below code to construct graph in Spark GraphX and writing graph to a json file :***
val conf = new SparkConf()
val sc = new SparkContext(conf.setAppName("========= GraphXTest ======="))
// Create an RDD for the vertices
val users: RDD[(VertexId, (String, String))] = sc.parallelize(Array(
(3L, ("rxin", "student")),
(7L, ("jgonzal", "postdoc")),
(5L, ("franklin", "prof"))
))
// Create an RDD for edges
val relationships: RDD[Edge[String]] = sc.parallelize(Array(
Edge(3L, 7L, "collab"),
Edge(5L, 3L, "advisor")
))
// Build the initial Graph
val graph = Graph(users, relationships)
graph.vertices.saveAsTextFile("D://Spark-GraphX-vertices.json")
在运行上述代码时,它创建了一个名为D://Spark GraphX vertices.json的文件夹,其中几乎没有其他文件。但这些文件不包含任何数据
如何将此图从Spark GraphX导出到Titan数据库 您需要将数据转换为邻接列表格式,以便Titan能够读取数据。最好是导出到文本文件并使用ScriptInputFormat读取它。例如:
1:2,4,5,6
2:4,1,5
3:7,8,9,2
此格式表示顶点1连接到2、4、5和6。如果您的数据集很小(<1亿条边),则只需在文件中循环,并使用OLTP API来写入数据(实际上您并不需要邻接列表格式的数据,尽管这会很好,因为缓存中至少有一个顶点)。如果您的数据集很大(数十亿条边),则需要使用BulkLoadServerTex程序并将其批量加载到Titan中。以下是一些可供研究的链接:
(有趣的是,您将使用Spark批量加载图形)
您需要将数据转换为邻接列表格式,以便Titan能够读取数据。最好是导出到文本文件并使用ScriptInputFormat读取它。例如:
1:2,4,5,6
2:4,1,5
3:7,8,9,2
此格式表示顶点1连接到2、4、5和6。如果您的数据集很小(<1亿条边),则只需在文件中循环,并使用OLTP API来写入数据(实际上您并不需要邻接列表格式的数据,尽管这会很好,因为缓存中至少有一个顶点)。如果您的数据集很大(数十亿条边),则需要使用BulkLoadServerTex程序并将其批量加载到Titan中。以下是一些可供研究的链接:
(有趣的是,您将使用Spark批量加载图形)
谢谢Marko A.Rodriguez。我会查的谢谢Marko A.Rodriguez。我来查一下