Date post: | 20-May-2015 |
Category: |
Business |
Upload: | neo4j-the-fastest-and-most-scalable-native-graph-database |
View: | 999 times |
Download: | 2 times |
WebinarJune 25 2013
Walkthrough Neo4j 1.9.1 & 2.0Michael Hunger, Neo Technology
@mesirii
Overview
Overview• Neo4j 1.9.1
• High Availability & Operations
• Performance & Cypher
• Neo4j 2.0
• Extension Property Graph Model - Labels & Indexes
• Cypher
• Transactional Http Endpoint
Neo4j 1.9.1
High Availability & Operations• new HA cluster management implementation (paxos) w/o ZK
• ZK compatibility layer for rolling upgrades from 1.8
• faster consistency check with new implementation
• new HA JMX information -> JConsole
• Arbiter instance for clusters < 3
• Slave only mode
• new endpoint for load balancers /db/manage/server/ha/{master,slave}
Hands-On High Availability• Manual 1.8 vs. Manual 1.9
• Live
• 3 node cluster
• runs without zookeeper
• show that replication works
• show management endpoint and JMX
• show config
General• Java 7 support
• Store-Locks to limit access of Readonly-Instances
• Online backup enabled by default, works with port-range
• Performance
• caching & property access improvements
• REST-Batch-Operations speedup
Server• Traversal Javascript is sandboxed
• X-Forwarded-Host and X-Forwarded-Proto headers to support running behind a proxy
• SSL certificate chain support
• REST-batch-operations performance improvements
• Gremlin plugin as separate project
• to allow different versions and decouple from neo4j release cycle
Cypher• upgrade to scala 2.10
• concurrent parsing
• execution plan description
• fix non-lazyness
• faster pattern matcher (bi-directional traversal)
• top-n select for order by limit
Cypher
• predicates as expressions
• Functions: reduce, string functions
• order by, skip, limit with WITH
• automatic conversion
• SET can work with other nodes or maps
Hands-On Cypher
• profiling
• string functions, show reduce
• WITH with ORDER BY LIMIT
• SET with predicates, SET with other nodes
• FOREACH with CREATE UNIQUE
Why 2.0?
(0.x) --> (1.x) --> (2.x)
(0.x) --> (1.x) --> (2.x)
• 0.x was about embedded java
(0.x) --> (1.x) --> (2.x)
• 0.x was about embedded java
• 1.x introduced indexes, the server and REST
(0.x) --> (1.x) --> (2.x)
• 0.x was about embedded java
• 1.x introduced indexes, the server and REST
• 2.x ease of use, big data, cloud
(0.x) --> (1.x) --> (2.x)
• 0.x was about embedded java
• 1.x introduced indexes, the server and REST
• 2.x ease of use, big data, cloud
which means a focus on...
This guy
Focus on Cypher
Focus on Cypher
• Cypher, a carefully crafted language for working with graphs
Focus on Cypher
• Cypher, a carefully crafted language for working with graphs
• Declarative, friendly, easy to read and write
Focus on Cypher
• Cypher, a carefully crafted language for working with graphs
• Declarative, friendly, easy to read and write
• One language, used everywhere
Focus on Cypher
• Cypher, a carefully crafted language for working with graphs
• Declarative, friendly, easy to read and write
• One language, used everywhere
• REST for management, Java for extensions,
What is new in 2.0?
There will be some sad Danes
"Once you label me,you negate me.”
- Søren Kierkegaard
Introducing Node Labels
name: 'Soren'
• Simply: a label identifies a set of nodes
Introducing Node Labels
name: 'Soren'
• Simply: a label identifies a set of nodes
Introducing Node Labels
name: 'Soren'
Dane
• Simply: a label identifies a set of nodes
• Nodes can have multiple labels
Introducing Node Labels
name: 'Soren'
Dane
• Simply: a label identifies a set of nodes
• Nodes can have multiple labels
Introducing Node Labels
name: 'Soren'
Negated Dane
• Simply: a label identifies a set of nodes
• Nodes can have multiple labels
Introducing Node Labels
name: 'Soren'
Negated
name: 'Soren'img:
Dane
• Simply: a label identifies a set of nodes
• Nodes can have multiple labels
• Find nodes by label
Introducing Node Labels
name: 'Soren'
Negated
name: 'Soren'img:
Dane
• Simply: a label identifies a set of nodes
• Nodes can have multiple labels
• Find nodes by label
• Constrain properties and values
(lightweight, optional schema)
Introducing Node Labels
name: 'Soren'
Negated
name: 'Soren'img:
Dane
• Simply: a label identifies a set of nodes
• Nodes can have multiple labels
• Find nodes by label
• Constrain properties and values
(lightweight, optional schema)
• A simple idea, with powerful applications
Introducing Node Labels
name: 'Soren'
Negated
name: 'Soren'img:
Dane
Find friends who like cheese
MATCH (max:People)-[:FRIENDS]->(cheesy: People),
(cheesy)-[:LIKE]->(cheese:Things)
WHERE max.name = "Max De Marzi"
AND cheese.name = "Cheese"
RETURN cheesy;
Schema Indexing• Indexes for labels, based on a property
• Simple lookups for now
• Unique indexing coming soon
• Full-text, other special indexes in planning
CREATE INDEX ON :People(name)
MERGE operation• a combination of MATCH + CREATE
• replaces CREATE UNIQUE
• attempts to MATCH, with specified properties and labels
• if match fails, new graph data is created
• optional sub-clauses for handling ON CREATE, and ON MATCHMERGE (charlie { name:'Charlie Sheen', age:10 })ON CREATE charlie SET charlie.created = timestamp()RETURN charlie
Transactional Cypher
• begin, commit, or rollback a transaction
Transactional Cypher
• begin, commit, or rollback a transaction
• transaction as RESTful resource
Transactional Cypher
• begin, commit, or rollback a transaction
• transaction as RESTful resource
• issue multiple statements per request
Transactional Cypher
• begin, commit, or rollback a transaction
• transaction as RESTful resource
• issue multiple statements per request
• multiple requests per transaction
Transactional Cypher
• begin, commit, or rollback a transaction
• transaction as RESTful resource
• issue multiple statements per request
• multiple requests per transaction
• compact response format
Transactional Cypher
• begin, commit, or rollback a transaction
• transaction as RESTful resource
• issue multiple statements per request
• multiple requests per transaction
• compact response format
Transactional Cypher
Anything else?
Anything else?• Performance improvements
Anything else?• Performance improvements
• Breaking changes to some APIs (read CHANGES.txt)
Anything else?• Performance improvements
• Breaking changes to some APIs (read CHANGES.txt)
• Migration of "legacy" indexes (stop STARTing)
Anything else?• Performance improvements
• Breaking changes to some APIs (read CHANGES.txt)
• Migration of "legacy" indexes (stop STARTing)
• Mandatory transactions for all DB interactions
Anything else?• Performance improvements
• Breaking changes to some APIs (read CHANGES.txt)
• Migration of "legacy" indexes (stop STARTing)
• Mandatory transactions for all DB interactions
• Improving installers (in progress)
Anything else?• Performance improvements
• Breaking changes to some APIs (read CHANGES.txt)
• Migration of "legacy" indexes (stop STARTing)
• Mandatory transactions for all DB interactions
• Improving installers (in progress)
• Changing everything to be "all Cypher, all the time"
How to use labels?
Label - special nodes
• replace built-in reference node, with domain specific reference nodes
42
Label - special nodes
• replace built-in reference node, with domain specific reference nodes
42Answer
Labels - rules of thumb
Labels - rules of thumb• Use a label to make queries easier to read & write
Labels - rules of thumb• Use a label to make queries easier to read & write
• And to improve performance through indexing
Labels - rules of thumb• Use a label to make queries easier to read & write
• And to improve performance through indexing
Labels - rules of thumb• Use a label to make queries easier to read & write
• And to improve performance through indexing
• Start with anything you might've put in a legacy index
Labels - rules of thumb• Use a label to make queries easier to read & write
• And to improve performance through indexing
• Start with anything you might've put in a legacy index
• Use lightly, as few labels as needed
Hands-On Cypher
• Migrate Cineasts dataset to use Labels
• Show MATCH on Labels and Properties (+ profile)
• Add an Index on :Person(name) :Movie(title)
• Show MATCH on Labels and Properties (+ profile)
• Show MERGE
Hands-On 2.0• Show Transactional HTTP-Endpoint
• POST initial statements, look at result, check currently running tx in server-info
• POST another create statement to the tx
• POST a new read statement to a new tx that shows isolation
• DELETE second transaction
• POST to COMMIT resource
Is that it for 2.0?
Well, there is this...
Googlehttp://localhost:7474/
Neo4j
LoadTransactions
Neo4j2.0.0
Active Queries 12Master
/var/neo4j/webui.graphdb Active Queries 12
MATCH (n)-[:FRIEND]->(friends) WHERE n.name = 'Andreas'Create a blank node
CREATE (n);
Clear all
MATCH (n)-[r?]->(m)DELETE n,r,m;
ad-hoc query
Relate People
MATCH (from),(to) WHERE n.name = {from}AND to.name = {to}CREATE (from)-[:FRIEND]->(to);
Delia
Andreas
m
People
CREATE (n);
Andreas
Name
Metaphysical
Mood
Delia Excited
Friends by name
CREATE (n);
Andreas
From
Delia
To
Delia Tiberius
Mood survey
CREATE (n);
Andreas
Name
Metaphysical
Mood
Delia ExcitedMATCH (n) RETURN n
People Books ClassicsAuthors
CREATE (me:People {name:'Andreas'})
What is new in 2.0?
What is new in 2.0?
• It's all about Cypher, starting with
• Labels, the first significant change in over 12 years
• Mix in schema indexing
• Then transactional REST, new clauses, functions
• A fresh Web UI that is Cypher-focused
Thanks :)
MATCH (you)-[:HAVE]->(question)RETURN question.text
@neo4j or @mesirii to keep in touch