diff options
Diffstat (limited to 'dev/audit-release/sbt_app_graphx/src/main/scala/GraphxApp.scala')
-rw-r--r-- | dev/audit-release/sbt_app_graphx/src/main/scala/GraphxApp.scala | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/dev/audit-release/sbt_app_graphx/src/main/scala/GraphxApp.scala b/dev/audit-release/sbt_app_graphx/src/main/scala/GraphxApp.scala new file mode 100644 index 0000000000..da08e014eb --- /dev/null +++ b/dev/audit-release/sbt_app_graphx/src/main/scala/GraphxApp.scala @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package main.scala + +import org.apache.spark.SparkContext +import org.apache.spark.SparkContext._ +import org.apache.spark.graphx._ +import org.apache.spark.rdd.RDD + +object GraphXApp { + def main(args: Array[String]) { + val sc = new SparkContext("local", "Simple GraphX App") + val users: RDD[(VertexId, (String, String))] = + sc.parallelize(Array((3L, ("rxin", "student")), (7L, ("jgonzal", "postdoc")), + (5L, ("franklin", "prof")), (2L, ("istoica", "prof")), + (4L, ("peter", "student")))) + val relationships: RDD[Edge[String]] = + sc.parallelize(Array(Edge(3L, 7L, "collab"), Edge(5L, 3L, "advisor"), + Edge(2L, 5L, "colleague"), Edge(5L, 7L, "pi"), + Edge(4L, 0L, "student"), Edge(5L, 0L, "colleague"))) + val defaultUser = ("John Doe", "Missing") + val graph = Graph(users, relationships, defaultUser) + // Notice that there is a user 0 (for which we have no information) connected to users + // 4 (peter) and 5 (franklin). + val triplets = graph.triplets.map(e => (e.srcAttr._1, e.dstAttr._1)).collect + if (!triplets.exists(_ == ("peter", "John Doe"))) { + println("Failed to run GraphX") + System.exit(-1) + } + println("Test succeeded") + } +} |