Created
October 17, 2017 14:04
-
-
Save pstutz/44b3990c6adc3f9966b5a603ede59b5d to your computer and use it in GitHub Desktop.
CAPS Zeppelin Example Notebook
This file contains 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\nIn order to use this notebook, follow these steps:\n\n - Go to the Interpreter (`anonymous/username` -> `Interpreter`) settings in the top right\n - Find the `spark` interpreter and click on `edit` \n - In the `Dependencies` section, add the path to the CAPS jar file\n - Click on `save`", | |
"user": "anonymous", | |
"dateUpdated": "2017-10-17T15:02:02+0100", | |
"config": { | |
"colWidth": 12, | |
"enabled": true, | |
"results": {}, | |
"editorSetting": { | |
"language": "markdown", | |
"editOnDblClick": true | |
}, | |
"editorMode": "ace/mode/markdown", | |
"editorHide": true, | |
"tableHide": false | |
}, | |
"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>In order to use this notebook, follow these steps:</p>\n<ul>\n <li>Go to the Interpreter (<code>anonymous/username</code> -> <code>Interpreter</code>) settings in the top right</li>\n <li>Find the <code>spark</code> interpreter and click on <code>edit</code></li>\n <li>In the <code>Dependencies</code> section, add the path to the CAPS jar file</li>\n <li>Click on <code>save</code></li>\n</ul>\n</div>" | |
}] | |
}, | |
"apps": [], | |
"jobName": "paragraph_1508244758979_1302169300", | |
"id": "20171017-135238_242143141", | |
"dateCreated": "2017-10-17T13:52:38+0100", | |
"dateStarted": "2017-10-17T15:02:02+0100", | |
"dateFinished": "2017-10-17T15:02:02+0100", | |
"status": "FINISHED", | |
"progressUpdateIntervalMs": 500, | |
"focus": true, | |
"$$hashKey": "object:4431" | |
}, { | |
"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-10-17T14:41:49+0100", | |
"config": { | |
"colWidth": 12, | |
"enabled": true, | |
"results": {}, | |
"editorSetting": { | |
"language": "scala", | |
"editOnDblClick": false | |
}, | |
"editorMode": "ace/mode/scala", | |
"editorHide": false, | |
"tableHide": false, | |
"title": true | |
}, | |
"settings": { | |
"params": {}, | |
"forms": {} | |
}, | |
"results": { | |
"code": "SUCCESS", | |
"msg": [] | |
}, | |
"apps": [], | |
"jobName": "paragraph_1508244862399_1110719234", | |
"id": "20171017-135422_2642844", | |
"dateCreated": "2017-10-17T13:54:22+0100", | |
"dateStarted": "2017-10-17T14:39:55+0100", | |
"dateFinished": "2017-10-17T14:39:56+0100", | |
"status": "FINISHED", | |
"progressUpdateIntervalMs": 500, | |
"$$hashKey": "object:4432" | |
}, { | |
"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-10-17T14:41:47+0100", | |
"config": { | |
"colWidth": 12, | |
"enabled": true, | |
"results": { | |
"1": { | |
"graph": { | |
"mode": "table", | |
"height": 300, | |
"optionOpen": false | |
}, | |
"helium": {} | |
} | |
}, | |
"editorSetting": { | |
"language": "scala", | |
"editOnDblClick": false | |
}, | |
"editorMode": "ace/mode/scala", | |
"tableHide": false, | |
"title": true | |
}, | |
"settings": { | |
"params": {}, | |
"forms": {} | |
}, | |
"results": { | |
"code": "SUCCESS", | |
"msg": [] | |
}, | |
"apps": [], | |
"jobName": "paragraph_1508244993492_135532370", | |
"id": "20171017-135633_1714791996", | |
"dateCreated": "2017-10-17T13:56:33+0100", | |
"dateStarted": "2017-10-17T14:40:51+0100", | |
"dateFinished": "2017-10-17T14:40:53+0100", | |
"status": "FINISHED", | |
"progressUpdateIntervalMs": 500, | |
"$$hashKey": "object:4433" | |
}, { | |
"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-10-17T14:41:46+0100", | |
"config": { | |
"colWidth": 12, | |
"enabled": true, | |
"results": {}, | |
"editorSetting": { | |
"language": "scala" | |
}, | |
"editorMode": "ace/mode/scala", | |
"title": true | |
}, | |
"settings": { | |
"params": {}, | |
"forms": {} | |
}, | |
"results": { | |
"code": "SUCCESS", | |
"msg": [{ | |
"type": "TEXT", | |
"data": "\n" | |
}, { | |
"type": "TABLE", | |
"data": "a.name\n'Alice'\n'Bob'" | |
}] | |
}, | |
"apps": [], | |
"jobName": "paragraph_1508247654503_1928474279", | |
"id": "20171017-144054_342912603", | |
"dateCreated": "2017-10-17T14:40:54+0100", | |
"dateStarted": "2017-10-17T14:41:42+0100", | |
"dateFinished": "2017-10-17T14:41:43+0100", | |
"status": "FINISHED", | |
"progressUpdateIntervalMs": 500, | |
"$$hashKey": "object:4434" | |
}, { | |
"title": " Zeppelin 0.8 can visualize graphs like this", | |
"text": "graph.asZeppelinGraph", | |
"user": "anonymous", | |
"dateUpdated": "2017-10-17T14:41:25+0100", | |
"config": { | |
"colWidth": 12, | |
"enabled": true, | |
"results": {}, | |
"editorSetting": { | |
"language": "scala", | |
"editOnDblClick": true | |
}, | |
"editorMode": "ace/mode/scala", | |
"editorHide": true, | |
"tableHide": false, | |
"title": 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\" : \"#2614ef\"\n },\n \"directed\" : true,\n \"types\" : [\n \"FRIENDS\"\n ]\n}\n " | |
}] | |
}, | |
"apps": [], | |
"jobName": "paragraph_1508246218533_-515471515", | |
"id": "20171017-141658_922492815", | |
"dateCreated": "2017-10-17T14:16:58+0100", | |
"dateStarted": "2017-10-17T14:41:25+0100", | |
"dateFinished": "2017-10-17T14:41:26+0100", | |
"status": "FINISHED", | |
"progressUpdateIntervalMs": 500, | |
"$$hashKey": "object:4435" | |
}, { | |
"user": "anonymous", | |
"config": { | |
"colWidth": 12, | |
"enabled": true, | |
"results": {}, | |
"editorSetting": { | |
"language": "scala" | |
}, | |
"editorMode": "ace/mode/scala" | |
}, | |
"settings": { | |
"params": {}, | |
"forms": {} | |
}, | |
"apps": [], | |
"jobName": "paragraph_1508247418493_2016648531", | |
"id": "20171017-143658_1085306660", | |
"dateCreated": "2017-10-17T14:36:58+0100", | |
"status": "READY", | |
"progressUpdateIntervalMs": 500, | |
"$$hashKey": "object:4436" | |
}], | |
"name": "Cypher for Apache Spark Example", | |
"id": "2CWAV16BU", | |
"angularObjects": { | |
"2CY7RNMQZ:shared_process": [], | |
"2CWWD4GWH: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