-
-
Save DarthMax/e1997a639eb94896a84c7689621ceef1 to your computer and use it in GitHub Desktop.
CAPS Zeppelin Example Notebook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"paragraphs": [{ | |
"text": "%md \n### This notebook shows how to get started with CAPS inside of Zeppelin.\n\n__Note:__ In order to use this notebook make sure that the CAPS library is installed in local maven repository by running `$ mvn clean install` inside the CAPS direcotry", | |
"user": "anonymous", | |
"dateUpdated": "2017-11-07T12:36:58+0100", | |
"config": { | |
"tableHide": false, | |
"editorSetting": { | |
"language": "markdown", | |
"editOnDblClick": true | |
}, | |
"colWidth": 12, | |
"editorMode": "ace/mode/markdown", | |
"editorHide": true, | |
"results": {}, | |
"enabled": true | |
}, | |
"settings": { | |
"params": {}, | |
"forms": {} | |
}, | |
"results": { | |
"code": "SUCCESS", | |
"msg": [{ | |
"type": "HTML", | |
"data": "<div class=\"markdown-body\">\n<h3>This notebook shows how to get started with CAPS inside of Zeppelin.</h3>\n<p><strong>Note:</strong> In order to use this notebook make sure that the CAPS library is installed in local maven repository by running <code>$ mvn clean install</code> inside the CAPS direcotry</p>\n</div>" | |
}] | |
}, | |
"apps": [], | |
"jobName": "paragraph_1510053931943_-1433163531", | |
"id": "20171017-135238_242143141", | |
"dateCreated": "2017-11-07T12:25:31+0100", | |
"status": "FINISHED", | |
"progressUpdateIntervalMs": 500, | |
"focus": true, | |
"$$hashKey": "object:622", | |
"dateFinished": "2017-11-07T12:37:00+0100", | |
"dateStarted": "2017-11-07T12:36:58+0100" | |
}, { | |
"text": "%spark.dep\nz.load(\"org.opencypher:cypher-for-apache-spark:1.0-SNAPSHOT\")\n", | |
"user": "anonymous", | |
"dateUpdated": "2017-11-07T12:37:42+0100", | |
"config": { | |
"colWidth": 12, | |
"enabled": true, | |
"results": {}, | |
"editorSetting": { | |
"language": "scala" | |
}, | |
"editorMode": "ace/mode/scala", | |
"title": true, | |
"editorHide": false, | |
"tableHide": true | |
}, | |
"settings": { | |
"params": {}, | |
"forms": {} | |
}, | |
"results": { | |
"code": "SUCCESS", | |
"msg": [{ | |
"type": "TEXT", | |
"data": "res0: org.apache.zeppelin.dep.Dependency = org.apache.zeppelin.dep.Dependency@cc2853a\n" | |
}] | |
}, | |
"apps": [], | |
"jobName": "paragraph_1510053938520_-1332343995", | |
"id": "20171107-122538_2057740083", | |
"dateCreated": "2017-11-07T12:25:38+0100", | |
"dateStarted": "2017-11-07T12:30:59+0100", | |
"dateFinished": "2017-11-07T12:32:05+0100", | |
"status": "FINISHED", | |
"progressUpdateIntervalMs": 500, | |
"$$hashKey": "object:623", | |
"title": "Load CAPS dependency" | |
}, { | |
"title": "Imports and session", | |
"text": "import org.opencypher.caps.api.spark.{CAPSGraph, CAPSSession}\nimport org.opencypher.caps.api.record.{NodeScan, RelationshipScan}\nimport org.opencypher.caps.api.util.ZeppelinSupport._\nimplicit val caps = CAPSSession.create(spark)", | |
"user": "anonymous", | |
"dateUpdated": "2017-11-07T12:32:12+0100", | |
"config": { | |
"tableHide": false, | |
"editorSetting": { | |
"language": "scala", | |
"editOnDblClick": false | |
}, | |
"colWidth": 12, | |
"editorMode": "ace/mode/scala", | |
"editorHide": false, | |
"title": true, | |
"results": {}, | |
"enabled": true | |
}, | |
"settings": { | |
"params": {}, | |
"forms": {} | |
}, | |
"results": { | |
"code": "SUCCESS", | |
"msg": [{ | |
"type": "TEXT", | |
"data": "import org.opencypher.caps.api.spark.{CAPSGraph, CAPSSession}\nimport org.opencypher.caps.api.record.{NodeScan, RelationshipScan}\nimport org.opencypher.caps.api.util.ZeppelinSupport._\ncaps: org.opencypher.caps.api.spark.CAPSSession = CAPSSession(No graphs mounted)\n" | |
}] | |
}, | |
"apps": [], | |
"jobName": "paragraph_1510053931951_-1436241522", | |
"id": "20171017-135422_2642844", | |
"dateCreated": "2017-11-07T12:25:31+0100", | |
"dateStarted": "2017-11-07T12:32:12+0100", | |
"dateFinished": "2017-11-07T12:32:31+0100", | |
"status": "FINISHED", | |
"progressUpdateIntervalMs": 500, | |
"$$hashKey": "object:624" | |
}, { | |
"title": "Graph creation", | |
"text": "// Initial data model\ncase class Person(id: Long, name: String)\ncase class Friendship(id: Long, from: Long, to: Long)\n\n// Data mapped to DataFrames\nval personList = List(Person(0, \"Alice\"), Person(1, \"Bob\"))\nval friendshipList= List(Friendship(0, 0, 1), Friendship(1, 1, 0))\nval personDf = spark.createDataFrame(personList)\nval friendshipDf = spark.createDataFrame(friendshipList)\n\n// Turn DataFrame into Node/Relationship scans\nval personScan = NodeScan.on(\"id\") { builder =>\n builder.build.withImpliedLabel(\"Person\").withPropertyKey(\"name\")\n}.fromDf(personDf)\nval friendshipScan = RelationshipScan.on(\"id\") { builder =>\n builder.from(\"from\").to(\"to\").relType(\"FRIENDS\").build\n}.fromDf(friendshipDf)\n\n// Create CAPSGraph from scans\nval graph = CAPSGraph.create(personScan, friendshipScan)", | |
"user": "anonymous", | |
"dateUpdated": "2017-11-07T12:32:40+0100", | |
"config": { | |
"tableHide": false, | |
"editorSetting": { | |
"language": "scala", | |
"editOnDblClick": false | |
}, | |
"colWidth": 12, | |
"editorMode": "ace/mode/scala", | |
"title": true, | |
"results": { | |
"1": { | |
"graph": { | |
"mode": "table", | |
"height": 300, | |
"optionOpen": false | |
}, | |
"helium": {} | |
} | |
}, | |
"enabled": true | |
}, | |
"settings": { | |
"params": {}, | |
"forms": {} | |
}, | |
"results": { | |
"code": "SUCCESS", | |
"msg": [{ | |
"type": "TEXT", | |
"data": "defined class Person\ndefined class Friendship\npersonList: List[Person] = List(Person(0,Alice), Person(1,Bob))\nfriendshipList: List[Friendship] = List(Friendship(0,0,1), Friendship(1,1,0))\npersonDf: org.apache.spark.sql.DataFrame = [id: bigint, name: string]\nfriendshipDf: org.apache.spark.sql.DataFrame = [id: bigint, from: bigint ... 1 more field]\npersonScan: org.opencypher.caps.api.record.NodeScan = org.opencypher.caps.api.record.GraphScanBuilder$RichNodeScanBuilder$$anon$1@63d5264f\nfriendshipScan: org.opencypher.caps.api.record.RelationshipScan = org.opencypher.caps.api.record.GraphScanBuilder$RichRelScanBuilder$$anon$2@1a055ee2\ngraph: org.opencypher.caps.api.spark.CAPSGraph = CAPSScanGraph\n" | |
}] | |
}, | |
"apps": [], | |
"jobName": "paragraph_1510053931952_-1425853302", | |
"id": "20171017-135633_1714791996", | |
"dateCreated": "2017-11-07T12:25:31+0100", | |
"dateStarted": "2017-11-07T12:32:40+0100", | |
"dateFinished": "2017-11-07T12:32:47+0100", | |
"status": "FINISHED", | |
"progressUpdateIntervalMs": 500, | |
"$$hashKey": "object:625" | |
}, { | |
"title": " Querying the graph with Cypher", | |
"text": "val result = graph.cypher(\"MATCH (a:Person)-[:FRIENDS]->(b) RETURN a.name\")\nresult.asZeppelinTable", | |
"user": "anonymous", | |
"dateUpdated": "2017-11-07T12:32:54+0100", | |
"config": { | |
"editorSetting": { | |
"language": "scala" | |
}, | |
"colWidth": 12, | |
"editorMode": "ace/mode/scala", | |
"title": true, | |
"results": {}, | |
"enabled": true | |
}, | |
"settings": { | |
"params": {}, | |
"forms": {} | |
}, | |
"results": { | |
"code": "SUCCESS", | |
"msg": [{ | |
"type": "TEXT", | |
"data": "result: graph.Result = anon$1\n\n" | |
}, { | |
"type": "TABLE", | |
"data": "a.name\n'Alice'\n'Bob'" | |
}] | |
}, | |
"apps": [], | |
"jobName": "paragraph_1510053931952_-1425853302", | |
"id": "20171017-144054_342912603", | |
"dateCreated": "2017-11-07T12:25:31+0100", | |
"dateStarted": "2017-11-07T12:32:54+0100", | |
"dateFinished": "2017-11-07T12:33:01+0100", | |
"status": "FINISHED", | |
"progressUpdateIntervalMs": 500, | |
"$$hashKey": "object:626" | |
}, { | |
"title": " Zeppelin 0.8 can visualize graphs like this", | |
"text": "graph.asZeppelinGraph", | |
"user": "anonymous", | |
"dateUpdated": "2017-11-07T12:33:08+0100", | |
"config": { | |
"tableHide": false, | |
"editorSetting": { | |
"language": "scala", | |
"editOnDblClick": true | |
}, | |
"colWidth": 12, | |
"editorMode": "ace/mode/scala", | |
"editorHide": true, | |
"title": true, | |
"results": {}, | |
"enabled": true | |
}, | |
"settings": { | |
"params": {}, | |
"forms": {} | |
}, | |
"results": { | |
"code": "SUCCESS", | |
"msg": [{ | |
"type": "TEXT", | |
"data": "\n%network\n{\n \"nodes\" : [\n {\n \"id\" : 0,\n \"label\" : \"Person\",\n \"labels\" : [\n \"Person\"\n ],\n \"data\" : {\n \"name\" : \"'Alice'\"\n }\n },\n {\n \"id\" : 1,\n \"label\" : \"Person\",\n \"labels\" : [\n \"Person\"\n ],\n \"data\" : {\n \"name\" : \"'Bob'\"\n }\n }\n ],\n \"edges\" : [\n {\n \"id\" : 0,\n \"source\" : 0,\n \"target\" : 1,\n \"label\" : \"FRIENDS\",\n \"data\" : {\n \n }\n },\n {\n \"id\" : 1,\n \"source\" : 1,\n \"target\" : 0,\n \"label\" : \"FRIENDS\",\n \"data\" : {\n \n }\n }\n ],\n \"labels\" : {\n \"Person\" : \"#adac7c\"\n },\n \"directed\" : true,\n \"types\" : [\n \"FRIENDS\"\n ]\n}\n " | |
}] | |
}, | |
"apps": [], | |
"jobName": "paragraph_1510053931953_-1426238050", | |
"id": "20171017-141658_922492815", | |
"dateCreated": "2017-11-07T12:25:31+0100", | |
"dateStarted": "2017-11-07T12:33:08+0100", | |
"dateFinished": "2017-11-07T12:33:09+0100", | |
"status": "FINISHED", | |
"progressUpdateIntervalMs": 500, | |
"$$hashKey": "object:627" | |
}, { | |
"dateUpdated": "2017-11-07T12:25:31+0100", | |
"config": { | |
"colWidth": 12, | |
"editorMode": "ace/mode/scala", | |
"results": {}, | |
"enabled": true, | |
"editorSetting": { | |
"language": "scala" | |
} | |
}, | |
"settings": { | |
"params": {}, | |
"forms": {} | |
}, | |
"apps": [], | |
"jobName": "paragraph_1510053931953_-1426238050", | |
"id": "20171017-143658_1085306660", | |
"dateCreated": "2017-11-07T12:25:31+0100", | |
"status": "READY", | |
"errorMessage": "", | |
"progressUpdateIntervalMs": 500, | |
"$$hashKey": "object:628" | |
}], | |
"name": "CAPS Test 1", | |
"id": "2CZJVWKKC", | |
"angularObjects": { | |
"2CZ8CJ4UZ:shared_process": [] | |
}, | |
"config": { | |
"looknfeel": "default", | |
"personalizedMode": "false" | |
}, | |
"info": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment