SlideShare uma empresa Scribd logo
1 de 105
Baixar para ler offline
A free guided tour of

(Reality)-[:IS_A]->(Graph)
What we have always known

selection sort (O(n2))
What we have always known

selection sort (O(n2))
|
heap sort (O(n*log(n))
What we have always known

selection sort (O(n2))
|
heap sort (O(n*log(n))

same algorithm, different data structure,
better execution time !
What we have always known

1 data structure
1 usage
One NOSQL lesson?

1 data STORE
1 usage
One NOSQL lesson?

polyglot persistence, anyone ?
DevFest Istanbul - a free guided tour of Neo4J
ZOOM on Graph Databases

graph
=
nodes/vertices
+
edges/relationships/arcs
Graph DB : a common model
property graph
=
nodes
+
labeled relationships
+
K/V pairs
Graph DB : a common model
property graph
=
labeledneov2 nodes
+
labeled relationships
+
K/V pairs
Property Graph DBs

lock DB
F
Property Graph DBs

WHY DO THEY

KICK ASS?
BECAUSE
Graph-based computing

Intuitive model
Expressive querying
Powerful analyses
Graph-based computing

Intuitive model

Whiteboard-friendliness

Expressive querying

Pregel (GOOG), TAO (FB)

Powerful analyses

Pattern matching, path
finding...
A glimpse at usecases: mantra

RELATIONSHIPS
ARE AS IMPORTANT AS

E N T I T I E S
A glimpse at usecases
Recommendations
People I may know

ex: people known by contacts I have
worked with in the past
A glimpse at usecases
Recommendations
People I may know

ex: people known by contacts I have
worked with in the past

Products I should buy

ex: people who bought “Twilight” and
“Justin Bieber biography” like you
also bought “The ultimate emo
guide”
A glimpse at usecases
Recommendations
People I may know

ex: people known by contacts I have
worked with in the past

Products I should buy

ex: people who bought “Twilight” and
“Justin Bieber biography” like you
also bought “The ultimate emo
guide”

Movies I should watch with whom and where...
A glimpse at usecases
Pattern detection
Fraud

ex: many IPs from Fraudistan have
made a purchase of game X
in the last hour
A glimpse at usecases
Pattern detection
Fraud

ex: many IPs from Fraudistan have
made a purchase of game X
in the last hour

Disease detection

ex: DNA sequencing
A glimpse at usecases
Pattern detection
Fraud

ex: many IPs from Fraudistan have
made a purchase of game X
in the last hour

Disease detection

ex: DNA sequencing

Trend detection

ex: the term Flu has been tweeted
789% times more in Guatemala area
in the last 24 hours
A glimpse at usecases
Path finding
Genealogy

ex: is François Mitterand related to
Elizabeth II ? (yes)
A glimpse at usecases
Path finding
Genealogy

ex: is François Mitterand related to
Elizabeth II ? (yes)

Navigation

ex: what is the cheapest way to go
to a sushi place < 15€ for me (Place
de Clichy) and my friend (Place d’
Italie)?
A glimpse at usecases
Path finding
Genealogy

ex: is François Mitterand related to
Elizabeth II ? (yes)

Navigation

ex: what is the cheapest way to go
to a sushi place < 15€ for me (Place
de Clichy) and my friend (Place d’
Italie)?

Impact analysis

ex: which customers are impacted if
network switch XYZ fails?
A glimpse at usecases
and more...
Topological ordering

ex: given a set of dependencies, in
which order should I include them?

Community detection

ex: tag clustering on annotated
resources to detect groups of interest
(targeted advertising)

and much more...
A glimpse at usecases
http://www.opentreeoflife.org/

http://bio4j.com/

http://www.reco4j.org/

http://structr.org/

https://github.com/neo4j-contrib/graphgist/wiki
In short

GRAPHS ARE

EVERYWHERE!
THAT’S WHY
YOU
SHOULD TRY
Neo4J - the origins

Circa 2000, somewhere in Sweden
2 swedish guys hacking in a garage
Neo4J - the origins
Dialogue
- Man, I cannot stand Informix anymore
- Right, we’ve pushed it to the limit
- All these documents, these workflows…
- Right, it’s way too densely connected.
- Connected… connections? CONNECTIONS??
DevFest Istanbul - a free guided tour of Neo4J
Flash-forward: Neo Technology!

1 company

Neo Technology

1 main product

Neo4J

~50 employees
All over the world

Sweden, US, Germany,
France, Malaysia, NZ...
Neo4J - moaar facts & figures

Versions

2.0.0.M06 / 1.9.4

Licenses

GPL, AGPL, OEM, Commercial

235 nodes

34_359_738_368

235 relationships
> 236 properties

at most 238

… capacity can be tailored on demand
Neo4J anatomy
GRAPH
ON DISK
(roughly)

original presentation: http://www.ustream.tv/channel/neo4j
DevFest Istanbul - a free guided tour of Neo4J
DevFest Istanbul - a free guided tour of Neo4J
DevFest Istanbul - a free guided tour of Neo4J
DevFest Istanbul - a free guided tour of Neo4J
CORE
API
Neo4J anatomy
Node CRUD (JVM)

GraphDatabaseService graphDB = new TestGraphDatabaseFactory ()
.newImpermanentDatabase();

try (Transaction transaction = graphDB.beginTx()) {
Node character =graphDB.createNode( DynamicLabel .label("CHARACTER" ));
character.setProperty( "name", "Homer Simpson" );
transaction .success();
}
Node CRUD (JVM)
officially distributed
test version!

GraphDatabaseService graphDB = new TestGraphDatabaseFactory()
.newImpermanentDatabase();

try (Transaction transaction = graphDB.beginTx()) {
Node character =graphDB.createNode( DynamicLabel .label("CHARACTER" ));
character.setProperty( "name", "Homer Simpson" );
transaction .success();
}
Node CRUD (JVM)

GraphDatabaseService graphDB = new TestGraphDatabaseFactory ()
.newImpermanentDatabase();

try (Transaction transaction = graphDB.beginTx()) {
Node character =graphDB.createNode( DynamicLabel .label("CHARACTER" ));
character.setProperty( "name", "Homer Simpson" );
transaction .success();
}

transaction is MANDATORY
Java 7 required since 2.0
Node CRUD (JVM)

GraphDatabaseService graphDB = new TestGraphDatabaseFactory ()
.newImpermanentDatabase();

try (Transaction transaction = graphDB.beginTx()) {
Node character =graphDB.createNode( DynamicLabel.label("CHARACTER"));
character.setProperty( "name", "Homer Simpson" );
transaction .success();
}

labels are a way
to semi-structure your nodes
(since 2.0)
Node CRUD (JVM)

try (Transaction transaction = graphDB.beginTx()) {
for (Node node: graphDB.findNodesByLabelAndProperty(
DynamicLabel .label("CHARACTER" ),
"name",
"Homer Simpson" )) {
/* do something very useful */
}
transaction .success();
}
Node CRUD (JVM)

try (Transaction transaction = graphDB.beginTx()) {
for (Node node: graphDB.findNodesByLabelAndProperty(
DynamicLabel .label("CHARACTER" ),
"name",
"Homer Simpson" )) {
/* do something very useful */
}
transaction .success();
}

Gotchas
●

avoid graphDB.findById !!!

●

transaction is MANDATORY for reads as well (new in 2.0)
Node CRUD (JVM)

try (Transaction transaction = graphDB.beginTx()) {
Node character = /*lookup*/ ;
character.delete();
transaction .success();
}
Node CRUD (JVM)

try (Transaction transaction = graphDB.beginTx()) {
Node character = /*lookup*/ ;
character.delete();
transaction .success();
}

Gotchas
●

no relationships must be attached when transaction commits

●

all properties will be automatically removed
Relationship CRUD (JVM)

try (Transaction transaction = graphDB.beginTx()) {
Node homer = /*lookup*/ ;
Node doughnut = /*lookup*/ ;
Relationship eating = homer.createRelationshipTo(
doughnut,
DynamicRelationshipType .withName("LOVES_EATING" )
);
eating.setProperty( "quantity" , Long.MAX_VALUE);
transaction .success();
}
Relationship CRUD (JVM)

try (Transaction transaction = graphDB.beginTx()) {
Node homer = /*lookup*/ ;
Node doughnut = /*lookup*/ ;
Relationship eating = homer.createRelationshipTo(
doughnut,
DynamicRelationshipType.withName("LOVES_EATING")
);
eating.setProperty( "quantity" , Long.MAX_VALUE);
transaction .success();
}

unrelated to
Node labels
Relationship CRUD (JVM)

try (Transaction transaction = graphDB.beginTx()) {
Node homer = /*lookup*/ ;
Node doughnut = /*lookup*/ ;
Relationship eating = homer.createRelationshipTo(
doughnut,
DynamicRelationshipType .withName("LOVES_EATING" )
);
eating.setProperty( "quantity" , Long.MAX_VALUE);
transaction .success();
}

Gotchas
●

relationship direction matters at query time

●

avoid human-eating doughnuts ;-)
Relationship CRUD (JVM)

try (Transaction transaction = graphDB.beginTx()) {
Relationship relationship = /*lookup*/ ;
relationship .delete();
transaction .success();
}
Relationship CRUD (JVM)

try (Transaction transaction = graphDB.beginTx()) {
Relationship relationship = /*lookup*/ ;
relationship .delete();
transaction .success();
}

Gotcha
●

a write lock is set on the relationship, as well as both start AND end
nodes of the relationship
Core API

Low Level
Transactions are ALWAYS required (v2.0)
Technical IDs are dangerous (findById)
have a look at github.com/sarmbruster/neo4j-uuid

SAME capabilities with REST API
QUERYING

DATA
Neo4J anatomy
Two strategies
IMPERATIVE

VERY extensive
Totally customizable

100% under your
responsability

DECLARATIVE

VERY intuitive
90% of your needs

No free lunch (yet)!
Cypher PROFILE on its way
Two strategies

TRAVERSALS

CYPHER QL
(/GREMLIN)
Traversals
DEPTH FIRST

BREADTH FIRST
Traversals
Traversal - basic git

log

try (Transaction transaction = graphDB.beginTx()) {
for (Path position : Traversal.description()
.depthFirst()
.evaluator(toDepth(LOG_DEFAULT_SIZE))
.relationships(
DynRelType .withName("PARENT_COMMIT" ),
INCOMING
).traverse(headCommit)) {
Node currentNode = position.endNode;
logs.add(currentNode);
}
transaction .success();
}
Traversal - basic git

log

try (Transaction transaction = graphDB.beginTx()) {
for (Path position : Traversal.description()
.depthFirst()
.evaluator(toDepth(LOG_DEFAULT_SIZE))
lazy traversal

.relationships(

definition

DynRelType.withName("PARENT_COMMIT"),
Direction.INCOMING
).traverse(headCommit)) {

Node currentNode = position.endNode;
logs.add(currentNode);
}
transaction .success();
}
Traversal - basic git

log

try (Transaction transaction = graphDB.beginTx()) {
for (Path position : Traversal.description()
.depthFirst()
.evaluator(toDepth(LOG_DEFAULT_SIZE))
.relationships(
DynRelType.withName("PARENT_COMMIT" ),
INCOMING
).traverse(headCommit)) {
Node currentNode = position.endNode;
logs.add(currentNode);
}
transaction .success();
}

start traversal
with node
Traversal - basic git

log

try (Transaction transaction = graphDB.beginTx()) {
for (Path position : Traversal.description()
.depthFirst()
.evaluator(toDepth(LOG_DEFAULT_SIZE))
.relationships(
DynRelType.withName("PARENT_COMMIT" ),
INCOMING
).traverse(headCommit)) {
Node currentNode = position.endNode;
logs.add(currentNode);
}
transaction .success();
}

keeps track of
current position
& visited nodes/rels
Traversals

Extensive
but verbose
and error-prone

WE <3 ASCII ART!
Pattern matching and ASCII art

WE <3
CYPHER
Pattern matching and ASCII art
Pattern matching and ASCII art
Pattern matching and ASCII art
Pattern matching and ASCII art
Pattern matching and ASCII art
Pattern matching and ASCII art
Cypher syntax with <3

Cypher

()-->()
Cypher syntax with <3

Cypher

(A)-->(B)
Cypher syntax with <3

Cypher

LOVES

(A)-[:LOVES]->(B)
Cypher syntax with <3

Cypher
(C)<--(A)-->(B)-->(C)
A-->B-->C,A-->C
Cypher reads

START <lookup>

(optional)

MATCH <pattern>
WHERE <filtering>
RETURN <expression>
Cypher reads

MATCH (homer:HUMAN)-[:LOVES_EATING]->(doughnut:FOOD)
WHERE

homer.name = "Homer Simpson"

AND doughnut.brand = "Fattylicious!"
RETURN homer
Cypher reads

MATCH (sugg:CONTACT)-[:IN_CONTACT*2..10]-(me:CONTACT)
WHERE me.name = "Florent Biville"
AND me <> sugg
RETURN me, sugg
Cypher reads
RULES OF THUMB
● MATCH for results
● use WHERE to filter (WHERE

)

a-[:F]->b or NOT(a-[:F]->b)

● favour parameters over literals (exec. plan reuse)
● javacodegeeks.com: “optimizing Neo4j Cypher Queries”
Cypher writes

CREATE (UNIQUE) <expression>

MERGE <expression>
Cypher writes

CREATE (homer:HUMAN:DAD {name: "Homer Simpson"})
RETURN homer
Cypher writes

START homer = node:characters("name:Hom*")
MATCH (d:JUNK:FOOD)
WHERE d.brand = "Fattylicious!"
CREATE (homer)-[luv:LOVES_EATING {quantity:∞}]->(d)
RETURN luv
Cypher writes

MERGE (keanu:ACTOR {name:'Keanu Reeves'})
ON CREATE keanu
SET keanu.created = timestamp()
ON MATCH keanu
SET keanu.lastSeen = timestamp()
RETURN keanu
Cypher - I want moaaar

Declarative power
Super nice syntax
Evolutionary design with MERGE!
http://console.neo4j.org to try it out!
Cypher will the #1 way to query data!
OBJECT-GRAPH

MAPPING
With...
Spring Data
History ~2010

Rod Johnson,
Scala last poet

Emil Eifrem,
Neo Tech. founder & CEO
Spring Data
Familiar model for Spring apps

THIN common layer
Embraces diversity

MongoDB
Redis
Neo4J
ElasticSearch…

Current version

2.3.1.RELEASE
Vanilla Neo4J repositories with Spring
@Repository
public class BranchRepository {
public Relationship createBranch (Node p, Node c, Map<String,?> props) {
try (Transaction transaction = graphDB.beginTx()) {
Relationship relationship = p.createRelationshipTo(
c,
DynamicRelationshipType .name("HAS_BRANCH" )
);
for (Entry<String,?> entry:props.entrySet()) {
relationship .setProperty(entry .getKey(), entry .getValue());
}
transaction .success();
return relationship;
}}}
Vanilla Neo4J repositories with Spring
@Repository
public class BranchRepository {
public Relationship createBranch (Node p, Node c, Map<String,?> props) {
try (Transaction transaction = graphDB.beginTx()) {
Relationship relationship = p.createRelationshipTo(
commit,
DynamicRelationshipType .name("HAS_BRANCH" )
);
for (Entry<String,?> entry:props.entrySet()) {
relationship .setProperty(entry .getKey(), entry .getValue());
}
transaction .success();
return relationship;
}}}
Spring Data Neo4J repositories
public interface BranchRepository extends GraphRepository< Branch> {
// look ma! no code!
}
Moaaar Spring Data Neo4J repositories

public interface BranchRepository extends GraphRepository< Branch> {

Iterable<Branch> findByNameLike (String name);

@Query("MATCH (p:PROJECT)-[b:HAS_BRANCH]->(c:COMMIT) RETURN b" )
Page<Branch> lookMaIveGotPages ();

Branch findByNameAndCommitIdentifierLike (String name, String commit);
}
Moaaar Spring Data Neo4J repositories

public interface BranchRepository extends GraphRepository< Branch> {

Iterable<Branch> findByNameLike (String name);

@Query("MATCH (p:PROJECT)-[b:HAS_BRANCH]->(c:COMMIT) RETURN b" )

Cool things

Page<Branch> lookMaIveGotPages ();

● Branch findByNameAndCommitIdentifierLike (String
boilerplate methods already provided
}●

name, String commit);

you declare methods following a naming convention, Spring Data Neo4J
generates the right implementation for ya!

●

YOU EXPOSE YOUR DOMAIN, no Nodes, no Relationships!
Spring Data Neo4J node entities
@NodeEntity
public class Person {
@GraphId
private Long id;
@Indexed(indexName = "people", type=FULLTEXT)
private String name;
@RelatedTo (type="OWNS", enforceTargetType = true)
private Car car;
@RelatedToVia (type="FRIEND_OF" , direction = Direction.INCOMING)
private Iterable<Friendship> friendships;
@GraphTraversal (traversal = PeopleTraversalBuilder .class,
elementClass = Person.class, params = "persons")
private Iterable<Person> people;
}
Spring Data Neo4J relationship entities
@RelationshipEntity(type ="FRIEND_OF" )
public class Friendship {
@StartNode
private Person person;
@EndNode
private Dog humansBestFriend;
@GraphProperty /* optional here ;-) */
private Date since;
/**
* moaaaaar properties
*/
}
And much more

Neo4jTemplate
Geospatial queries

Cross-store support
Dynamic relationships
“Advanced” mapping
Conclusion
So much to talk about, so little time
● moaaar Cypher
● REST
○ standard API
○ unmanaged extensions
○ streaming
● Tinkerpop abstractions, http://www.tinkerpop.com/
● dataviz
○ auto : http://linkurio.us/, Neoclipse, Gephi
○ custom : d3.js, sigma.js…
● NeoAAS : http://www.graphenedb.com/, Heroku
● misc. : backup, batch-import, JDBC drivers
And one more thing

AssertJ-Neo4J 1.0 is coming soon!
Fluent test assertions for Neo4J
https://github.com/joel-costigliola/assertj-neo4j
SORUSU
OLAN?
Bana ulaşın

@fbiville
@LateraIThoughts
florent.biville.net
www.lateral-thoughts.com

Mais conteúdo relacionado

Mais procurados

Distributed algorithms for big data @ GeeCon
Distributed algorithms for big data @ GeeConDistributed algorithms for big data @ GeeCon
Distributed algorithms for big data @ GeeConDuyhai Doan
 
Pushing the rule engine to its limits with drools planner (parisjug 2010-11-09)
Pushing the rule engine to its limits with drools planner (parisjug 2010-11-09)Pushing the rule engine to its limits with drools planner (parisjug 2010-11-09)
Pushing the rule engine to its limits with drools planner (parisjug 2010-11-09)Geoffrey De Smet
 
The Ring programming language version 1.3 book - Part 84 of 88
The Ring programming language version 1.3 book - Part 84 of 88The Ring programming language version 1.3 book - Part 84 of 88
The Ring programming language version 1.3 book - Part 84 of 88Mahmoud Samir Fayed
 
groovy rules
groovy rulesgroovy rules
groovy rulesPaul King
 
Gremlin 101.3 On Your FM Dial
Gremlin 101.3 On Your FM DialGremlin 101.3 On Your FM Dial
Gremlin 101.3 On Your FM DialMarko Rodriguez
 
OSDC.fr 2012 :: Cascalog : progammation logique pour Hadoop
OSDC.fr 2012 :: Cascalog : progammation logique pour HadoopOSDC.fr 2012 :: Cascalog : progammation logique pour Hadoop
OSDC.fr 2012 :: Cascalog : progammation logique pour HadoopPublicis Sapient Engineering
 
Naïveté vs. Experience
Naïveté vs. ExperienceNaïveté vs. Experience
Naïveté vs. ExperienceMike Fogus
 
The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84Mahmoud Samir Fayed
 
RxJava и Android. Плюсы, минусы, подводные камни
RxJava и Android. Плюсы, минусы, подводные камниRxJava и Android. Плюсы, минусы, подводные камни
RxJava и Android. Плюсы, минусы, подводные камниStfalcon Meetups
 
The Macronomicon
The MacronomiconThe Macronomicon
The MacronomiconMike Fogus
 
[DSC 2016] 系列活動:李泳泉 / 星火燎原 - Spark 機器學習初探
[DSC 2016] 系列活動:李泳泉 / 星火燎原 - Spark 機器學習初探[DSC 2016] 系列活動:李泳泉 / 星火燎原 - Spark 機器學習初探
[DSC 2016] 系列活動:李泳泉 / 星火燎原 - Spark 機器學習初探台灣資料科學年會
 
Developing applications with rules, workflow and event processing (it@cork 2010)
Developing applications with rules, workflow and event processing (it@cork 2010)Developing applications with rules, workflow and event processing (it@cork 2010)
Developing applications with rules, workflow and event processing (it@cork 2010)Geoffrey De Smet
 
Sokoban Game Development Using Java ( Updated using Screenshots & Class Diagr...
Sokoban Game Development Using Java ( Updated using Screenshots & Class Diagr...Sokoban Game Development Using Java ( Updated using Screenshots & Class Diagr...
Sokoban Game Development Using Java ( Updated using Screenshots & Class Diagr...British Council
 

Mais procurados (20)

tutorial5
tutorial5tutorial5
tutorial5
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
 
Distributed algorithms for big data @ GeeCon
Distributed algorithms for big data @ GeeConDistributed algorithms for big data @ GeeCon
Distributed algorithms for big data @ GeeCon
 
Pushing the rule engine to its limits with drools planner (parisjug 2010-11-09)
Pushing the rule engine to its limits with drools planner (parisjug 2010-11-09)Pushing the rule engine to its limits with drools planner (parisjug 2010-11-09)
Pushing the rule engine to its limits with drools planner (parisjug 2010-11-09)
 
RealmDB for Android
RealmDB for AndroidRealmDB for Android
RealmDB for Android
 
The Ring programming language version 1.3 book - Part 84 of 88
The Ring programming language version 1.3 book - Part 84 of 88The Ring programming language version 1.3 book - Part 84 of 88
The Ring programming language version 1.3 book - Part 84 of 88
 
Nicety of Java 8 Multithreading
Nicety of Java 8 MultithreadingNicety of Java 8 Multithreading
Nicety of Java 8 Multithreading
 
groovy rules
groovy rulesgroovy rules
groovy rules
 
Gremlin 101.3 On Your FM Dial
Gremlin 101.3 On Your FM DialGremlin 101.3 On Your FM Dial
Gremlin 101.3 On Your FM Dial
 
OSDC.fr 2012 :: Cascalog : progammation logique pour Hadoop
OSDC.fr 2012 :: Cascalog : progammation logique pour HadoopOSDC.fr 2012 :: Cascalog : progammation logique pour Hadoop
OSDC.fr 2012 :: Cascalog : progammation logique pour Hadoop
 
Python Objects
Python ObjectsPython Objects
Python Objects
 
Naïveté vs. Experience
Naïveté vs. ExperienceNaïveté vs. Experience
Naïveté vs. Experience
 
The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84
 
RxJava и Android. Плюсы, минусы, подводные камни
RxJava и Android. Плюсы, минусы, подводные камниRxJava и Android. Плюсы, минусы, подводные камни
RxJava и Android. Плюсы, минусы, подводные камни
 
Return of c++
Return of c++Return of c++
Return of c++
 
The Macronomicon
The MacronomiconThe Macronomicon
The Macronomicon
 
[DSC 2016] 系列活動:李泳泉 / 星火燎原 - Spark 機器學習初探
[DSC 2016] 系列活動:李泳泉 / 星火燎原 - Spark 機器學習初探[DSC 2016] 系列活動:李泳泉 / 星火燎原 - Spark 機器學習初探
[DSC 2016] 系列活動:李泳泉 / 星火燎原 - Spark 機器學習初探
 
Developing applications with rules, workflow and event processing (it@cork 2010)
Developing applications with rules, workflow and event processing (it@cork 2010)Developing applications with rules, workflow and event processing (it@cork 2010)
Developing applications with rules, workflow and event processing (it@cork 2010)
 
mobl
moblmobl
mobl
 
Sokoban Game Development Using Java ( Updated using Screenshots & Class Diagr...
Sokoban Game Development Using Java ( Updated using Screenshots & Class Diagr...Sokoban Game Development Using Java ( Updated using Screenshots & Class Diagr...
Sokoban Game Development Using Java ( Updated using Screenshots & Class Diagr...
 

Destaque

Why Neo4J is awesome in 5 slides
Why Neo4J is awesome in 5 slidesWhy Neo4J is awesome in 5 slides
Why Neo4J is awesome in 5 slidesFlorent Biville
 
[FR] Introduction à Spring Data Neo4j 3.x
[FR] Introduction à Spring Data Neo4j 3.x[FR] Introduction à Spring Data Neo4j 3.x
[FR] Introduction à Spring Data Neo4j 3.xFlorent Biville
 
Hands on Neo4J - Duchess France/Zenexity - 25/09/2013
Hands on Neo4J - Duchess France/Zenexity - 25/09/2013Hands on Neo4J - Duchess France/Zenexity - 25/09/2013
Hands on Neo4J - Duchess France/Zenexity - 25/09/2013Florent Biville
 
A general introduction to Spring Data / Neo4J
A general introduction to Spring Data / Neo4JA general introduction to Spring Data / Neo4J
A general introduction to Spring Data / Neo4JFlorent Biville
 
(R)évolutionnez vos bases de données avec Liquibase
(R)évolutionnez vos bases de données avec Liquibase(R)évolutionnez vos bases de données avec Liquibase
(R)évolutionnez vos bases de données avec LiquibaseFlorent Biville
 

Destaque (6)

Why Neo4J is awesome in 5 slides
Why Neo4J is awesome in 5 slidesWhy Neo4J is awesome in 5 slides
Why Neo4J is awesome in 5 slides
 
[FR] Introduction à Spring Data Neo4j 3.x
[FR] Introduction à Spring Data Neo4j 3.x[FR] Introduction à Spring Data Neo4j 3.x
[FR] Introduction à Spring Data Neo4j 3.x
 
Hands on Neo4J - Duchess France/Zenexity - 25/09/2013
Hands on Neo4J - Duchess France/Zenexity - 25/09/2013Hands on Neo4J - Duchess France/Zenexity - 25/09/2013
Hands on Neo4J - Duchess France/Zenexity - 25/09/2013
 
A general introduction to Spring Data / Neo4J
A general introduction to Spring Data / Neo4JA general introduction to Spring Data / Neo4J
A general introduction to Spring Data / Neo4J
 
(R)évolutionnez vos bases de données avec Liquibase
(R)évolutionnez vos bases de données avec Liquibase(R)évolutionnez vos bases de données avec Liquibase
(R)évolutionnez vos bases de données avec Liquibase
 
Liquibase en action
Liquibase en actionLiquibase en action
Liquibase en action
 

Semelhante a DevFest Istanbul - a free guided tour of Neo4J

mobl presentation @ IHomer
mobl presentation @ IHomermobl presentation @ IHomer
mobl presentation @ IHomerzefhemel
 
Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Jonathan Felch
 
Building Go Web Apps
Building Go Web AppsBuilding Go Web Apps
Building Go Web AppsMark
 
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.GeeksLab Odessa
 
Wprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache HadoopWprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache HadoopSages
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
Scalding Big (Ad)ta
Scalding Big (Ad)taScalding Big (Ad)ta
Scalding Big (Ad)tab0ris_1
 
Ft10 de smet
Ft10 de smetFt10 de smet
Ft10 de smetnkaluva
 
Full stack analytics with Hadoop 2
Full stack analytics with Hadoop 2Full stack analytics with Hadoop 2
Full stack analytics with Hadoop 2Gabriele Modena
 
Introduction to Scalding and Monoids
Introduction to Scalding and MonoidsIntroduction to Scalding and Monoids
Introduction to Scalding and MonoidsHugo Gävert
 
3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DB
3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DB3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DB
3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DBAthens Big Data
 
mobl - model-driven engineering lecture
mobl - model-driven engineering lecturemobl - model-driven engineering lecture
mobl - model-driven engineering lecturezefhemel
 
Hadoop trainingin bangalore
Hadoop trainingin bangaloreHadoop trainingin bangalore
Hadoop trainingin bangaloreappaji intelhunt
 
{"JSON, Swift and Type Safety" : "It's a wrap"}
{"JSON, Swift and Type Safety" : "It's a wrap"}{"JSON, Swift and Type Safety" : "It's a wrap"}
{"JSON, Swift and Type Safety" : "It's a wrap"}Anthony Levings
 
OrientDB - The 2nd generation of (multi-model) NoSQL
OrientDB - The 2nd generation of  (multi-model) NoSQLOrientDB - The 2nd generation of  (multi-model) NoSQL
OrientDB - The 2nd generation of (multi-model) NoSQLRoberto Franchini
 
Using Neo4j from Java
Using Neo4j from JavaUsing Neo4j from Java
Using Neo4j from JavaNeo4j
 
Introduction into scalable graph analysis with Apache Giraph and Spark GraphX
Introduction into scalable graph analysis with Apache Giraph and Spark GraphXIntroduction into scalable graph analysis with Apache Giraph and Spark GraphX
Introduction into scalable graph analysis with Apache Giraph and Spark GraphXrhatr
 
JavaScript Foundations Day1
JavaScript Foundations Day1JavaScript Foundations Day1
JavaScript Foundations Day1Troy Miles
 

Semelhante a DevFest Istanbul - a free guided tour of Neo4J (20)

mobl presentation @ IHomer
mobl presentation @ IHomermobl presentation @ IHomer
mobl presentation @ IHomer
 
Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)
 
Building Go Web Apps
Building Go Web AppsBuilding Go Web Apps
Building Go Web Apps
 
Cloud jpl
Cloud jplCloud jpl
Cloud jpl
 
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
 
Wprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache HadoopWprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache Hadoop
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Shooting the Rapids
Shooting the RapidsShooting the Rapids
Shooting the Rapids
 
Scalding Big (Ad)ta
Scalding Big (Ad)taScalding Big (Ad)ta
Scalding Big (Ad)ta
 
Ft10 de smet
Ft10 de smetFt10 de smet
Ft10 de smet
 
Full stack analytics with Hadoop 2
Full stack analytics with Hadoop 2Full stack analytics with Hadoop 2
Full stack analytics with Hadoop 2
 
Introduction to Scalding and Monoids
Introduction to Scalding and MonoidsIntroduction to Scalding and Monoids
Introduction to Scalding and Monoids
 
3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DB
3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DB3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DB
3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DB
 
mobl - model-driven engineering lecture
mobl - model-driven engineering lecturemobl - model-driven engineering lecture
mobl - model-driven engineering lecture
 
Hadoop trainingin bangalore
Hadoop trainingin bangaloreHadoop trainingin bangalore
Hadoop trainingin bangalore
 
{"JSON, Swift and Type Safety" : "It's a wrap"}
{"JSON, Swift and Type Safety" : "It's a wrap"}{"JSON, Swift and Type Safety" : "It's a wrap"}
{"JSON, Swift and Type Safety" : "It's a wrap"}
 
OrientDB - The 2nd generation of (multi-model) NoSQL
OrientDB - The 2nd generation of  (multi-model) NoSQLOrientDB - The 2nd generation of  (multi-model) NoSQL
OrientDB - The 2nd generation of (multi-model) NoSQL
 
Using Neo4j from Java
Using Neo4j from JavaUsing Neo4j from Java
Using Neo4j from Java
 
Introduction into scalable graph analysis with Apache Giraph and Spark GraphX
Introduction into scalable graph analysis with Apache Giraph and Spark GraphXIntroduction into scalable graph analysis with Apache Giraph and Spark GraphX
Introduction into scalable graph analysis with Apache Giraph and Spark GraphX
 
JavaScript Foundations Day1
JavaScript Foundations Day1JavaScript Foundations Day1
JavaScript Foundations Day1
 

Último

AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...DianaGray10
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Adtran
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Brian Pichman
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1DianaGray10
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-pyJamie (Taka) Wang
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfDaniel Santiago Silva Capera
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXTarek Kalaji
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopBachir Benyammi
 

Último (20)

AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-py
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
201610817 - edge part1
201610817 - edge part1201610817 - edge part1
201610817 - edge part1
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBX
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 Workshop
 

DevFest Istanbul - a free guided tour of Neo4J

  • 1. A free guided tour of (Reality)-[:IS_A]->(Graph)
  • 2. What we have always known selection sort (O(n2))
  • 3. What we have always known selection sort (O(n2)) | heap sort (O(n*log(n))
  • 4. What we have always known selection sort (O(n2)) | heap sort (O(n*log(n)) same algorithm, different data structure, better execution time !
  • 5. What we have always known 1 data structure 1 usage
  • 6. One NOSQL lesson? 1 data STORE 1 usage
  • 7. One NOSQL lesson? polyglot persistence, anyone ?
  • 9. ZOOM on Graph Databases graph = nodes/vertices + edges/relationships/arcs
  • 10. Graph DB : a common model property graph = nodes + labeled relationships + K/V pairs
  • 11. Graph DB : a common model property graph = labeledneov2 nodes + labeled relationships + K/V pairs
  • 13. Property Graph DBs WHY DO THEY KICK ASS?
  • 16. Graph-based computing Intuitive model Whiteboard-friendliness Expressive querying Pregel (GOOG), TAO (FB) Powerful analyses Pattern matching, path finding...
  • 17. A glimpse at usecases: mantra RELATIONSHIPS ARE AS IMPORTANT AS E N T I T I E S
  • 18. A glimpse at usecases Recommendations People I may know ex: people known by contacts I have worked with in the past
  • 19. A glimpse at usecases Recommendations People I may know ex: people known by contacts I have worked with in the past Products I should buy ex: people who bought “Twilight” and “Justin Bieber biography” like you also bought “The ultimate emo guide”
  • 20. A glimpse at usecases Recommendations People I may know ex: people known by contacts I have worked with in the past Products I should buy ex: people who bought “Twilight” and “Justin Bieber biography” like you also bought “The ultimate emo guide” Movies I should watch with whom and where...
  • 21. A glimpse at usecases Pattern detection Fraud ex: many IPs from Fraudistan have made a purchase of game X in the last hour
  • 22. A glimpse at usecases Pattern detection Fraud ex: many IPs from Fraudistan have made a purchase of game X in the last hour Disease detection ex: DNA sequencing
  • 23. A glimpse at usecases Pattern detection Fraud ex: many IPs from Fraudistan have made a purchase of game X in the last hour Disease detection ex: DNA sequencing Trend detection ex: the term Flu has been tweeted 789% times more in Guatemala area in the last 24 hours
  • 24. A glimpse at usecases Path finding Genealogy ex: is François Mitterand related to Elizabeth II ? (yes)
  • 25. A glimpse at usecases Path finding Genealogy ex: is François Mitterand related to Elizabeth II ? (yes) Navigation ex: what is the cheapest way to go to a sushi place < 15€ for me (Place de Clichy) and my friend (Place d’ Italie)?
  • 26. A glimpse at usecases Path finding Genealogy ex: is François Mitterand related to Elizabeth II ? (yes) Navigation ex: what is the cheapest way to go to a sushi place < 15€ for me (Place de Clichy) and my friend (Place d’ Italie)? Impact analysis ex: which customers are impacted if network switch XYZ fails?
  • 27. A glimpse at usecases and more... Topological ordering ex: given a set of dependencies, in which order should I include them? Community detection ex: tag clustering on annotated resources to detect groups of interest (targeted advertising) and much more...
  • 28. A glimpse at usecases http://www.opentreeoflife.org/ http://bio4j.com/ http://www.reco4j.org/ http://structr.org/ https://github.com/neo4j-contrib/graphgist/wiki
  • 31. Neo4J - the origins Circa 2000, somewhere in Sweden 2 swedish guys hacking in a garage
  • 32. Neo4J - the origins Dialogue - Man, I cannot stand Informix anymore - Right, we’ve pushed it to the limit - All these documents, these workflows… - Right, it’s way too densely connected. - Connected… connections? CONNECTIONS??
  • 34. Flash-forward: Neo Technology! 1 company Neo Technology 1 main product Neo4J ~50 employees All over the world Sweden, US, Germany, France, Malaysia, NZ...
  • 35. Neo4J - moaar facts & figures Versions 2.0.0.M06 / 1.9.4 Licenses GPL, AGPL, OEM, Commercial 235 nodes 34_359_738_368 235 relationships > 236 properties at most 238 … capacity can be tailored on demand
  • 37. GRAPH ON DISK (roughly) original presentation: http://www.ustream.tv/channel/neo4j
  • 44. Node CRUD (JVM) GraphDatabaseService graphDB = new TestGraphDatabaseFactory () .newImpermanentDatabase(); try (Transaction transaction = graphDB.beginTx()) { Node character =graphDB.createNode( DynamicLabel .label("CHARACTER" )); character.setProperty( "name", "Homer Simpson" ); transaction .success(); }
  • 45. Node CRUD (JVM) officially distributed test version! GraphDatabaseService graphDB = new TestGraphDatabaseFactory() .newImpermanentDatabase(); try (Transaction transaction = graphDB.beginTx()) { Node character =graphDB.createNode( DynamicLabel .label("CHARACTER" )); character.setProperty( "name", "Homer Simpson" ); transaction .success(); }
  • 46. Node CRUD (JVM) GraphDatabaseService graphDB = new TestGraphDatabaseFactory () .newImpermanentDatabase(); try (Transaction transaction = graphDB.beginTx()) { Node character =graphDB.createNode( DynamicLabel .label("CHARACTER" )); character.setProperty( "name", "Homer Simpson" ); transaction .success(); } transaction is MANDATORY Java 7 required since 2.0
  • 47. Node CRUD (JVM) GraphDatabaseService graphDB = new TestGraphDatabaseFactory () .newImpermanentDatabase(); try (Transaction transaction = graphDB.beginTx()) { Node character =graphDB.createNode( DynamicLabel.label("CHARACTER")); character.setProperty( "name", "Homer Simpson" ); transaction .success(); } labels are a way to semi-structure your nodes (since 2.0)
  • 48. Node CRUD (JVM) try (Transaction transaction = graphDB.beginTx()) { for (Node node: graphDB.findNodesByLabelAndProperty( DynamicLabel .label("CHARACTER" ), "name", "Homer Simpson" )) { /* do something very useful */ } transaction .success(); }
  • 49. Node CRUD (JVM) try (Transaction transaction = graphDB.beginTx()) { for (Node node: graphDB.findNodesByLabelAndProperty( DynamicLabel .label("CHARACTER" ), "name", "Homer Simpson" )) { /* do something very useful */ } transaction .success(); } Gotchas ● avoid graphDB.findById !!! ● transaction is MANDATORY for reads as well (new in 2.0)
  • 50. Node CRUD (JVM) try (Transaction transaction = graphDB.beginTx()) { Node character = /*lookup*/ ; character.delete(); transaction .success(); }
  • 51. Node CRUD (JVM) try (Transaction transaction = graphDB.beginTx()) { Node character = /*lookup*/ ; character.delete(); transaction .success(); } Gotchas ● no relationships must be attached when transaction commits ● all properties will be automatically removed
  • 52. Relationship CRUD (JVM) try (Transaction transaction = graphDB.beginTx()) { Node homer = /*lookup*/ ; Node doughnut = /*lookup*/ ; Relationship eating = homer.createRelationshipTo( doughnut, DynamicRelationshipType .withName("LOVES_EATING" ) ); eating.setProperty( "quantity" , Long.MAX_VALUE); transaction .success(); }
  • 53. Relationship CRUD (JVM) try (Transaction transaction = graphDB.beginTx()) { Node homer = /*lookup*/ ; Node doughnut = /*lookup*/ ; Relationship eating = homer.createRelationshipTo( doughnut, DynamicRelationshipType.withName("LOVES_EATING") ); eating.setProperty( "quantity" , Long.MAX_VALUE); transaction .success(); } unrelated to Node labels
  • 54. Relationship CRUD (JVM) try (Transaction transaction = graphDB.beginTx()) { Node homer = /*lookup*/ ; Node doughnut = /*lookup*/ ; Relationship eating = homer.createRelationshipTo( doughnut, DynamicRelationshipType .withName("LOVES_EATING" ) ); eating.setProperty( "quantity" , Long.MAX_VALUE); transaction .success(); } Gotchas ● relationship direction matters at query time ● avoid human-eating doughnuts ;-)
  • 55. Relationship CRUD (JVM) try (Transaction transaction = graphDB.beginTx()) { Relationship relationship = /*lookup*/ ; relationship .delete(); transaction .success(); }
  • 56. Relationship CRUD (JVM) try (Transaction transaction = graphDB.beginTx()) { Relationship relationship = /*lookup*/ ; relationship .delete(); transaction .success(); } Gotcha ● a write lock is set on the relationship, as well as both start AND end nodes of the relationship
  • 57. Core API Low Level Transactions are ALWAYS required (v2.0) Technical IDs are dangerous (findById) have a look at github.com/sarmbruster/neo4j-uuid SAME capabilities with REST API
  • 60. Two strategies IMPERATIVE VERY extensive Totally customizable 100% under your responsability DECLARATIVE VERY intuitive 90% of your needs No free lunch (yet)! Cypher PROFILE on its way
  • 64. Traversal - basic git log try (Transaction transaction = graphDB.beginTx()) { for (Path position : Traversal.description() .depthFirst() .evaluator(toDepth(LOG_DEFAULT_SIZE)) .relationships( DynRelType .withName("PARENT_COMMIT" ), INCOMING ).traverse(headCommit)) { Node currentNode = position.endNode; logs.add(currentNode); } transaction .success(); }
  • 65. Traversal - basic git log try (Transaction transaction = graphDB.beginTx()) { for (Path position : Traversal.description() .depthFirst() .evaluator(toDepth(LOG_DEFAULT_SIZE)) lazy traversal .relationships( definition DynRelType.withName("PARENT_COMMIT"), Direction.INCOMING ).traverse(headCommit)) { Node currentNode = position.endNode; logs.add(currentNode); } transaction .success(); }
  • 66. Traversal - basic git log try (Transaction transaction = graphDB.beginTx()) { for (Path position : Traversal.description() .depthFirst() .evaluator(toDepth(LOG_DEFAULT_SIZE)) .relationships( DynRelType.withName("PARENT_COMMIT" ), INCOMING ).traverse(headCommit)) { Node currentNode = position.endNode; logs.add(currentNode); } transaction .success(); } start traversal with node
  • 67. Traversal - basic git log try (Transaction transaction = graphDB.beginTx()) { for (Path position : Traversal.description() .depthFirst() .evaluator(toDepth(LOG_DEFAULT_SIZE)) .relationships( DynRelType.withName("PARENT_COMMIT" ), INCOMING ).traverse(headCommit)) { Node currentNode = position.endNode; logs.add(currentNode); } transaction .success(); } keeps track of current position & visited nodes/rels
  • 69. Pattern matching and ASCII art WE <3 CYPHER
  • 70. Pattern matching and ASCII art
  • 71. Pattern matching and ASCII art
  • 72. Pattern matching and ASCII art
  • 73. Pattern matching and ASCII art
  • 74. Pattern matching and ASCII art
  • 75. Pattern matching and ASCII art
  • 76. Cypher syntax with <3 Cypher ()-->()
  • 77. Cypher syntax with <3 Cypher (A)-->(B)
  • 78. Cypher syntax with <3 Cypher LOVES (A)-[:LOVES]->(B)
  • 79. Cypher syntax with <3 Cypher (C)<--(A)-->(B)-->(C) A-->B-->C,A-->C
  • 80. Cypher reads START <lookup> (optional) MATCH <pattern> WHERE <filtering> RETURN <expression>
  • 81. Cypher reads MATCH (homer:HUMAN)-[:LOVES_EATING]->(doughnut:FOOD) WHERE homer.name = "Homer Simpson" AND doughnut.brand = "Fattylicious!" RETURN homer
  • 82. Cypher reads MATCH (sugg:CONTACT)-[:IN_CONTACT*2..10]-(me:CONTACT) WHERE me.name = "Florent Biville" AND me <> sugg RETURN me, sugg
  • 83. Cypher reads RULES OF THUMB ● MATCH for results ● use WHERE to filter (WHERE ) a-[:F]->b or NOT(a-[:F]->b) ● favour parameters over literals (exec. plan reuse) ● javacodegeeks.com: “optimizing Neo4j Cypher Queries”
  • 84. Cypher writes CREATE (UNIQUE) <expression> MERGE <expression>
  • 85. Cypher writes CREATE (homer:HUMAN:DAD {name: "Homer Simpson"}) RETURN homer
  • 86. Cypher writes START homer = node:characters("name:Hom*") MATCH (d:JUNK:FOOD) WHERE d.brand = "Fattylicious!" CREATE (homer)-[luv:LOVES_EATING {quantity:∞}]->(d) RETURN luv
  • 87. Cypher writes MERGE (keanu:ACTOR {name:'Keanu Reeves'}) ON CREATE keanu SET keanu.created = timestamp() ON MATCH keanu SET keanu.lastSeen = timestamp() RETURN keanu
  • 88. Cypher - I want moaaar Declarative power Super nice syntax Evolutionary design with MERGE! http://console.neo4j.org to try it out! Cypher will the #1 way to query data!
  • 91. Spring Data History ~2010 Rod Johnson, Scala last poet Emil Eifrem, Neo Tech. founder & CEO
  • 92. Spring Data Familiar model for Spring apps THIN common layer Embraces diversity MongoDB Redis Neo4J ElasticSearch… Current version 2.3.1.RELEASE
  • 93. Vanilla Neo4J repositories with Spring @Repository public class BranchRepository { public Relationship createBranch (Node p, Node c, Map<String,?> props) { try (Transaction transaction = graphDB.beginTx()) { Relationship relationship = p.createRelationshipTo( c, DynamicRelationshipType .name("HAS_BRANCH" ) ); for (Entry<String,?> entry:props.entrySet()) { relationship .setProperty(entry .getKey(), entry .getValue()); } transaction .success(); return relationship; }}}
  • 94. Vanilla Neo4J repositories with Spring @Repository public class BranchRepository { public Relationship createBranch (Node p, Node c, Map<String,?> props) { try (Transaction transaction = graphDB.beginTx()) { Relationship relationship = p.createRelationshipTo( commit, DynamicRelationshipType .name("HAS_BRANCH" ) ); for (Entry<String,?> entry:props.entrySet()) { relationship .setProperty(entry .getKey(), entry .getValue()); } transaction .success(); return relationship; }}}
  • 95. Spring Data Neo4J repositories public interface BranchRepository extends GraphRepository< Branch> { // look ma! no code! }
  • 96. Moaaar Spring Data Neo4J repositories public interface BranchRepository extends GraphRepository< Branch> { Iterable<Branch> findByNameLike (String name); @Query("MATCH (p:PROJECT)-[b:HAS_BRANCH]->(c:COMMIT) RETURN b" ) Page<Branch> lookMaIveGotPages (); Branch findByNameAndCommitIdentifierLike (String name, String commit); }
  • 97. Moaaar Spring Data Neo4J repositories public interface BranchRepository extends GraphRepository< Branch> { Iterable<Branch> findByNameLike (String name); @Query("MATCH (p:PROJECT)-[b:HAS_BRANCH]->(c:COMMIT) RETURN b" ) Cool things Page<Branch> lookMaIveGotPages (); ● Branch findByNameAndCommitIdentifierLike (String boilerplate methods already provided }● name, String commit); you declare methods following a naming convention, Spring Data Neo4J generates the right implementation for ya! ● YOU EXPOSE YOUR DOMAIN, no Nodes, no Relationships!
  • 98. Spring Data Neo4J node entities @NodeEntity public class Person { @GraphId private Long id; @Indexed(indexName = "people", type=FULLTEXT) private String name; @RelatedTo (type="OWNS", enforceTargetType = true) private Car car; @RelatedToVia (type="FRIEND_OF" , direction = Direction.INCOMING) private Iterable<Friendship> friendships; @GraphTraversal (traversal = PeopleTraversalBuilder .class, elementClass = Person.class, params = "persons") private Iterable<Person> people; }
  • 99. Spring Data Neo4J relationship entities @RelationshipEntity(type ="FRIEND_OF" ) public class Friendship { @StartNode private Person person; @EndNode private Dog humansBestFriend; @GraphProperty /* optional here ;-) */ private Date since; /** * moaaaaar properties */ }
  • 100. And much more Neo4jTemplate Geospatial queries Cross-store support Dynamic relationships “Advanced” mapping
  • 102. So much to talk about, so little time ● moaaar Cypher ● REST ○ standard API ○ unmanaged extensions ○ streaming ● Tinkerpop abstractions, http://www.tinkerpop.com/ ● dataviz ○ auto : http://linkurio.us/, Neoclipse, Gephi ○ custom : d3.js, sigma.js… ● NeoAAS : http://www.graphenedb.com/, Heroku ● misc. : backup, batch-import, JDBC drivers
  • 103. And one more thing AssertJ-Neo4J 1.0 is coming soon! Fluent test assertions for Neo4J https://github.com/joel-costigliola/assertj-neo4j