SlideShare a Scribd company logo
1 of 28
Download to read offline
Cypher for Gremlin
oCIM 4
Apache TinkerPop
Apache TinkerPop™ is a graph computing
framework for both graph databases (OLTP)
and graph analytic systems (OLAP).
Gremlin is a graph traversal language
developed by Apache TinkerPop.
Gremlin in the wild
Gremlin in the wild
IBM Graph
Gremlin in the wild
IBM Graph
Gremlin in the wild
IBM Graph
Azure Cosmos DB
Gremlin in the wild
IBM Graph
Azure Cosmos DB
Amazon Neptune
Gremlin language
gremlin> g.V().count()
==>0
gremlin> g.addV('City').property('name', 'København')
gremlin> g.V().count()
==>1
gremlin> g.V().hasLabel('City').values('name')
==>København
Declarative vs imperative querying
// Cypher: what to get
MATCH (b:Boat)-[:SAILS_TO]->(:Location {name: 'Denmark'})
RETURN b
// Gremlin: how to get it
g.V().hasLabel('Boat').as('b')
.out('SAILS_TO')
.hasLabel('Location').has('name', 'Denmark')
.select('b')
Gremlin traversal
g.V().hasLabel('Boat').as('b')
.out('SAILS_TO')
.hasLabel('Location').has('name', 'Denmark')
.select('b')
.profile()
Step Count
TinkerGraphStep(vertex,[~label.eq(Boat)])@[b] 100000
VertexStep(OUT,[SAILS_TO],vertex) 100000
HasStep([~label.eq(Location), name.eq(Denmark)]) 1
SelectOneStep(last,b) 1
Gremlin traversal (the right way)
g.V().hasLabel('Location').has('name', 'Denmark')
.in('SAILS_TO')
.hasLabel('Boat')
.profile()
Step Count
TinkerGraphStep(vertex,[~label.eq(Location), name.eq(Denmark)]) 1
VertexStep(IN,[SAILS_TO],vertex) 1
HasStep([~label.eq(Boat)]) 1
Cypher in Gremlin
// MATCH (b:Boat)-[:SAILS_TO]->(:Location {name: 'Denmark'})
// RETURN b.name
g.V().hasLabel('Boat').as('b')
.out('SAILS_TO')
.hasLabel('Location').has('name', 'Denmark')
.select('b').values('name')
==>"Havhingsten fra Glendalough"
==>"Roar Ege"
Cypher in Gremlin: return columns
// MATCH (b:Boat)-[:SAILS_TO]->(:Location {name: 'Denmark'})
// RETURN b.name
g.V().hasLabel('Boat').as('b')
.out('SAILS_TO')
.hasLabel('Location').has('name', 'Denmark')
.select('b').project('b.name').by(values('name'))
==>{"b.name": "Havhingsten fra Glendalough"}
==>{"b.name": "Roar Ege"}
Null handling in Gremlin
gremlin> g.addV('Boat').property('name', 'Roar Ege')
==>v[0]
gremlin> g.addV('Boat')
==>v[1]
gremlin> g.V().count()
==>2
gremlin> g.V().hasLabel('Boat').values('name')
==>Roar Ege
gremlin> g.V().hasLabel('Boat').project('name').by(values('name'))
==>[name:Roar Ege]
The provided traverser does not map to a value:
v[5]->[PropertiesStep([name],value)]
Cypher in Gremlin: nulls
// MATCH (b:Boat)-[:SAILS_TO]->(:Location {name: 'Denmark'})
// RETURN b.name
g.V().hasLabel('Boat').as('b')
.out('SAILS_TO')
.hasLabel('Location').has('name', 'Denmark')
.select('b').project('b.name').by(
choose(neq('NULL'),
coalesce(values('name'), constant('NULL')),
constant('NULL')))
Cypher in Gremlin: traversal-based logic
// RETURN $a AND $b
g.inject('START').project('$a AND $b').by(
choose(
and(constant(a).is(eq(true)), constant(b).is(eq(true))),
constant(true),
choose(
or(constant(a).is(eq(false)), constant(b).is(eq(false))),
constant(false),
constant('NULL'))))
Translation flow
82.5%
731 scenarios
(with Server plugin)
Cypher TCK progress
● Functionality exclusive to Gremlin Servers with Cypher plugin:
○ List access by non-constant index
○ Map access
○ Non-numeric plus operator
○ Path comprehensions
○ Functions with non-native implementation: length, nodes, percentileCont, percentileDisc, properties,
relationships, size, toBoolean, toFloat, toInteger, toString
● Multiple labels and label modification are not supported
○ TinkerPop graph elements have a single, immutable string label
○ No plans for a workaround
Major limitations
Cypher for Gremlin integration
Gremlin Server
without Cypher plugin
Gremlin Server
with Cypher plugin
Gremlin driver ❌ ✔ server-side translation
Cypher Gremlin client
for Java
✔ client-side translation ✔ server-side translation
Gremlin Console ❌ ❌
Gremlin Console
with Cypher plugin
✔ client-side translation ✔ server-side translation
It’s on GitHub!
https://github.com/opencypher/cypher-for-gremlin
● Cypher to Gremlin translation library for Java
● Cypher plugin for Gremlin Server
● Cypher plugin for Gremlin Console
● Cypher wrapper for Gremlin client
● Neo4j driver API wrapper
● TCK implementation for Gremlin
It’s on GitHub!
https://github.com/opencypher/cypher-for-gremlin
Java APIs: translation
String cypher = "MATCH (p:Person) WHERE p.age > 25 RETURN p.name";
CypherAstWrapper ast = CypherAstWrapper.parse(cypher);
Translator<String, GroovyPredicate> translator =
Translator.builder().gremlinGroovy().build();
String gremlin = ast.buildTranslation(translator);
Java APIs: Gremlin Server client
Cluster cluster = Cluster.open(configuration);
Client gremlinClient = cluster.connect();
CypherGremlinClient cypherGremlinClient =
CypherGremlinClient.translating(gremlinClient);
String cypher = "MATCH (p:person) WHERE p.age > 25 RETURN p.name";
CypherResultSet resultSet = cypherGremlinClient.submit(cypher);
List<Map<String, Object>> results = resultSet.all();
Java APIs: Neo4j driver
Config config = Config.build()
.withTranslation()
.toConfig();
Driver driver = GremlinDatabase.driver("//localhost:8182", config);
String cypher = "MATCH (p:person) WHERE p.age > 25 RETURN p.name";
try (Session session = driver.session()) {
StatementResult result = session.run(cypher);
List<Record> records = result.list();
}
Java APIs: In-memory graphs
TinkerGraph graph = TinkerFactory.createModern();
GraphTraversalSource traversal = graph.traversal();
// Gremlin Server client
CypherGremlinClient cypherGremlinClient =
CypherGremlinClient.inMemory(traversal);
// Neo4j driver
Driver driver = GremlinDatabase.driver(traversal);
Java APIs: In-memory graphs
// SimpleGraph Excel
ExcelSystem excelSystem = new ExcelSystem();
excelSystem.connect();
excelSystem.moveTo(new File("graph.xlsx").toURI().toString());
GraphTraversalSource traversal = excelSystem.g();
CypherGremlinClient cypherGremlinClient =
CypherGremlinClient.inMemory(traversal);
Quick start
// Add dependencies
compile "org.apache.tinkerpop:tinkergraph-gremlin:3.3.2"
compile "org.opencypher.gremlin:cypher-gremlin-neo4j-driver:0.9.6"
// Create an in-memory graph
TinkerGraph graph = TinkerFactory.createModern();
GraphTraversalSource traversal = graph.traversal();
Driver driver = GremlinDatabase.driver(traversal);
// Query as usual: driver.session()... etc
// (Except transactions)

More Related Content

What's hot

Build a RESTful API with the Serverless Framework
Build a RESTful API with the Serverless FrameworkBuild a RESTful API with the Serverless Framework
Build a RESTful API with the Serverless Frameworkmasahitojp
 
Stuff we noticed while building "Asterisk in the cloud"
Stuff we noticed while building "Asterisk in the cloud"Stuff we noticed while building "Asterisk in the cloud"
Stuff we noticed while building "Asterisk in the cloud"troyd
 
Command line arguments that make you smile
Command line arguments that make you smileCommand line arguments that make you smile
Command line arguments that make you smileMartin Melin
 
Solving Nonograms In Parallel
Solving Nonograms In ParallelSolving Nonograms In Parallel
Solving Nonograms In Parallel家郡 葉
 
from ai.backend import python @ pycontw2018
from ai.backend import python @ pycontw2018from ai.backend import python @ pycontw2018
from ai.backend import python @ pycontw2018Chun-Yu Tseng
 
Easily reduce runtimes with cython
Easily reduce runtimes with cythonEasily reduce runtimes with cython
Easily reduce runtimes with cythonMichal Mucha
 
Debugging Your PHP Cake Application
Debugging Your PHP Cake ApplicationDebugging Your PHP Cake Application
Debugging Your PHP Cake ApplicationJose Diaz-Gonzalez
 
iOS App Development with F# and Xamarin
iOS App Development with F# and XamariniOS App Development with F# and Xamarin
iOS App Development with F# and XamarinRachel Reese
 
[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...
[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...
[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...Jerry Chou
 
Large-Scale Training with GPUs at Facebook
Large-Scale Training with GPUs at FacebookLarge-Scale Training with GPUs at Facebook
Large-Scale Training with GPUs at FacebookFaisal Siddiqi
 
Running Flink in Production: The good, The bad and The in Between - Lakshmi ...
Running Flink in Production:  The good, The bad and The in Between - Lakshmi ...Running Flink in Production:  The good, The bad and The in Between - Lakshmi ...
Running Flink in Production: The good, The bad and The in Between - Lakshmi ...Flink Forward
 
Integrating R with C++: Rcpp, RInside and RProtoBuf
Integrating R with C++: Rcpp, RInside and RProtoBufIntegrating R with C++: Rcpp, RInside and RProtoBuf
Integrating R with C++: Rcpp, RInside and RProtoBufRomain Francois
 
JavaScriptCore's DFG JIT (JSConf EU 2012)
JavaScriptCore's DFG JIT (JSConf EU 2012)JavaScriptCore's DFG JIT (JSConf EU 2012)
JavaScriptCore's DFG JIT (JSConf EU 2012)Igalia
 
走向开源:提交CPAN模块Step by Step
走向开源:提交CPAN模块Step by Step走向开源:提交CPAN模块Step by Step
走向开源:提交CPAN模块Step by Steppluschen
 
Python 4 Arc
Python 4 ArcPython 4 Arc
Python 4 Arcabsvis
 
IBM Cloud University: Java, Node.js and Swift
IBM Cloud University: Java, Node.js and SwiftIBM Cloud University: Java, Node.js and Swift
IBM Cloud University: Java, Node.js and SwiftChris Bailey
 
The state of PyPy
The state of PyPyThe state of PyPy
The state of PyPym_r_e
 
InspiringCon14: ElePHPants on speed: Running TYPO3 Flow on HipHop VM
InspiringCon14: ElePHPants on speed: Running TYPO3 Flow on HipHop VMInspiringCon14: ElePHPants on speed: Running TYPO3 Flow on HipHop VM
InspiringCon14: ElePHPants on speed: Running TYPO3 Flow on HipHop VMmhelmich
 

What's hot (20)

Build a RESTful API with the Serverless Framework
Build a RESTful API with the Serverless FrameworkBuild a RESTful API with the Serverless Framework
Build a RESTful API with the Serverless Framework
 
Stuff we noticed while building "Asterisk in the cloud"
Stuff we noticed while building "Asterisk in the cloud"Stuff we noticed while building "Asterisk in the cloud"
Stuff we noticed while building "Asterisk in the cloud"
 
Command line arguments that make you smile
Command line arguments that make you smileCommand line arguments that make you smile
Command line arguments that make you smile
 
Rcpp
RcppRcpp
Rcpp
 
Solving Nonograms In Parallel
Solving Nonograms In ParallelSolving Nonograms In Parallel
Solving Nonograms In Parallel
 
from ai.backend import python @ pycontw2018
from ai.backend import python @ pycontw2018from ai.backend import python @ pycontw2018
from ai.backend import python @ pycontw2018
 
Easily reduce runtimes with cython
Easily reduce runtimes with cythonEasily reduce runtimes with cython
Easily reduce runtimes with cython
 
Debugging Your PHP Cake Application
Debugging Your PHP Cake ApplicationDebugging Your PHP Cake Application
Debugging Your PHP Cake Application
 
iOS App Development with F# and Xamarin
iOS App Development with F# and XamariniOS App Development with F# and Xamarin
iOS App Development with F# and Xamarin
 
[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...
[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...
[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...
 
Large-Scale Training with GPUs at Facebook
Large-Scale Training with GPUs at FacebookLarge-Scale Training with GPUs at Facebook
Large-Scale Training with GPUs at Facebook
 
Running Flink in Production: The good, The bad and The in Between - Lakshmi ...
Running Flink in Production:  The good, The bad and The in Between - Lakshmi ...Running Flink in Production:  The good, The bad and The in Between - Lakshmi ...
Running Flink in Production: The good, The bad and The in Between - Lakshmi ...
 
Integrating R with C++: Rcpp, RInside and RProtoBuf
Integrating R with C++: Rcpp, RInside and RProtoBufIntegrating R with C++: Rcpp, RInside and RProtoBuf
Integrating R with C++: Rcpp, RInside and RProtoBuf
 
JavaScriptCore's DFG JIT (JSConf EU 2012)
JavaScriptCore's DFG JIT (JSConf EU 2012)JavaScriptCore's DFG JIT (JSConf EU 2012)
JavaScriptCore's DFG JIT (JSConf EU 2012)
 
Presentation tim numann
Presentation tim numannPresentation tim numann
Presentation tim numann
 
走向开源:提交CPAN模块Step by Step
走向开源:提交CPAN模块Step by Step走向开源:提交CPAN模块Step by Step
走向开源:提交CPAN模块Step by Step
 
Python 4 Arc
Python 4 ArcPython 4 Arc
Python 4 Arc
 
IBM Cloud University: Java, Node.js and Swift
IBM Cloud University: Java, Node.js and SwiftIBM Cloud University: Java, Node.js and Swift
IBM Cloud University: Java, Node.js and Swift
 
The state of PyPy
The state of PyPyThe state of PyPy
The state of PyPy
 
InspiringCon14: ElePHPants on speed: Running TYPO3 Flow on HipHop VM
InspiringCon14: ElePHPants on speed: Running TYPO3 Flow on HipHop VMInspiringCon14: ElePHPants on speed: Running TYPO3 Flow on HipHop VM
InspiringCon14: ElePHPants on speed: Running TYPO3 Flow on HipHop VM
 

Similar to Cypher for Gremlin: Translate Cypher queries to Gremlin traversals

Cypher for Gremlin
Cypher for GremlinCypher for Gremlin
Cypher for GremlinopenCypher
 
Build microservice with gRPC in golang
Build microservice with gRPC in golangBuild microservice with gRPC in golang
Build microservice with gRPC in golangTing-Li Chou
 
Gearman work queue in php
Gearman work queue in phpGearman work queue in php
Gearman work queue in phpBo-Yi Wu
 
HPEC 2021 grblas
HPEC 2021 grblasHPEC 2021 grblas
HPEC 2021 grblasErikWelch2
 
不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)Douglas Chen
 
SETCON'18 - Ilya labacheuski - GraphQL adventures
SETCON'18 - Ilya labacheuski - GraphQL adventuresSETCON'18 - Ilya labacheuski - GraphQL adventures
SETCON'18 - Ilya labacheuski - GraphQL adventuresNadzeya Pus
 
GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28Jorge Hidalgo
 
Cloud Native Data Pipelines (in Eng & Japanese) - QCon Tokyo
Cloud Native Data Pipelines (in Eng & Japanese)  - QCon TokyoCloud Native Data Pipelines (in Eng & Japanese)  - QCon Tokyo
Cloud Native Data Pipelines (in Eng & Japanese) - QCon TokyoSid Anand
 
Graal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerGraal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerKoichi Sakata
 
GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18Jorge Hidalgo
 
SC13: OpenMP and NVIDIA
SC13: OpenMP and NVIDIASC13: OpenMP and NVIDIA
SC13: OpenMP and NVIDIAJeff Larkin
 
2015-GopherCon-Talk-Uptime.pdf
2015-GopherCon-Talk-Uptime.pdf2015-GopherCon-Talk-Uptime.pdf
2015-GopherCon-Talk-Uptime.pdfUtabeUtabe
 
Integrating microservices with apache camel on kubernetes
Integrating microservices with apache camel on kubernetesIntegrating microservices with apache camel on kubernetes
Integrating microservices with apache camel on kubernetesClaus Ibsen
 
GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22Jorge Hidalgo
 
Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018Petr Zapletal
 
Writing Rust Command Line Applications
Writing Rust Command Line ApplicationsWriting Rust Command Line Applications
Writing Rust Command Line ApplicationsAll Things Open
 
Security testing with gauntlt
Security testing with gauntltSecurity testing with gauntlt
Security testing with gauntltJames Wickett
 
CommunityOneEast 09 - Dynamic Languages: the next big thing for the JVM or an...
CommunityOneEast 09 - Dynamic Languages: the next big thing for the JVM or an...CommunityOneEast 09 - Dynamic Languages: the next big thing for the JVM or an...
CommunityOneEast 09 - Dynamic Languages: the next big thing for the JVM or an...Chris Richardson
 
Two C++ Tools: Compiler Explorer and Cpp Insights
Two C++ Tools: Compiler Explorer and Cpp InsightsTwo C++ Tools: Compiler Explorer and Cpp Insights
Two C++ Tools: Compiler Explorer and Cpp InsightsAlison Chaiken
 

Similar to Cypher for Gremlin: Translate Cypher queries to Gremlin traversals (20)

Cypher for Gremlin
Cypher for GremlinCypher for Gremlin
Cypher for Gremlin
 
Build microservice with gRPC in golang
Build microservice with gRPC in golangBuild microservice with gRPC in golang
Build microservice with gRPC in golang
 
Gearman work queue in php
Gearman work queue in phpGearman work queue in php
Gearman work queue in php
 
HPEC 2021 grblas
HPEC 2021 grblasHPEC 2021 grblas
HPEC 2021 grblas
 
不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)
 
Helm intro
Helm introHelm intro
Helm intro
 
SETCON'18 - Ilya labacheuski - GraphQL adventures
SETCON'18 - Ilya labacheuski - GraphQL adventuresSETCON'18 - Ilya labacheuski - GraphQL adventures
SETCON'18 - Ilya labacheuski - GraphQL adventures
 
GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28
 
Cloud Native Data Pipelines (in Eng & Japanese) - QCon Tokyo
Cloud Native Data Pipelines (in Eng & Japanese)  - QCon TokyoCloud Native Data Pipelines (in Eng & Japanese)  - QCon Tokyo
Cloud Native Data Pipelines (in Eng & Japanese) - QCon Tokyo
 
Graal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerGraal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT Compiler
 
GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18
 
SC13: OpenMP and NVIDIA
SC13: OpenMP and NVIDIASC13: OpenMP and NVIDIA
SC13: OpenMP and NVIDIA
 
2015-GopherCon-Talk-Uptime.pdf
2015-GopherCon-Talk-Uptime.pdf2015-GopherCon-Talk-Uptime.pdf
2015-GopherCon-Talk-Uptime.pdf
 
Integrating microservices with apache camel on kubernetes
Integrating microservices with apache camel on kubernetesIntegrating microservices with apache camel on kubernetes
Integrating microservices with apache camel on kubernetes
 
GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22
 
Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018
 
Writing Rust Command Line Applications
Writing Rust Command Line ApplicationsWriting Rust Command Line Applications
Writing Rust Command Line Applications
 
Security testing with gauntlt
Security testing with gauntltSecurity testing with gauntlt
Security testing with gauntlt
 
CommunityOneEast 09 - Dynamic Languages: the next big thing for the JVM or an...
CommunityOneEast 09 - Dynamic Languages: the next big thing for the JVM or an...CommunityOneEast 09 - Dynamic Languages: the next big thing for the JVM or an...
CommunityOneEast 09 - Dynamic Languages: the next big thing for the JVM or an...
 
Two C++ Tools: Compiler Explorer and Cpp Insights
Two C++ Tools: Compiler Explorer and Cpp InsightsTwo C++ Tools: Compiler Explorer and Cpp Insights
Two C++ Tools: Compiler Explorer and Cpp Insights
 

More from openCypher

Learning Timed Automata with Cypher
Learning Timed Automata with CypherLearning Timed Automata with Cypher
Learning Timed Automata with CypheropenCypher
 
Incremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher QueriesIncremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher QueriesopenCypher
 
Formal semantics for Cypher queries and updates
Formal semantics for Cypher queries and updatesFormal semantics for Cypher queries and updates
Formal semantics for Cypher queries and updatesopenCypher
 
Cypher.PL: an executable specification of Cypher semantics
Cypher.PL: an executable specification of Cypher semanticsCypher.PL: an executable specification of Cypher semantics
Cypher.PL: an executable specification of Cypher semanticsopenCypher
 
Multiple Graphs: Updatable Views
Multiple Graphs: Updatable ViewsMultiple Graphs: Updatable Views
Multiple Graphs: Updatable ViewsopenCypher
 
Micro-Servicing Linked Data
Micro-Servicing Linked DataMicro-Servicing Linked Data
Micro-Servicing Linked DataopenCypher
 
Graph abstraction
Graph abstractionGraph abstraction
Graph abstractionopenCypher
 
From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...
From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...
From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...openCypher
 
Comparing PGQL, G-Core and Cypher
Comparing PGQL, G-Core and CypherComparing PGQL, G-Core and Cypher
Comparing PGQL, G-Core and CypheropenCypher
 
Multiple graphs in openCypher
Multiple graphs in openCypherMultiple graphs in openCypher
Multiple graphs in openCypheropenCypher
 
Eighth openCypher Implementers Group Meeting: Status Update
Eighth openCypher Implementers Group Meeting: Status UpdateEighth openCypher Implementers Group Meeting: Status Update
Eighth openCypher Implementers Group Meeting: Status UpdateopenCypher
 
Supporting dates and times in Cypher
Supporting dates and times in CypherSupporting dates and times in Cypher
Supporting dates and times in CypheropenCypher
 
Seventh openCypher Implementers Group Meeting: Status Update
Seventh openCypher Implementers Group Meeting: Status UpdateSeventh openCypher Implementers Group Meeting: Status Update
Seventh openCypher Implementers Group Meeting: Status UpdateopenCypher
 
Academic research on graph processing: connecting recent findings to industri...
Academic research on graph processing: connecting recent findings to industri...Academic research on graph processing: connecting recent findings to industri...
Academic research on graph processing: connecting recent findings to industri...openCypher
 
Property Graphs with Time
Property Graphs with TimeProperty Graphs with Time
Property Graphs with TimeopenCypher
 
Cypher.PL: Executable Specification of Cypher written in Prolog
Cypher.PL: Executable Specification of Cypher written in PrologCypher.PL: Executable Specification of Cypher written in Prolog
Cypher.PL: Executable Specification of Cypher written in PrologopenCypher
 
Use case: processing multiple graphs
Use case: processing multiple graphsUse case: processing multiple graphs
Use case: processing multiple graphsopenCypher
 
openCypher Technology Compatibility Kit (TCK)
openCypher Technology Compatibility Kit (TCK)openCypher Technology Compatibility Kit (TCK)
openCypher Technology Compatibility Kit (TCK)openCypher
 
Cypher Editor in the Web
Cypher Editor in the WebCypher Editor in the Web
Cypher Editor in the WebopenCypher
 
The inGraph project and incremental evaluation of Cypher queries
The inGraph project and incremental evaluation of Cypher queriesThe inGraph project and incremental evaluation of Cypher queries
The inGraph project and incremental evaluation of Cypher queriesopenCypher
 

More from openCypher (20)

Learning Timed Automata with Cypher
Learning Timed Automata with CypherLearning Timed Automata with Cypher
Learning Timed Automata with Cypher
 
Incremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher QueriesIncremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher Queries
 
Formal semantics for Cypher queries and updates
Formal semantics for Cypher queries and updatesFormal semantics for Cypher queries and updates
Formal semantics for Cypher queries and updates
 
Cypher.PL: an executable specification of Cypher semantics
Cypher.PL: an executable specification of Cypher semanticsCypher.PL: an executable specification of Cypher semantics
Cypher.PL: an executable specification of Cypher semantics
 
Multiple Graphs: Updatable Views
Multiple Graphs: Updatable ViewsMultiple Graphs: Updatable Views
Multiple Graphs: Updatable Views
 
Micro-Servicing Linked Data
Micro-Servicing Linked DataMicro-Servicing Linked Data
Micro-Servicing Linked Data
 
Graph abstraction
Graph abstractionGraph abstraction
Graph abstraction
 
From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...
From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...
From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...
 
Comparing PGQL, G-Core and Cypher
Comparing PGQL, G-Core and CypherComparing PGQL, G-Core and Cypher
Comparing PGQL, G-Core and Cypher
 
Multiple graphs in openCypher
Multiple graphs in openCypherMultiple graphs in openCypher
Multiple graphs in openCypher
 
Eighth openCypher Implementers Group Meeting: Status Update
Eighth openCypher Implementers Group Meeting: Status UpdateEighth openCypher Implementers Group Meeting: Status Update
Eighth openCypher Implementers Group Meeting: Status Update
 
Supporting dates and times in Cypher
Supporting dates and times in CypherSupporting dates and times in Cypher
Supporting dates and times in Cypher
 
Seventh openCypher Implementers Group Meeting: Status Update
Seventh openCypher Implementers Group Meeting: Status UpdateSeventh openCypher Implementers Group Meeting: Status Update
Seventh openCypher Implementers Group Meeting: Status Update
 
Academic research on graph processing: connecting recent findings to industri...
Academic research on graph processing: connecting recent findings to industri...Academic research on graph processing: connecting recent findings to industri...
Academic research on graph processing: connecting recent findings to industri...
 
Property Graphs with Time
Property Graphs with TimeProperty Graphs with Time
Property Graphs with Time
 
Cypher.PL: Executable Specification of Cypher written in Prolog
Cypher.PL: Executable Specification of Cypher written in PrologCypher.PL: Executable Specification of Cypher written in Prolog
Cypher.PL: Executable Specification of Cypher written in Prolog
 
Use case: processing multiple graphs
Use case: processing multiple graphsUse case: processing multiple graphs
Use case: processing multiple graphs
 
openCypher Technology Compatibility Kit (TCK)
openCypher Technology Compatibility Kit (TCK)openCypher Technology Compatibility Kit (TCK)
openCypher Technology Compatibility Kit (TCK)
 
Cypher Editor in the Web
Cypher Editor in the WebCypher Editor in the Web
Cypher Editor in the Web
 
The inGraph project and incremental evaluation of Cypher queries
The inGraph project and incremental evaluation of Cypher queriesThe inGraph project and incremental evaluation of Cypher queries
The inGraph project and incremental evaluation of Cypher queries
 

Recently uploaded

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 

Recently uploaded (20)

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 

Cypher for Gremlin: Translate Cypher queries to Gremlin traversals

  • 2. Apache TinkerPop Apache TinkerPop™ is a graph computing framework for both graph databases (OLTP) and graph analytic systems (OLAP). Gremlin is a graph traversal language developed by Apache TinkerPop.
  • 4. Gremlin in the wild IBM Graph
  • 5. Gremlin in the wild IBM Graph
  • 6. Gremlin in the wild IBM Graph Azure Cosmos DB
  • 7. Gremlin in the wild IBM Graph Azure Cosmos DB Amazon Neptune
  • 8. Gremlin language gremlin> g.V().count() ==>0 gremlin> g.addV('City').property('name', 'København') gremlin> g.V().count() ==>1 gremlin> g.V().hasLabel('City').values('name') ==>København
  • 9. Declarative vs imperative querying // Cypher: what to get MATCH (b:Boat)-[:SAILS_TO]->(:Location {name: 'Denmark'}) RETURN b // Gremlin: how to get it g.V().hasLabel('Boat').as('b') .out('SAILS_TO') .hasLabel('Location').has('name', 'Denmark') .select('b')
  • 10. Gremlin traversal g.V().hasLabel('Boat').as('b') .out('SAILS_TO') .hasLabel('Location').has('name', 'Denmark') .select('b') .profile() Step Count TinkerGraphStep(vertex,[~label.eq(Boat)])@[b] 100000 VertexStep(OUT,[SAILS_TO],vertex) 100000 HasStep([~label.eq(Location), name.eq(Denmark)]) 1 SelectOneStep(last,b) 1
  • 11. Gremlin traversal (the right way) g.V().hasLabel('Location').has('name', 'Denmark') .in('SAILS_TO') .hasLabel('Boat') .profile() Step Count TinkerGraphStep(vertex,[~label.eq(Location), name.eq(Denmark)]) 1 VertexStep(IN,[SAILS_TO],vertex) 1 HasStep([~label.eq(Boat)]) 1
  • 12. Cypher in Gremlin // MATCH (b:Boat)-[:SAILS_TO]->(:Location {name: 'Denmark'}) // RETURN b.name g.V().hasLabel('Boat').as('b') .out('SAILS_TO') .hasLabel('Location').has('name', 'Denmark') .select('b').values('name') ==>"Havhingsten fra Glendalough" ==>"Roar Ege"
  • 13. Cypher in Gremlin: return columns // MATCH (b:Boat)-[:SAILS_TO]->(:Location {name: 'Denmark'}) // RETURN b.name g.V().hasLabel('Boat').as('b') .out('SAILS_TO') .hasLabel('Location').has('name', 'Denmark') .select('b').project('b.name').by(values('name')) ==>{"b.name": "Havhingsten fra Glendalough"} ==>{"b.name": "Roar Ege"}
  • 14. Null handling in Gremlin gremlin> g.addV('Boat').property('name', 'Roar Ege') ==>v[0] gremlin> g.addV('Boat') ==>v[1] gremlin> g.V().count() ==>2 gremlin> g.V().hasLabel('Boat').values('name') ==>Roar Ege gremlin> g.V().hasLabel('Boat').project('name').by(values('name')) ==>[name:Roar Ege] The provided traverser does not map to a value: v[5]->[PropertiesStep([name],value)]
  • 15. Cypher in Gremlin: nulls // MATCH (b:Boat)-[:SAILS_TO]->(:Location {name: 'Denmark'}) // RETURN b.name g.V().hasLabel('Boat').as('b') .out('SAILS_TO') .hasLabel('Location').has('name', 'Denmark') .select('b').project('b.name').by( choose(neq('NULL'), coalesce(values('name'), constant('NULL')), constant('NULL')))
  • 16. Cypher in Gremlin: traversal-based logic // RETURN $a AND $b g.inject('START').project('$a AND $b').by( choose( and(constant(a).is(eq(true)), constant(b).is(eq(true))), constant(true), choose( or(constant(a).is(eq(false)), constant(b).is(eq(false))), constant(false), constant('NULL'))))
  • 18. 82.5% 731 scenarios (with Server plugin) Cypher TCK progress
  • 19. ● Functionality exclusive to Gremlin Servers with Cypher plugin: ○ List access by non-constant index ○ Map access ○ Non-numeric plus operator ○ Path comprehensions ○ Functions with non-native implementation: length, nodes, percentileCont, percentileDisc, properties, relationships, size, toBoolean, toFloat, toInteger, toString ● Multiple labels and label modification are not supported ○ TinkerPop graph elements have a single, immutable string label ○ No plans for a workaround Major limitations
  • 20. Cypher for Gremlin integration Gremlin Server without Cypher plugin Gremlin Server with Cypher plugin Gremlin driver ❌ ✔ server-side translation Cypher Gremlin client for Java ✔ client-side translation ✔ server-side translation Gremlin Console ❌ ❌ Gremlin Console with Cypher plugin ✔ client-side translation ✔ server-side translation
  • 22. ● Cypher to Gremlin translation library for Java ● Cypher plugin for Gremlin Server ● Cypher plugin for Gremlin Console ● Cypher wrapper for Gremlin client ● Neo4j driver API wrapper ● TCK implementation for Gremlin It’s on GitHub! https://github.com/opencypher/cypher-for-gremlin
  • 23. Java APIs: translation String cypher = "MATCH (p:Person) WHERE p.age > 25 RETURN p.name"; CypherAstWrapper ast = CypherAstWrapper.parse(cypher); Translator<String, GroovyPredicate> translator = Translator.builder().gremlinGroovy().build(); String gremlin = ast.buildTranslation(translator);
  • 24. Java APIs: Gremlin Server client Cluster cluster = Cluster.open(configuration); Client gremlinClient = cluster.connect(); CypherGremlinClient cypherGremlinClient = CypherGremlinClient.translating(gremlinClient); String cypher = "MATCH (p:person) WHERE p.age > 25 RETURN p.name"; CypherResultSet resultSet = cypherGremlinClient.submit(cypher); List<Map<String, Object>> results = resultSet.all();
  • 25. Java APIs: Neo4j driver Config config = Config.build() .withTranslation() .toConfig(); Driver driver = GremlinDatabase.driver("//localhost:8182", config); String cypher = "MATCH (p:person) WHERE p.age > 25 RETURN p.name"; try (Session session = driver.session()) { StatementResult result = session.run(cypher); List<Record> records = result.list(); }
  • 26. Java APIs: In-memory graphs TinkerGraph graph = TinkerFactory.createModern(); GraphTraversalSource traversal = graph.traversal(); // Gremlin Server client CypherGremlinClient cypherGremlinClient = CypherGremlinClient.inMemory(traversal); // Neo4j driver Driver driver = GremlinDatabase.driver(traversal);
  • 27. Java APIs: In-memory graphs // SimpleGraph Excel ExcelSystem excelSystem = new ExcelSystem(); excelSystem.connect(); excelSystem.moveTo(new File("graph.xlsx").toURI().toString()); GraphTraversalSource traversal = excelSystem.g(); CypherGremlinClient cypherGremlinClient = CypherGremlinClient.inMemory(traversal);
  • 28. Quick start // Add dependencies compile "org.apache.tinkerpop:tinkergraph-gremlin:3.3.2" compile "org.opencypher.gremlin:cypher-gremlin-neo4j-driver:0.9.6" // Create an in-memory graph TinkerGraph graph = TinkerFactory.createModern(); GraphTraversalSource traversal = graph.traversal(); Driver driver = GremlinDatabase.driver(traversal); // Query as usual: driver.session()... etc // (Except transactions)