William Lyon presented on Neo4j 3.0 which introduces a new storage engine allowing unlimited graph size, new language drivers for easier application development, and improved operability for deploying Neo4j in the cloud, containers, and on premises. Key features include the new Bolt binary protocol, Java stored procedures, and an upgraded Cypher query engine with a new cost-based optimizer.
16. Official Language Drivers
• Foundational drivers for popular
programming languages
• Bolt: streaming binary wire
protocol
• Authoritative mapping to native
type system, uniform across
drivers
• Pluggable into richer frameworks
Spring Data Neo4j v4.1 uses Bolt-
based object-to-graph mapper
JavaScript Java .NET Python
Community
Drivers
Drivers
Bolt
17. Using Bolt: Official Language Drivers
With JavaScript
var driver = Graph.Database.driver("bolt://localhost");
var session = driver.session();
var result = session.run("MATCH (u:User) RETURN u.name");
18. Using Bolt: Official Language Drivers
With Python
driver = Graph.Database.driver("bolt://localhost")
session = driver.session()
result = session.run("MATCH (u:User) RETURN u.name")
19. Using Bolt: Official Language Drivers
Driver driver = GraphDatabase.driver( "bolt://localhost" );
try ( Session session = driver.session() ) {
StatementResult result = session.run("MATCH (u:User) RETURN u.name");
}
With Java
20. Using Bolt: Official Language Drivers
using (var driver = GraphDatabase.Driver("bolt://localhost"))
using (var session = driver.Session())
{
var result = session.Run("MATCH (u:User) RETURN u.name");
}
With .NET
21. Java Stored Procedures
Neo4j Execution Engine
Java Stored
Procedure
Applications
Bolt
Java Stored Procedures let you write
custom code that is:
• Written in any JVM language
• Stored on the server
• Accessed by applications over
Bolt
• Executed on the server
22. Neo4j Browser Sync
Companion Cloud Service for Neo4j
Browser
• Synchronize scripts, settings, and graph-style
sheets
• Preserve client-side work
across connections
• Personal cloud storage accessible from
anywhere
• Connect with existing online credentials
• Opt-in for registered users
24. Operation in the Cloud, Containers and On
Premises
New file, config and log structure to support
modern deployment scenarios
Improved database operations
• On-premises
• In virtualized and containerized
environments
• In the Cloud Neo4j
Neo4j
Application
Neo4j
25. Neo4j 3.0: A New Architecture Foundation
Neo4j
Neo4j
Application
Neo4j
New language driversNew binary protocol
New file, config and log structure
for tomorrow’s deployments
Native LanguageDrivers
BOLT
New storage engine with no limits
Enterprise Edition
30. Java Stored Procedures
User-defined procedures are written in Java,
deployed into the database, and called from Cypher.
http://neo4j.com/docs/developer-manual/current/#procedures
47. Cypher
• New cost-based optimizer for writes
• Faster index population via parallel
indexing
• Always-on Bolt connection speeds
high volumes of small queries
Cypher Engine
Parser
Rule-based
optimizer
Cost-based optimizer
Cypher Runtime
Many other improvements including:
• More index-based string queries: ENDS WITH and CONTAINS
• Global aggregation improvements (e.g. counting nodes by label)
• Value joins to speed queries where no relationship link exists
48. Cypher – COST Planner for Writes
cypher planner=rule
MATCH (p:Product),(c:Category)
WHERE p.category_id = c.id
CREATE (c)-[:CONTAINS]->(p);
Cypher version: CYPHER 3.0, planner:
RULE. 3060001 total db hits in 7197 ms.
49. Cypher – COST Planner for Writes
cypher planner=cost
MATCH (p:Product),(c:Category)
WHERE p.category_id = c.id
CREATE (c)-[:CONTAINS]->(p);
Cypher version: CYPHER 3.0, planner:
COST. 50003 total db hits in 3280 ms.
50. Predicates for shortestPath
MATCH (a:Loc {name:”Berlin"}),
(b:Loc {name:"Dresden"})
MATCH trip = shortestPath((a)-[roads:ROAD*]->(b))
WHERE NONE(r in roads WHERE r.closed or r.speed < 30)
AND ( reduce(s=0, r in roads | s + r.distance) < 300
OR length(trip) < 50 )
RETURN trip;
51. Spatial Functions
LOAD CSV WITH HEADERS FROM {URL} AS row FIELDTERMINATOR "t"
CREATE (:City {name:row.name, pop:toInt(row.einwohner),
longitude:toFloat(row.lon), latitude:toFloat(row.lat)});
MATCH (a:City {name:"Berlin"}),(b:City {name:"Dresden"})
RETURN a.name, b.name, toInt(distance(point(a),point(b)) / 1000)
as distance;
+---------------------------------+
| a.name | b.name | distance |
+---------------------------------+
| "Berlin" | "Dresden" | 165 |
+---------------------------------+
http://gist.asciidoctor.org/?dropbox-14493611%2Fcypher_spatial.adoc