SlideShare a Scribd company logo
Cypher for Gremlin
oCIG 7
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 language
gremlin> g.V().count()
==>0
gremlin> g.addV('person').properties('name', 'Marko')
gremlin> g.V().count()
==>1
gremlin> g.V().hasLabel('person').values('name')
==>Marko
MATCH (p:Planet)-[orbit:ORBITS]->(:Star {name: 'Sun'})
WHERE orbit.au < 5
RETURN p AS planet;
g.V().as('p').outE('ORBITS').as('orbit').inV().as(' UNNAMED34')
.where(and(
select('p').hasLabel('Planet'),
select(' UNNAMED34').values('name').is(eq('Sun')),
select(' UNNAMED34').hasLabel('Star'),
select('orbit').values('au').is(lt(5))
))
.select('p').map(project('planet').by(identity()))
The gist
Clauses Other Patterns Functions
MATCH
RETURN
UNWIND
OPTIONAL MATCH
WITH
UNION
CREATE
MERGE
SET
DETACH DELETE
ON CREATE
ON MATCH
WHERE
ORDER BY
SKIP
LIMIT
DISTINCT
(n:L {k: ‘v’})
()-->()
()--()
()-[r:L {k: ‘v’}]-()
(n)-[r]-(m)
()-[]-()-[]-()
()-[*n]-()
[x IN … | …]
avg, collect, count,
max, min, sum
keys, labels, nodes,
relationships, size
type, exists,
type conversion,
string matching
It is not guaranteed, however, that all combinations of
the listed clauses, patterns, or functions will work.
You are welcome to report any issues with the
translation that you encounter.
Cypher → Gremlin translation
● Cypher to Gremlin translation library for Java
● Cypher for Gremlin Server (plugin)
● Cypher for Gremlin Console (plugin)
● Cypher wrapper for Gremlin client
● Neo4j driver-like API wrapper
● TCK implementation for Gremlin
Cypher for Gremlin open source
https://github.com/opencypher/cypher-for-gremlin
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
59%
523 scenarios
Cypher Technology Compatibility Kit
Query performance tests
● Setup:
○ “Movies” graph (171 nodes, 506 rels)
○ One benchmark = one query execution
○ Warmup: 1 iteration, 1 sec each
○ Measurement: 5 iterations, 1 sec each
● Targets:
○ Gremlin Server with TinkerGraph backend
and Cypher for Gremlin plugin
○ No-op with query translation only
● Hardware:
○ Intel Core i5-6200U CPU @ 2.30GHz
○ Linux 4.14.4-1-ARCH x86_64
○ JDK 1.8.0_144, VM 25.144-b01
○ JMH 1.17.4
Benchmark
TinkerGraph
avg ms/op
Translation
avg ms/op
allNodes 7.019 1.069
allPaths 7.208 1.495
byLabel 4.367 1.246
byLongPath 6.899 2.407
byMultiplePaths 306.611 3.442
byPath 3.902 1.923
byProperty 3.618 1.468
byUndirectedPath 5.037 2.113
byVariablePath 448.726 2.079
countWithPivot 3.917 1.790
groupByProperty 5.295 1.766
limit 3.261 1.229
orderBy 5.268 2.808
relationshipTypes 3.823 1.747
wherePropertyBetween 3.884 2.097
Java APIs: translation
/*
* 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
/*
* 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();
Neo4j, Gremlin
Server, and Cosmos
DB running
side-by-side

More Related Content

PDF
OPTIMIZING THE TICK STACK
PDF
The Monitoring Playground
PDF
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
PDF
R and C++
PDF
R and cpp
PDF
Scaling metrics
PDF
INFLUXQL & TICKSCRIPT
PDF
Advanced kapacitor
OPTIMIZING THE TICK STACK
The Monitoring Playground
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
R and C++
R and cpp
Scaling metrics
INFLUXQL & TICKSCRIPT
Advanced kapacitor

What's hot (20)

PDF
InfluxData Platform Future and Vision
PDF
Cypher for Gremlin
PDF
Write your own telegraf plugin
PDF
Improving Performance of a WebKit Port MIPS Platform (ELC 2014)
PDF
Performance testing of microservices in Action
PDF
Building a Serverless Computation Environment with Python
PPTX
Syslog-ng Performance
PPTX
Improving go-git performance
PPTX
Scaling with Python: SF Python Meetup, September 2017
PPTX
Enable IPv6 on Route53 AWS ELB, docker and node App
PDF
Boosting command line experience with python and awk
DOCX
Logistic Regression in R-An Exmple.
PDF
Raster Processing with Scipy.ndimage (Dev Meet Up II)
PDF
Manageable data pipelines with airflow (and kubernetes) november 27, 11 45 ...
PPTX
Elixir 5 minute intro
PPT
Take Flight - Using Fly with the Play Framework
PDF
Monitoring InfluxEnterprise
PDF
"Metrics: Where and How", Vsevolod Polyakov
PDF
Time Series Data with InfluxDB
PDF
Cluster Drm
InfluxData Platform Future and Vision
Cypher for Gremlin
Write your own telegraf plugin
Improving Performance of a WebKit Port MIPS Platform (ELC 2014)
Performance testing of microservices in Action
Building a Serverless Computation Environment with Python
Syslog-ng Performance
Improving go-git performance
Scaling with Python: SF Python Meetup, September 2017
Enable IPv6 on Route53 AWS ELB, docker and node App
Boosting command line experience with python and awk
Logistic Regression in R-An Exmple.
Raster Processing with Scipy.ndimage (Dev Meet Up II)
Manageable data pipelines with airflow (and kubernetes) november 27, 11 45 ...
Elixir 5 minute intro
Take Flight - Using Fly with the Play Framework
Monitoring InfluxEnterprise
"Metrics: Where and How", Vsevolod Polyakov
Time Series Data with InfluxDB
Cluster Drm
Ad

More from openCypher (20)

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

Recently uploaded (20)

PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
1 - Historical Antecedents, Social Consideration.pdf
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PDF
August Patch Tuesday
PDF
A comparative study of natural language inference in Swahili using monolingua...
PPTX
Modernising the Digital Integration Hub
PPT
Module 1.ppt Iot fundamentals and Architecture
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
Developing a website for English-speaking practice to English as a foreign la...
PDF
WOOl fibre morphology and structure.pdf for textiles
PPT
What is a Computer? Input Devices /output devices
PPTX
observCloud-Native Containerability and monitoring.pptx
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Architecture types and enterprise applications.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
A novel scalable deep ensemble learning framework for big data classification...
A contest of sentiment analysis: k-nearest neighbor versus neural network
Univ-Connecticut-ChatGPT-Presentaion.pdf
1 - Historical Antecedents, Social Consideration.pdf
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
August Patch Tuesday
A comparative study of natural language inference in Swahili using monolingua...
Modernising the Digital Integration Hub
Module 1.ppt Iot fundamentals and Architecture
cloud_computing_Infrastucture_as_cloud_p
Getting started with AI Agents and Multi-Agent Systems
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Developing a website for English-speaking practice to English as a foreign la...
WOOl fibre morphology and structure.pdf for textiles
What is a Computer? Input Devices /output devices
observCloud-Native Containerability and monitoring.pptx
Group 1 Presentation -Planning and Decision Making .pptx
Architecture types and enterprise applications.pdf

Cypher for Gremlin

  • 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 language gremlin> g.V().count() ==>0 gremlin> g.addV('person').properties('name', 'Marko') gremlin> g.V().count() ==>1 gremlin> g.V().hasLabel('person').values('name') ==>Marko
  • 5. MATCH (p:Planet)-[orbit:ORBITS]->(:Star {name: 'Sun'}) WHERE orbit.au < 5 RETURN p AS planet; g.V().as('p').outE('ORBITS').as('orbit').inV().as(' UNNAMED34') .where(and( select('p').hasLabel('Planet'), select(' UNNAMED34').values('name').is(eq('Sun')), select(' UNNAMED34').hasLabel('Star'), select('orbit').values('au').is(lt(5)) )) .select('p').map(project('planet').by(identity())) The gist
  • 6. Clauses Other Patterns Functions MATCH RETURN UNWIND OPTIONAL MATCH WITH UNION CREATE MERGE SET DETACH DELETE ON CREATE ON MATCH WHERE ORDER BY SKIP LIMIT DISTINCT (n:L {k: ‘v’}) ()-->() ()--() ()-[r:L {k: ‘v’}]-() (n)-[r]-(m) ()-[]-()-[]-() ()-[*n]-() [x IN … | …] avg, collect, count, max, min, sum keys, labels, nodes, relationships, size type, exists, type conversion, string matching It is not guaranteed, however, that all combinations of the listed clauses, patterns, or functions will work. You are welcome to report any issues with the translation that you encounter. Cypher → Gremlin translation
  • 7. ● Cypher to Gremlin translation library for Java ● Cypher for Gremlin Server (plugin) ● Cypher for Gremlin Console (plugin) ● Cypher wrapper for Gremlin client ● Neo4j driver-like API wrapper ● TCK implementation for Gremlin Cypher for Gremlin open source https://github.com/opencypher/cypher-for-gremlin
  • 8. 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
  • 10. Query performance tests ● Setup: ○ “Movies” graph (171 nodes, 506 rels) ○ One benchmark = one query execution ○ Warmup: 1 iteration, 1 sec each ○ Measurement: 5 iterations, 1 sec each ● Targets: ○ Gremlin Server with TinkerGraph backend and Cypher for Gremlin plugin ○ No-op with query translation only ● Hardware: ○ Intel Core i5-6200U CPU @ 2.30GHz ○ Linux 4.14.4-1-ARCH x86_64 ○ JDK 1.8.0_144, VM 25.144-b01 ○ JMH 1.17.4 Benchmark TinkerGraph avg ms/op Translation avg ms/op allNodes 7.019 1.069 allPaths 7.208 1.495 byLabel 4.367 1.246 byLongPath 6.899 2.407 byMultiplePaths 306.611 3.442 byPath 3.902 1.923 byProperty 3.618 1.468 byUndirectedPath 5.037 2.113 byVariablePath 448.726 2.079 countWithPivot 3.917 1.790 groupByProperty 5.295 1.766 limit 3.261 1.229 orderBy 5.268 2.808 relationshipTypes 3.823 1.747 wherePropertyBetween 3.884 2.097
  • 11. Java APIs: translation /* * 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);
  • 12. Java APIs: Gremlin Server client /* * 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();
  • 13. Neo4j, Gremlin Server, and Cosmos DB running side-by-side