SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Graph Oriented
Databases Lab
Ciao
ciao
Vai a fare
ciao ciao
Dr. Fabio Fumarola
TitanDB
2
Getting Started
‱ As example we use the Graph of the Godsexample
‱ This Graph stores:
– As nodes: locations, god, demigod, titan, monster and
humans
– As relations: battled, mother, father, brother, lives, person
3
4
Start TitanDB
There are three options:
1.Download a binary version from
https://github.com/thinkaurelius/titan/wiki/Downloads
2.Download a Docker image from docker hub
https://registry.hub.docker.com/u/lulumialu/titandb/
5
Docker Setup
$ docker pull lulumialu/titandb
$ docker run –it--name titan lulumialu/titandb bash
$ ./bin/gremlin.sh
6
Start with the shell
‱ The Gremlin terminal is a Groovy shell
‱ Groovy is a superset of Java that has various
shorthand
7
Loading the Graph of Gods
‱ We use BerkeleyDB and Elasticsearch index backend
8
gremlin> g = TitanFactory.open('conf/titan-berkeleydb-es.properties')
==>titangraph[berkeleyje:../db/berkeley]
gremlin> GraphOfTheGodsFactory.load(g)
==>null
Gremlin
9
Find a Starting Node
‱ The first step is locating a node using a graph index
‱ That entry point is an element (or set of elements)
‱ Starting from that we can traverse the graph
10
gremlin> saturn = g.V.has('name','saturn').next()
==>v[256]
gremlin> saturn.map()
==>name=saturn
==>age=10000
gremlin> saturn.in('father').in('father').name
==>hercules
Find a Starting Edge
‱ We can use GeoQuery to query the place edge
‱ We look for event happened within 50 kms from
Athens
11
g.query().has('place',WITHIN,Geoshape.circle(37.97,23.72,50)).edges().
collect {
it.bothV.name.next(2)
}
==>[hercules, hydra]
==>[hercules, nemean]
Graph Traversal: Saturn’s grandchild
was Hercules
12
Graph Traversal: Saturn’s grandchild
was Hercules
13
gremlin> hercules = saturn.as('x').in('father').loop('x')
{it.loops < 3}.next()
==>v[1536]
Graph Traversal: to prove that
Hercules is demigod
14
Graph Traversal: to prove that
Hercules is demigod
15
gremlin> hercules.out('father','mother')
==>v[1024]
==>v[1792]
gremlin> hercules.out('father','mother').name
==>jupiter
==>alcmene
gremlin> hercules.out('father','mother')*.getVertexLabel()
==>god
==>human
gremlin> hercules.getVertexLabel()
==>demigod
Query: find Hercules heroic exploits
16
Query: find Hercules heroic exploits
17
gremlin> hercules.out('battled')
==>v[2304]
==>v[2560]
==>v[2816]
gremlin> hercules.out('battled').map
==>{name=nemean}
==>{name=hydra}
==>{name=cerberus}
gremlin> hercules.outE('battled').has('time',T.gt,1).inV.name
==>cerberus
==>hydra
Query: Cohabiters of Tartarus
18
Query: Cohabiters of Tartarus
19
gremlin> pluto = g.V('name','pluto').next()
==>v[2048]
gremlin> // who are pluto's cohabitants?
gremlin> pluto.out('lives').in('lives').name
==>pluto
==>cerberus
gremlin> // pluto can't be his own cohabitant
gremlin> pluto.out('lives').in('lives').except([pluto]).name
==>cerberus
gremlin> pluto.as('x').out('lives').in('lives').except('x').name
==>cerberus
Query: Pluto’s Brothers
20
Query: Pluto’s Brothers
21
Query: Pluto’s Brothers
22
gremlin> pluto.out('brother').out('lives').name
==>sky
==>sea
gremlin> // which brother lives in which place?
gremlin> pluto.out('brother').as('god').out('lives').as('place').select
==>[god:v[1024], place:v[512]]
==>[god:v[1280], place:v[768]]
gremlin> // what is the name of the brother and the name of the place?
gremlin>
pluto.out('brother').as('god').out('lives').as('place').select{it.name}
==>[god:jupiter, place:sky]
==>[god:neptune, place:sea]
Query: Reason Pluto lives in Tartarus
23
Query: Reason Pluto lives in Tartarus
24
gremlin> pluto.outE('lives').reason
==>no fear of death
gremlin> g.query().has('reason',CONTAINS,'loves').edges()
==>e[6xs-sg-m51-e8][1024-lives->512]
==>e[70g-zk-m51-lc][1280-lives->768]
gremlin> g.query().has('reason',CONTAINS,'loves').edges().collect{
[it.outV.name.next(),it.reason,it.inV.name.next()]
}
==>[jupiter, loves fresh breezes, sky]
==>[neptune, loves waves, sea]
Gremlin in Depth
For a complete gremlin guide check
‱http://s3.thinkaurelius.com/docs/titan/0.5.4/gremlin.
html
‱http://gremlindocs.com/
‱http://sql2gremlin.com/
25
Schema and Data Modeling
26
Defining an Edge Label 1/2
‱ We need a unique name for the label edge
‱ Multiplicity Settings:
– MULTI: Allows multiple edges of the same label between
any pair of vertices.
– SIMPLE: Allows at most one edge of such label between
any pair of vertices.
– MANY2ONE: Allows at most one outgoing edge of such
label on any vertex in the graph but places no constraint
on incoming edges.
27
Defining an Edge Label 2/2
‱ We need a unique name for the label edge
‱ Multiplicity Settings:
– ONE2MANY: Allows at most one incoming edge of such
label on any vertex in the graph but places no constraint
on outgoing edges.
– ONE2ONE: Allows at most one incoming and one outgoing
edge of such label on any vertex in the graph.
28
Defining an Edge Label
29
mgmt = g.getManagementSystem()
follow =
mgmt.makeEdgeLabel('follow').multiplicity(Multiplicity.MULTI).make()
mother =
mgmt.makeEdgeLabel('mother').multiplicity(Multiplicity.MANY2ONE).
make()
mgmt.commit()
Defining a Property
‱ Properties on vertices and
edges are key-value pairs.
‱ For instance, the property
name='Daniel' has the key
name and the value
'Daniel'.
30
Property Key Cardinality
Are used to set a cardinality of the values of a property
‱Single
‱List
‱Set
31
Property Key Cardinality
32
mgmt = g.getManagementSystem()
birthDate =
mgmt.makePropertyKey('birthDate').dataType(Long.class).cardinality(C
ardinality.SINGLE).make()
name =
mgmt.makePropertyKey('name').dataType(String.class).cardinality(Car
dinality.SET).make()
sensorReading =
mgmt.makePropertyKey('sensorReading').dataType(Double.class).card
inality(Cardinality.LIST).make()
mgmt.commit()
Relation Types for edges
‱ The names of relation types must be unique in the
graph
33
mgmt = g.getManagementSystem()
if (mgmt.containsRelationType('name'))
name = mgmt.getPropertyKey('name')
mgmt.getRelationTypes(EdgeLabel.class)
mgmt.commit()
Defining Vertex Labels
‱ Like edges, vertices have labels.
‱ Unlike edge labels, vertex labels are optional.
34
mgmt = g.getManagementSystem()
person = mgmt.makeVertexLabel('person').make();
mgmt.commit()
// Create a labeled vertex
person = g.addVertexWithLabel('person')
// Create an unlabeled vertex
v = g.addVertex(null)
g.commit()
Titan Server
35
Rexter
‱ Titan uses the Rexster engine as the server
component to process and answer client queries.
‱ The Titan Download comes preconfigured with a
script, titan.sh, which starts Cassandra, Elasticsearch,
and Titan with Rexster.
36
Rexster Dog House Visualization
37
Rexter Gremlin
38
References
‱ http://s3.thinkaurelius.com/docs/titan/0.5.4/index.h
tml
‱ http://www.quora.com/What-are-the-differences-
between-a-Graph-database-and-a-Triple-store
39

Weitere Àhnliche Inhalte

Was ist angesagt?

groovy databases
groovy databasesgroovy databases
groovy databasesPaul King
 
The Ring programming language version 1.3 book - Part 43 of 88
The Ring programming language version 1.3 book - Part 43 of 88The Ring programming language version 1.3 book - Part 43 of 88
The Ring programming language version 1.3 book - Part 43 of 88Mahmoud Samir Fayed
 
Distributed Data Structures
Distributed Data StructuresDistributed Data Structures
Distributed Data StructuresPDX Web & Design
 
Intro to OTP in Elixir
Intro to OTP in ElixirIntro to OTP in Elixir
Intro to OTP in ElixirJesse Anderson
 
Ű§ŰłÙ„Ű§ÛŒŰŻ Ű§ÙˆÙ„ ŰŹÙ„ŰłÙ‡ Ú†Ù‡Ű§Ű±Ù… Ú©Ù„Ű§Űł ÙŸŰ§ÛŒŰȘون ŰšŰ±Ű§ÛŒ Ù‡Ú©Ű±Ù‡Ű§ÛŒ Ù‚Ű§Ù†ÙˆÙ†ÛŒ
Ű§ŰłÙ„Ű§ÛŒŰŻ Ű§ÙˆÙ„ ŰŹÙ„ŰłÙ‡ Ú†Ù‡Ű§Ű±Ù… Ú©Ù„Ű§Űł ÙŸŰ§ÛŒŰȘون ŰšŰ±Ű§ÛŒ Ù‡Ú©Ű±Ù‡Ű§ÛŒ Ù‚Ű§Ù†ÙˆÙ†ÛŒŰ§ŰłÙ„Ű§ÛŒŰŻ Ű§ÙˆÙ„ ŰŹÙ„ŰłÙ‡ Ú†Ù‡Ű§Ű±Ù… Ú©Ù„Ű§Űł ÙŸŰ§ÛŒŰȘون ŰšŰ±Ű§ÛŒ Ù‡Ú©Ű±Ù‡Ű§ÛŒ Ù‚Ű§Ù†ÙˆÙ†ÛŒ
Ű§ŰłÙ„Ű§ÛŒŰŻ Ű§ÙˆÙ„ ŰŹÙ„ŰłÙ‡ Ú†Ù‡Ű§Ű±Ù… Ú©Ù„Ű§Űł ÙŸŰ§ÛŒŰȘون ŰšŰ±Ű§ÛŒ Ù‡Ú©Ű±Ù‡Ű§ÛŒ Ù‚Ű§Ù†ÙˆÙ†ÛŒMohammad Reza Kamalifard
 
MySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of ThingsMySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of ThingsAlexander Rubin
 
"You shall not pass : anti-debug methodics"
"You shall not pass : anti-debug methodics""You shall not pass : anti-debug methodics"
"You shall not pass : anti-debug methodics"ITCP Community
 
The State of NoSQL
The State of NoSQLThe State of NoSQL
The State of NoSQLBen Scofield
 
PyTrening 2.0 # 15 Okienka GUI
PyTrening 2.0 # 15 Okienka GUIPyTrening 2.0 # 15 Okienka GUI
PyTrening 2.0 # 15 Okienka GUIMoniaJ
 
Psycopg2 - Connect to PostgreSQL using Python Script
Psycopg2 - Connect to PostgreSQL using Python ScriptPsycopg2 - Connect to PostgreSQL using Python Script
Psycopg2 - Connect to PostgreSQL using Python ScriptSurvey Department
 
Webinar: Replication and Replica Sets
Webinar: Replication and Replica SetsWebinar: Replication and Replica Sets
Webinar: Replication and Replica SetsMongoDB
 
The Ring programming language version 1.8 book - Part 51 of 202
The Ring programming language version 1.8 book - Part 51 of 202The Ring programming language version 1.8 book - Part 51 of 202
The Ring programming language version 1.8 book - Part 51 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 64 of 212
The Ring programming language version 1.10 book - Part 64 of 212The Ring programming language version 1.10 book - Part 64 of 212
The Ring programming language version 1.10 book - Part 64 of 212Mahmoud Samir Fayed
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeBuilding Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeMongoDB
 
Replication and Replica Sets
Replication and Replica SetsReplication and Replica Sets
Replication and Replica SetsMongoDB
 

Was ist angesagt? (19)

Codigos
CodigosCodigos
Codigos
 
groovy databases
groovy databasesgroovy databases
groovy databases
 
Corona sdk
Corona sdkCorona sdk
Corona sdk
 
The Ring programming language version 1.3 book - Part 43 of 88
The Ring programming language version 1.3 book - Part 43 of 88The Ring programming language version 1.3 book - Part 43 of 88
The Ring programming language version 1.3 book - Part 43 of 88
 
Distributed Data Structures
Distributed Data StructuresDistributed Data Structures
Distributed Data Structures
 
Intro to OTP in Elixir
Intro to OTP in ElixirIntro to OTP in Elixir
Intro to OTP in Elixir
 
Ű§ŰłÙ„Ű§ÛŒŰŻ Ű§ÙˆÙ„ ŰŹÙ„ŰłÙ‡ Ú†Ù‡Ű§Ű±Ù… Ú©Ù„Ű§Űł ÙŸŰ§ÛŒŰȘون ŰšŰ±Ű§ÛŒ Ù‡Ú©Ű±Ù‡Ű§ÛŒ Ù‚Ű§Ù†ÙˆÙ†ÛŒ
Ű§ŰłÙ„Ű§ÛŒŰŻ Ű§ÙˆÙ„ ŰŹÙ„ŰłÙ‡ Ú†Ù‡Ű§Ű±Ù… Ú©Ù„Ű§Űł ÙŸŰ§ÛŒŰȘون ŰšŰ±Ű§ÛŒ Ù‡Ú©Ű±Ù‡Ű§ÛŒ Ù‚Ű§Ù†ÙˆÙ†ÛŒŰ§ŰłÙ„Ű§ÛŒŰŻ Ű§ÙˆÙ„ ŰŹÙ„ŰłÙ‡ Ú†Ù‡Ű§Ű±Ù… Ú©Ù„Ű§Űł ÙŸŰ§ÛŒŰȘون ŰšŰ±Ű§ÛŒ Ù‡Ú©Ű±Ù‡Ű§ÛŒ Ù‚Ű§Ù†ÙˆÙ†ÛŒ
Ű§ŰłÙ„Ű§ÛŒŰŻ Ű§ÙˆÙ„ ŰŹÙ„ŰłÙ‡ Ú†Ù‡Ű§Ű±Ù… Ú©Ù„Ű§Űł ÙŸŰ§ÛŒŰȘون ŰšŰ±Ű§ÛŒ Ù‡Ú©Ű±Ù‡Ű§ÛŒ Ù‚Ű§Ù†ÙˆÙ†ÛŒ
 
MySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of ThingsMySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of Things
 
"You shall not pass : anti-debug methodics"
"You shall not pass : anti-debug methodics""You shall not pass : anti-debug methodics"
"You shall not pass : anti-debug methodics"
 
The State of NoSQL
The State of NoSQLThe State of NoSQL
The State of NoSQL
 
Composable caching
Composable cachingComposable caching
Composable caching
 
PyTrening 2.0 # 15 Okienka GUI
PyTrening 2.0 # 15 Okienka GUIPyTrening 2.0 # 15 Okienka GUI
PyTrening 2.0 # 15 Okienka GUI
 
Psycopg2 - Connect to PostgreSQL using Python Script
Psycopg2 - Connect to PostgreSQL using Python ScriptPsycopg2 - Connect to PostgreSQL using Python Script
Psycopg2 - Connect to PostgreSQL using Python Script
 
Webinar: Replication and Replica Sets
Webinar: Replication and Replica SetsWebinar: Replication and Replica Sets
Webinar: Replication and Replica Sets
 
ES6 in Real Life
ES6 in Real LifeES6 in Real Life
ES6 in Real Life
 
The Ring programming language version 1.8 book - Part 51 of 202
The Ring programming language version 1.8 book - Part 51 of 202The Ring programming language version 1.8 book - Part 51 of 202
The Ring programming language version 1.8 book - Part 51 of 202
 
The Ring programming language version 1.10 book - Part 64 of 212
The Ring programming language version 1.10 book - Part 64 of 212The Ring programming language version 1.10 book - Part 64 of 212
The Ring programming language version 1.10 book - Part 64 of 212
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeBuilding Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at Stripe
 
Replication and Replica Sets
Replication and Replica SetsReplication and Replica Sets
Replication and Replica Sets
 

Andere mochten auch

9b. Document-Oriented Databases lab
9b. Document-Oriented Databases lab9b. Document-Oriented Databases lab
9b. Document-Oriented Databases labFabio Fumarola
 
10. Graph Databases
10. Graph Databases10. Graph Databases
10. Graph DatabasesFabio Fumarola
 
11. From Hadoop to Spark 1:2
11. From Hadoop to Spark 1:211. From Hadoop to Spark 1:2
11. From Hadoop to Spark 1:2Fabio Fumarola
 
11. From Hadoop to Spark 2/2
11. From Hadoop to Spark 2/211. From Hadoop to Spark 2/2
11. From Hadoop to Spark 2/2Fabio Fumarola
 
Hbase an introduction
Hbase an introductionHbase an introduction
Hbase an introductionFabio Fumarola
 
8. column oriented databases
8. column oriented databases8. column oriented databases
8. column oriented databasesFabio Fumarola
 
8b. Column Oriented Databases Lab
8b. Column Oriented Databases Lab8b. Column Oriented Databases Lab
8b. Column Oriented Databases LabFabio Fumarola
 
8a. How To Setup HBase with Docker
8a. How To Setup HBase with Docker8a. How To Setup HBase with Docker
8a. How To Setup HBase with DockerFabio Fumarola
 
8. key value databases laboratory
8. key value databases laboratory 8. key value databases laboratory
8. key value databases laboratory Fabio Fumarola
 
7. Key-Value Databases: In Depth
7. Key-Value Databases: In Depth7. Key-Value Databases: In Depth
7. Key-Value Databases: In DepthFabio Fumarola
 
Data Modeling for NoSQL
Data Modeling for NoSQLData Modeling for NoSQL
Data Modeling for NoSQLTony Tam
 
6 Data Modeling for NoSQL 2/2
6 Data Modeling for NoSQL 2/26 Data Modeling for NoSQL 2/2
6 Data Modeling for NoSQL 2/2Fabio Fumarola
 
5 Data Modeling for NoSQL 1/2
5 Data Modeling for NoSQL 1/25 Data Modeling for NoSQL 1/2
5 Data Modeling for NoSQL 1/2Fabio Fumarola
 
9. Document Oriented Databases
9. Document Oriented Databases9. Document Oriented Databases
9. Document Oriented DatabasesFabio Fumarola
 

Andere mochten auch (16)

9b. Document-Oriented Databases lab
9b. Document-Oriented Databases lab9b. Document-Oriented Databases lab
9b. Document-Oriented Databases lab
 
10. Graph Databases
10. Graph Databases10. Graph Databases
10. Graph Databases
 
11. From Hadoop to Spark 1:2
11. From Hadoop to Spark 1:211. From Hadoop to Spark 1:2
11. From Hadoop to Spark 1:2
 
11. From Hadoop to Spark 2/2
11. From Hadoop to Spark 2/211. From Hadoop to Spark 2/2
11. From Hadoop to Spark 2/2
 
Scala and spark
Scala and sparkScala and spark
Scala and spark
 
Hbase an introduction
Hbase an introductionHbase an introduction
Hbase an introduction
 
8. column oriented databases
8. column oriented databases8. column oriented databases
8. column oriented databases
 
8b. Column Oriented Databases Lab
8b. Column Oriented Databases Lab8b. Column Oriented Databases Lab
8b. Column Oriented Databases Lab
 
3 Git
3 Git3 Git
3 Git
 
8a. How To Setup HBase with Docker
8a. How To Setup HBase with Docker8a. How To Setup HBase with Docker
8a. How To Setup HBase with Docker
 
8. key value databases laboratory
8. key value databases laboratory 8. key value databases laboratory
8. key value databases laboratory
 
7. Key-Value Databases: In Depth
7. Key-Value Databases: In Depth7. Key-Value Databases: In Depth
7. Key-Value Databases: In Depth
 
Data Modeling for NoSQL
Data Modeling for NoSQLData Modeling for NoSQL
Data Modeling for NoSQL
 
6 Data Modeling for NoSQL 2/2
6 Data Modeling for NoSQL 2/26 Data Modeling for NoSQL 2/2
6 Data Modeling for NoSQL 2/2
 
5 Data Modeling for NoSQL 1/2
5 Data Modeling for NoSQL 1/25 Data Modeling for NoSQL 1/2
5 Data Modeling for NoSQL 1/2
 
9. Document Oriented Databases
9. Document Oriented Databases9. Document Oriented Databases
9. Document Oriented Databases
 

Ähnlich wie 10b. Graph Databases Lab

(Greach 2015) Dsl'ing your Groovy
(Greach 2015) Dsl'ing your Groovy(Greach 2015) Dsl'ing your Groovy
(Greach 2015) Dsl'ing your GroovyAlonso Torres
 
The Gremlin Graph Traversal Language
The Gremlin Graph Traversal LanguageThe Gremlin Graph Traversal Language
The Gremlin Graph Traversal LanguageMarko Rodriguez
 
Turtle Graphics in Groovy
Turtle Graphics in GroovyTurtle Graphics in Groovy
Turtle Graphics in GroovyJim Driscoll
 
Introduction to Gremlin
Introduction to GremlinIntroduction to Gremlin
Introduction to GremlinMax De Marzi
 
React Native One Day
React Native One DayReact Native One Day
React Native One DayTroy Miles
 
The Ring programming language version 1.10 book - Part 22 of 212
The Ring programming language version 1.10 book - Part 22 of 212The Ring programming language version 1.10 book - Part 22 of 212
The Ring programming language version 1.10 book - Part 22 of 212Mahmoud Samir Fayed
 
Fact, Fiction, and FP
Fact, Fiction, and FPFact, Fiction, and FP
Fact, Fiction, and FPBrian Lonsdorf
 
A walk in graph databases v1.0
A walk in graph databases v1.0A walk in graph databases v1.0
A walk in graph databases v1.0Pierre De Wilde
 
Rust "Hot or Not" at Sioux
Rust "Hot or Not" at SiouxRust "Hot or Not" at Sioux
Rust "Hot or Not" at Siouxnikomatsakis
 
Grails 1.2 æŽąæ€œéšŠ -æ–°ăŸăȘè–æŻă‚’ă‚‚ăšă‚ăŠăƒ»ăƒ»ăƒ»-
Grails 1.2 æŽąæ€œéšŠ -æ–°ăŸăȘè–æŻă‚’ă‚‚ăšă‚ăŠăƒ»ăƒ»ăƒ»-Grails 1.2 æŽąæ€œéšŠ -æ–°ăŸăȘè–æŻă‚’ă‚‚ăšă‚ăŠăƒ»ăƒ»ăƒ»-
Grails 1.2 æŽąæ€œéšŠ -æ–°ăŸăȘè–æŻă‚’ă‚‚ăšă‚ăŠăƒ»ăƒ»ăƒ»-Tsuyoshi Yamamoto
 
Beyond Breakpoints: Advanced Debugging with XCode
Beyond Breakpoints: Advanced Debugging with XCodeBeyond Breakpoints: Advanced Debugging with XCode
Beyond Breakpoints: Advanced Debugging with XCodeAijaz Ansari
 
The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212Mahmoud Samir Fayed
 
The secrets of inverse brogramming
The secrets of inverse brogrammingThe secrets of inverse brogramming
The secrets of inverse brogrammingRichie Cotton
 
Testing a 2D Platformer with Spock
Testing a 2D Platformer with SpockTesting a 2D Platformer with Spock
Testing a 2D Platformer with SpockAlexander Tarlinder
 
groovy & grails - lecture 2
groovy & grails - lecture 2groovy & grails - lecture 2
groovy & grails - lecture 2Alexandre Masselot
 
Groovy intro for OUDL
Groovy intro for OUDLGroovy intro for OUDL
Groovy intro for OUDLJ David Beutel
 
The Curious Clojurist - Neal Ford (Thoughtworks)
The Curious Clojurist - Neal Ford (Thoughtworks)The Curious Clojurist - Neal Ford (Thoughtworks)
The Curious Clojurist - Neal Ford (Thoughtworks)jaxLondonConference
 
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Rajmahendra Hegde
 

Ähnlich wie 10b. Graph Databases Lab (20)

(Greach 2015) Dsl'ing your Groovy
(Greach 2015) Dsl'ing your Groovy(Greach 2015) Dsl'ing your Groovy
(Greach 2015) Dsl'ing your Groovy
 
The Gremlin Graph Traversal Language
The Gremlin Graph Traversal LanguageThe Gremlin Graph Traversal Language
The Gremlin Graph Traversal Language
 
Turtle Graphics in Groovy
Turtle Graphics in GroovyTurtle Graphics in Groovy
Turtle Graphics in Groovy
 
Introduction to Gremlin
Introduction to GremlinIntroduction to Gremlin
Introduction to Gremlin
 
React Native One Day
React Native One DayReact Native One Day
React Native One Day
 
ES6 is Nigh
ES6 is NighES6 is Nigh
ES6 is Nigh
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to Groovy
 
The Ring programming language version 1.10 book - Part 22 of 212
The Ring programming language version 1.10 book - Part 22 of 212The Ring programming language version 1.10 book - Part 22 of 212
The Ring programming language version 1.10 book - Part 22 of 212
 
Fact, Fiction, and FP
Fact, Fiction, and FPFact, Fiction, and FP
Fact, Fiction, and FP
 
A walk in graph databases v1.0
A walk in graph databases v1.0A walk in graph databases v1.0
A walk in graph databases v1.0
 
Rust "Hot or Not" at Sioux
Rust "Hot or Not" at SiouxRust "Hot or Not" at Sioux
Rust "Hot or Not" at Sioux
 
Grails 1.2 æŽąæ€œéšŠ -æ–°ăŸăȘè–æŻă‚’ă‚‚ăšă‚ăŠăƒ»ăƒ»ăƒ»-
Grails 1.2 æŽąæ€œéšŠ -æ–°ăŸăȘè–æŻă‚’ă‚‚ăšă‚ăŠăƒ»ăƒ»ăƒ»-Grails 1.2 æŽąæ€œéšŠ -æ–°ăŸăȘè–æŻă‚’ă‚‚ăšă‚ăŠăƒ»ăƒ»ăƒ»-
Grails 1.2 æŽąæ€œéšŠ -æ–°ăŸăȘè–æŻă‚’ă‚‚ăšă‚ăŠăƒ»ăƒ»ăƒ»-
 
Beyond Breakpoints: Advanced Debugging with XCode
Beyond Breakpoints: Advanced Debugging with XCodeBeyond Breakpoints: Advanced Debugging with XCode
Beyond Breakpoints: Advanced Debugging with XCode
 
The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212
 
The secrets of inverse brogramming
The secrets of inverse brogrammingThe secrets of inverse brogramming
The secrets of inverse brogramming
 
Testing a 2D Platformer with Spock
Testing a 2D Platformer with SpockTesting a 2D Platformer with Spock
Testing a 2D Platformer with Spock
 
groovy & grails - lecture 2
groovy & grails - lecture 2groovy & grails - lecture 2
groovy & grails - lecture 2
 
Groovy intro for OUDL
Groovy intro for OUDLGroovy intro for OUDL
Groovy intro for OUDL
 
The Curious Clojurist - Neal Ford (Thoughtworks)
The Curious Clojurist - Neal Ford (Thoughtworks)The Curious Clojurist - Neal Ford (Thoughtworks)
The Curious Clojurist - Neal Ford (Thoughtworks)
 
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
 

Mehr von Fabio Fumarola

2 Linux Container and Docker
2 Linux Container and Docker2 Linux Container and Docker
2 Linux Container and DockerFabio Fumarola
 
1. Introduction to the Course "Designing Data Bases with Advanced Data Models...
1. Introduction to the Course "Designing Data Bases with Advanced Data Models...1. Introduction to the Course "Designing Data Bases with Advanced Data Models...
1. Introduction to the Course "Designing Data Bases with Advanced Data Models...Fabio Fumarola
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbtFabio Fumarola
 
Develop with linux containers and docker
Develop with linux containers and dockerDevelop with linux containers and docker
Develop with linux containers and dockerFabio Fumarola
 
Linux containers and docker
Linux containers and dockerLinux containers and docker
Linux containers and dockerFabio Fumarola
 
A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce
A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce
A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce Fabio Fumarola
 
NoSQL databases pros and cons
NoSQL databases pros and consNoSQL databases pros and cons
NoSQL databases pros and consFabio Fumarola
 

Mehr von Fabio Fumarola (8)

2 Linux Container and Docker
2 Linux Container and Docker2 Linux Container and Docker
2 Linux Container and Docker
 
1. Introduction to the Course "Designing Data Bases with Advanced Data Models...
1. Introduction to the Course "Designing Data Bases with Advanced Data Models...1. Introduction to the Course "Designing Data Bases with Advanced Data Models...
1. Introduction to the Course "Designing Data Bases with Advanced Data Models...
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbt
 
Develop with linux containers and docker
Develop with linux containers and dockerDevelop with linux containers and docker
Develop with linux containers and docker
 
Linux containers and docker
Linux containers and dockerLinux containers and docker
Linux containers and docker
 
08 datasets
08 datasets08 datasets
08 datasets
 
A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce
A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce
A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce
 
NoSQL databases pros and cons
NoSQL databases pros and consNoSQL databases pros and cons
NoSQL databases pros and cons
 

KĂŒrzlich hochgeladen

Predicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science ProjectPredicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science ProjectBoston Institute of Analytics
 
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...amitlee9823
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...amitlee9823
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Valters Lauzums
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...amitlee9823
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...amitlee9823
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...amitlee9823
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteedamy56318795
 
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...only4webmaster01
 
hybrid Seed Production In Chilli & Capsicum.pptx
hybrid Seed Production In Chilli & Capsicum.pptxhybrid Seed Production In Chilli & Capsicum.pptx
hybrid Seed Production In Chilli & Capsicum.pptx9to5mart
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Researchmichael115558
 
BDSM⚡Call Girls in Mandawali Delhi >àŒ’8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >àŒ’8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >àŒ’8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >àŒ’8448380779 Escort ServiceDelhi Call girls
 
Call Girls In Bellandur ☎ 7737669865 đŸ„” Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 đŸ„” Book Your One night StandCall Girls In Bellandur ☎ 7737669865 đŸ„” Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 đŸ„” Book Your One night Standamitlee9823
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightDelhi Call girls
 
Call Girls In Hsr Layout ☎ 7737669865 đŸ„” Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 đŸ„” Book Your One night StandCall Girls In Hsr Layout ☎ 7737669865 đŸ„” Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 đŸ„” Book Your One night Standamitlee9823
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...amitlee9823
 
âž„đŸ” 7737669865 đŸ”â–» Thrissur Call-girls in Women Seeking Men 🔝Thrissur🔝 Escor...
âž„đŸ” 7737669865 đŸ”â–» Thrissur Call-girls in Women Seeking Men  🔝Thrissur🔝   Escor...âž„đŸ” 7737669865 đŸ”â–» Thrissur Call-girls in Women Seeking Men  🔝Thrissur🔝   Escor...
âž„đŸ” 7737669865 đŸ”â–» Thrissur Call-girls in Women Seeking Men 🔝Thrissur🔝 Escor...amitlee9823
 
CHEAP Call Girls in Rabindra Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Rabindra Nagar  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Rabindra Nagar  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Rabindra Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls In Attibele ☎ 7737669865 đŸ„” Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 đŸ„” Book Your One night StandCall Girls In Attibele ☎ 7737669865 đŸ„” Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 đŸ„” Book Your One night Standamitlee9823
 
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -Pooja Nehwal
 

KĂŒrzlich hochgeladen (20)

Predicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science ProjectPredicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science Project
 
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
 
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
 
hybrid Seed Production In Chilli & Capsicum.pptx
hybrid Seed Production In Chilli & Capsicum.pptxhybrid Seed Production In Chilli & Capsicum.pptx
hybrid Seed Production In Chilli & Capsicum.pptx
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
BDSM⚡Call Girls in Mandawali Delhi >àŒ’8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >àŒ’8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >àŒ’8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >àŒ’8448380779 Escort Service
 
Call Girls In Bellandur ☎ 7737669865 đŸ„” Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 đŸ„” Book Your One night StandCall Girls In Bellandur ☎ 7737669865 đŸ„” Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 đŸ„” Book Your One night Stand
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 
Call Girls In Hsr Layout ☎ 7737669865 đŸ„” Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 đŸ„” Book Your One night StandCall Girls In Hsr Layout ☎ 7737669865 đŸ„” Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 đŸ„” Book Your One night Stand
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
 
âž„đŸ” 7737669865 đŸ”â–» Thrissur Call-girls in Women Seeking Men 🔝Thrissur🔝 Escor...
âž„đŸ” 7737669865 đŸ”â–» Thrissur Call-girls in Women Seeking Men  🔝Thrissur🔝   Escor...âž„đŸ” 7737669865 đŸ”â–» Thrissur Call-girls in Women Seeking Men  🔝Thrissur🔝   Escor...
âž„đŸ” 7737669865 đŸ”â–» Thrissur Call-girls in Women Seeking Men 🔝Thrissur🔝 Escor...
 
CHEAP Call Girls in Rabindra Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Rabindra Nagar  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Rabindra Nagar  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Rabindra Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Call Girls In Attibele ☎ 7737669865 đŸ„” Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 đŸ„” Book Your One night StandCall Girls In Attibele ☎ 7737669865 đŸ„” Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 đŸ„” Book Your One night Stand
 
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
 

10b. Graph Databases Lab

  • 1. Graph Oriented Databases Lab Ciao ciao Vai a fare ciao ciao Dr. Fabio Fumarola
  • 3. Getting Started ‱ As example we use the Graph of the Godsexample ‱ This Graph stores: – As nodes: locations, god, demigod, titan, monster and humans – As relations: battled, mother, father, brother, lives, person 3
  • 4. 4
  • 5. Start TitanDB There are three options: 1.Download a binary version from https://github.com/thinkaurelius/titan/wiki/Downloads 2.Download a Docker image from docker hub https://registry.hub.docker.com/u/lulumialu/titandb/ 5
  • 6. Docker Setup $ docker pull lulumialu/titandb $ docker run –it--name titan lulumialu/titandb bash $ ./bin/gremlin.sh 6
  • 7. Start with the shell ‱ The Gremlin terminal is a Groovy shell ‱ Groovy is a superset of Java that has various shorthand 7
  • 8. Loading the Graph of Gods ‱ We use BerkeleyDB and Elasticsearch index backend 8 gremlin> g = TitanFactory.open('conf/titan-berkeleydb-es.properties') ==>titangraph[berkeleyje:../db/berkeley] gremlin> GraphOfTheGodsFactory.load(g) ==>null
  • 10. Find a Starting Node ‱ The first step is locating a node using a graph index ‱ That entry point is an element (or set of elements) ‱ Starting from that we can traverse the graph 10 gremlin> saturn = g.V.has('name','saturn').next() ==>v[256] gremlin> saturn.map() ==>name=saturn ==>age=10000 gremlin> saturn.in('father').in('father').name ==>hercules
  • 11. Find a Starting Edge ‱ We can use GeoQuery to query the place edge ‱ We look for event happened within 50 kms from Athens 11 g.query().has('place',WITHIN,Geoshape.circle(37.97,23.72,50)).edges(). collect { it.bothV.name.next(2) } ==>[hercules, hydra] ==>[hercules, nemean]
  • 12. Graph Traversal: Saturn’s grandchild was Hercules 12
  • 13. Graph Traversal: Saturn’s grandchild was Hercules 13 gremlin> hercules = saturn.as('x').in('father').loop('x') {it.loops < 3}.next() ==>v[1536]
  • 14. Graph Traversal: to prove that Hercules is demigod 14
  • 15. Graph Traversal: to prove that Hercules is demigod 15 gremlin> hercules.out('father','mother') ==>v[1024] ==>v[1792] gremlin> hercules.out('father','mother').name ==>jupiter ==>alcmene gremlin> hercules.out('father','mother')*.getVertexLabel() ==>god ==>human gremlin> hercules.getVertexLabel() ==>demigod
  • 16. Query: find Hercules heroic exploits 16
  • 17. Query: find Hercules heroic exploits 17 gremlin> hercules.out('battled') ==>v[2304] ==>v[2560] ==>v[2816] gremlin> hercules.out('battled').map ==>{name=nemean} ==>{name=hydra} ==>{name=cerberus} gremlin> hercules.outE('battled').has('time',T.gt,1).inV.name ==>cerberus ==>hydra
  • 18. Query: Cohabiters of Tartarus 18
  • 19. Query: Cohabiters of Tartarus 19 gremlin> pluto = g.V('name','pluto').next() ==>v[2048] gremlin> // who are pluto's cohabitants? gremlin> pluto.out('lives').in('lives').name ==>pluto ==>cerberus gremlin> // pluto can't be his own cohabitant gremlin> pluto.out('lives').in('lives').except([pluto]).name ==>cerberus gremlin> pluto.as('x').out('lives').in('lives').except('x').name ==>cerberus
  • 22. Query: Pluto’s Brothers 22 gremlin> pluto.out('brother').out('lives').name ==>sky ==>sea gremlin> // which brother lives in which place? gremlin> pluto.out('brother').as('god').out('lives').as('place').select ==>[god:v[1024], place:v[512]] ==>[god:v[1280], place:v[768]] gremlin> // what is the name of the brother and the name of the place? gremlin> pluto.out('brother').as('god').out('lives').as('place').select{it.name} ==>[god:jupiter, place:sky] ==>[god:neptune, place:sea]
  • 23. Query: Reason Pluto lives in Tartarus 23
  • 24. Query: Reason Pluto lives in Tartarus 24 gremlin> pluto.outE('lives').reason ==>no fear of death gremlin> g.query().has('reason',CONTAINS,'loves').edges() ==>e[6xs-sg-m51-e8][1024-lives->512] ==>e[70g-zk-m51-lc][1280-lives->768] gremlin> g.query().has('reason',CONTAINS,'loves').edges().collect{ [it.outV.name.next(),it.reason,it.inV.name.next()] } ==>[jupiter, loves fresh breezes, sky] ==>[neptune, loves waves, sea]
  • 25. Gremlin in Depth For a complete gremlin guide check ‱http://s3.thinkaurelius.com/docs/titan/0.5.4/gremlin. html ‱http://gremlindocs.com/ ‱http://sql2gremlin.com/ 25
  • 26. Schema and Data Modeling 26
  • 27. Defining an Edge Label 1/2 ‱ We need a unique name for the label edge ‱ Multiplicity Settings: – MULTI: Allows multiple edges of the same label between any pair of vertices. – SIMPLE: Allows at most one edge of such label between any pair of vertices. – MANY2ONE: Allows at most one outgoing edge of such label on any vertex in the graph but places no constraint on incoming edges. 27
  • 28. Defining an Edge Label 2/2 ‱ We need a unique name for the label edge ‱ Multiplicity Settings: – ONE2MANY: Allows at most one incoming edge of such label on any vertex in the graph but places no constraint on outgoing edges. – ONE2ONE: Allows at most one incoming and one outgoing edge of such label on any vertex in the graph. 28
  • 29. Defining an Edge Label 29 mgmt = g.getManagementSystem() follow = mgmt.makeEdgeLabel('follow').multiplicity(Multiplicity.MULTI).make() mother = mgmt.makeEdgeLabel('mother').multiplicity(Multiplicity.MANY2ONE). make() mgmt.commit()
  • 30. Defining a Property ‱ Properties on vertices and edges are key-value pairs. ‱ For instance, the property name='Daniel' has the key name and the value 'Daniel'. 30
  • 31. Property Key Cardinality Are used to set a cardinality of the values of a property ‱Single ‱List ‱Set 31
  • 32. Property Key Cardinality 32 mgmt = g.getManagementSystem() birthDate = mgmt.makePropertyKey('birthDate').dataType(Long.class).cardinality(C ardinality.SINGLE).make() name = mgmt.makePropertyKey('name').dataType(String.class).cardinality(Car dinality.SET).make() sensorReading = mgmt.makePropertyKey('sensorReading').dataType(Double.class).card inality(Cardinality.LIST).make() mgmt.commit()
  • 33. Relation Types for edges ‱ The names of relation types must be unique in the graph 33 mgmt = g.getManagementSystem() if (mgmt.containsRelationType('name')) name = mgmt.getPropertyKey('name') mgmt.getRelationTypes(EdgeLabel.class) mgmt.commit()
  • 34. Defining Vertex Labels ‱ Like edges, vertices have labels. ‱ Unlike edge labels, vertex labels are optional. 34 mgmt = g.getManagementSystem() person = mgmt.makeVertexLabel('person').make(); mgmt.commit() // Create a labeled vertex person = g.addVertexWithLabel('person') // Create an unlabeled vertex v = g.addVertex(null) g.commit()
  • 36. Rexter ‱ Titan uses the Rexster engine as the server component to process and answer client queries. ‱ The Titan Download comes preconfigured with a script, titan.sh, which starts Cassandra, Elasticsearch, and Titan with Rexster. 36
  • 37. Rexster Dog House Visualization 37