SlideShare a Scribd company logo
1 of 26
Download to read offline
Traversing Graph Databases with Gremlin
               Marko A. Rodriguez
             Graph Systems Architect
            http://markorodriguez.com

      NoSQL New York City Meetup – May 16, 2011




           Gremlin   G = (V, E)


                   May 10, 2011
Thank You Sponsors




Short Slideshow + Live Demo = This Presentation
TinkerPop Productions




1
    1
    TinkerPop (http://tinkerpop.com), Marko A. Rodriguez (http://markorodriguez.com), Peter
Neubauer (http://www.linkedin.com/in/neubauer), Joshua Shinavier (http://fortytwo.net/), Pavel
Yaskevich (https://github.com/xedin), Darrick Wiebe (http://ofallpossibleworlds.wordpress.
com/), Stephen Mallette (http://stephen.genoprime.com/), Alex Averbuch (http://se.linkedin.
com/in/alexaverbuch)
TinkerPop Graph Stack

                            http://host:8182/graph/vertices/1


  RESTful Server


Traversal Language


 Traversal Engine
   Graph-to-Object Mapper

 Generic Interface


                               TinkerGraph

 Graph Database
TinkerPop Graph Stack – Focus

                     http://host:8182/graph/vertices/1




Traversal Language


 Traversal Engine


 Generic Interface


                        TinkerGraph
Blueprints –> Pipes –> Groovy –> Gremlin

To understand Gremlin, its important to understand Groovy,
Blueprints, and Pipes.




                   Bl
                      ue                  s
                        pr            ip
                                         e
                             in      P
                                ts
Gremlin is a Domain Specific Language

• Gremlin 0.7+ uses Groovy as its host language.2

• Gremlin 0.7+ takes advantage of Groovy’s meta-programming, dynamic
  typing, and closure properties.

• Groovy is a superset of Java and as such, natively exposes the full JDK
  to Gremlin.




 2
     Groovy available at http://groovy.codehaus.org/.
Gremlin is for Property Graphs
                                                            name = "lop"
                                                            lang = "java"

                                           weight = 0.4              3
                         name = "marko"
                         age = 29            created
                                                                                    weight = 0.2
                                       9
                                   1                                                created
                                       8                     created
                                                                                              12
                                   7       weight = 1.0
                    weight = 0.5
                                                                    weight = 0.4                    6
                                            knows
                              knows                          11                               name = "peter"
                                                                                              age = 35
                                                                    name = "josh"
                                                            4       age = 32
                                   2
                                                            10
                         name = "vadas"
                         age = 27
                                                                 weight = 1.0

                                                          created



                                                            5
                                                    name = "ripple"
                                                    lang = "java"




A graph is composed of vertices (nodes), edges (links), and properties (keys/values).
Gremlin is for Blueprints-enabled Graph Databases

•   Blueprints can be seen as the JDBC for property graph databases.3
•   Provides a collection of interfaces for graph database providers to implement.
•   Provides tests to ensure the operational semantics of any implementation are correct.
•   Provides numerous “helper utilities” to make working with graph databases easy.




                                 Blueprints

    3
        Blueprints is available at http://blueprints.tinkerpop.com.
A Blueprints Detour - Implementations


  TinkerGraph
A Blueprints Detour - Ouplementations




     JUNG
     Java Universal Network/Graph Framework
Gremlin Compiles Down to Pipes
• Pipes is a data flow framework for evaluating lazy graph traversals.4

• A Pipe extends Iterator, Iterable and can be chained together
  to create processing pipelines.

• A Pipe can be embedded into another Pipe to allow for nested
  processing.




                                                 Pipes
 4
     Pipes is available at http://pipes.tinkerpop.com.
A Pipes Detour - Chained Iterators

• This Pipeline takes objects of type A and turns them into objects of
  type D.


                                                                      D
                                                              D
       A
               A   A   Pipe1   B    Pipe2     C   Pipe3   D       D
   A                                                          D
           A
                                   Pipeline



Pipe<A,D> pipeline =
   new Pipeline<A,D>(Pipe1<A,B>, Pipe2<B,C>, Pipe3<C,D>)
A Pipes Detour - Simple Example

“What are the names of the people that marko knows?”

                                     B       name=peter
                        knows



                A       knows        C       name=pavel

          name=marko
                                   created
                        created
                                     D       name=gremlin
A Pipes Detour - Simple Example
Pipe<Vertex,Edge> pipe1 = new OutEdgesPipe("knows");
Pipe<Edge,Vertex> pipe2 = new InVertexPipe();
Pipe<Vertex,String> pipe3 = new PropertyPipe<String>("name");
Pipe<Vertex,String> pipeline = new Pipeline(pipe1,pipe2,pipe3);
pipeline.setStarts(new SingleIterator<Vertex>(graph.getVertex("A"));


                                                        InVertexPipe()


                       OutEdgesPipe("knows")
                                                                          PropertyPipe("name")

                                                                  B       name=peter
                                              knows



                               A               knows              C       name=pavel

                       name=marko
                                                                created
                                              created
                                                                  D       name=gremlin




HINT: The benefit of Gremlin is that this Java verbosity is reduced to g.v(‘A’).outE(‘knows’).inV.name.
A Pipes Detour - Pipes Library


                       [ GRAPHS ]           [ SIDEEFFECTS ]
[ FILTERS ]            OutEdgesPipe         AggregatorPipe
AndFilterPipe          InEdgesPipe          GroupCountPipe
BackFilterPipe         OutVertexPipe        CountPipe
CollectionFilterPipe   InVertexPip          SideEffectCapPipe
ComparisonFilterPipe   IdFilterPipe
DuplicateFilterPipe    IdPipe               [ UTILITIES ]
FutureFilterPipe       LabelFilterPipe      GatherPipe
ObjectFilterPipe       LabelPipe            PathPipe
OrFilterPipe           PropertyFilterPipe   ScatterPipe
RandomFilterPipe       PropertyPipe         Pipeline
RangeFilterPipe                             ...
A Pipes Detour - Creating Pipes


public class NumCharsPipe extends AbstractPipe<String,Integer> {
  public Integer processNextStart() {
    String word = this.starts.next();
    return word.length();
  }
}


When extending the base class AbstractPipe<S,E> all that is required is
an implementation of processNextStart().
Now onto Gremlin proper...
The Gremlin Architecture




   Neo4j   OrientDB   DEX
The Many Ways of Using Gremlin

• Gremlin has a REPL to be run from the shell.

• Gremlin can be natively integrated into any Groovy class.

• Gremlin can be interacted with indirectly through Java, via Groovy.

• Gremlin has a JSR 223 ScriptEngine as well.
Pipe = Step: 3 Generic Steps
In general a Pipe is a “step” in Gremlin. Gremlin is founded on a collection
of atomic steps. The syntax is generally seen as step.step.step. There
are 3 categories of steps.

• transform: map the input to some output. S → T
     outE, inV, paths, copySplit, fairMerge, . . .

• filter: either output the input or not. S → (S ∪ ∅)
     back, except, uniqueObject, andFilter, orFilter, . . .

• sideEffect: output the input and yield a side-effect. S → S
     aggregate, groupCount, . . .
Abstract/Derived/Inferred Adjacency
                              outE


                                         in                                 outE
                                              V


                                     loop(2){..}                   back(3)
                                               {i
                                                    t.
                                                         sa
                                                              la




                                      }                            ry
                                                                        }


                       friend_of_a_friend_who_earns_less_than_friend_at_work




• outE, inV, etc. is low-level graph speak (the domain is the graph).
• codeveloper is high-level domain speak (the domain is software development).5

   5
     In this way, Gremlin can be seen as a DSL (domain-specific language) for creating DSL’s for your
graph applications. Gremlin’s domain is “the graph.” Build languages for your domain on top of Gremlin
(e.g. “software development domain”).
Developer's FOAF Import
               Graph

                                     Friend-Of-A-Friend
                                           Graph




Developer Imports                                         Friends at Work
     Graph                                                     Graph



                                                                            You need not make
                       Software Imports   Friendship                        derived graphs explicit.
                            Graph           Graph                           You can, at runtime,
                                                                            compute them.
                                                                            Moreover, generate
                                                                            them locally, not
   Developer Created                                                        globally (e.g. ``Marko's
                                                          Employment
        Graph                                                               friends from work
                                                            Graph
                                                                            relations").

                                                                            This concept is related
                                                                            to automated reasoning
                                                                            and whether reasoned
                                                                            relations are inserted
                                                                            into the explicit graph or
                              Explicit Graph                                computed at query time.
Integrating the JDK (Java API)

• Groovy is the host language for Gremlin. Thus, the JDK is natively
  available in a path expression.

gremlin> v.out(‘friend’){it.name.matches(‘M.*’)}.name
==>Mattias
==>Marko
==>Matt
...
gremlin> x.out(‘rated’).transform{JSONParser.get(it.uri).stars}.mean()
...
gremlin> y.outE(‘rated’).filter{TextAnalysis.isElated(it.review)}.inV
...
Time for a demo
marko$ gremlin
         ,,,/
         (o o)
-----oOOo-(_)-oOOo-----
gremlin>




                             Gremlin    G = (V, E)


                     http://gremlin.tinkerpop.com
             http://groups.google.com/group/gremlin-users
                         http://tinkerpop.com
Graph Bootcamp




      http://markorodriguez.com/services/workshops/graph-bootcamp/

• June 23-24th in Chicago, Illinois.
• August X-Yth in Denver, Colorado.
• Book a private gig for your organization.

More Related Content

What's hot

What's hot (20)

Intro GraphQL
Intro GraphQLIntro GraphQL
Intro GraphQL
 
GraalVM
GraalVMGraalVM
GraalVM
 
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
 
Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)Graphql Intro (Tutorial and Example)
Graphql Intro (Tutorial and Example)
 
Intro to Neo4j presentation
Intro to Neo4j presentationIntro to Neo4j presentation
Intro to Neo4j presentation
 
OPA: The Cloud Native Policy Engine
OPA: The Cloud Native Policy EngineOPA: The Cloud Native Policy Engine
OPA: The Cloud Native Policy Engine
 
Intro to Neo4j and Graph Databases
Intro to Neo4j and Graph DatabasesIntro to Neo4j and Graph Databases
Intro to Neo4j and Graph Databases
 
Istio on Kubernetes
Istio on KubernetesIstio on Kubernetes
Istio on Kubernetes
 
Neptune, the Graph Database | AWS Floor28
Neptune, the Graph Database | AWS Floor28Neptune, the Graph Database | AWS Floor28
Neptune, the Graph Database | AWS Floor28
 
Opa gatekeeper
Opa gatekeeperOpa gatekeeper
Opa gatekeeper
 
GraalVM Native and Spring Boot 3.0
GraalVM Native and Spring Boot 3.0GraalVM Native and Spring Boot 3.0
GraalVM Native and Spring Boot 3.0
 
GraphQL
GraphQLGraphQL
GraphQL
 
Wroclaw GraphQL - GraphQL in Java
Wroclaw GraphQL - GraphQL in JavaWroclaw GraphQL - GraphQL in Java
Wroclaw GraphQL - GraphQL in Java
 
Graphql presentation
Graphql presentationGraphql presentation
Graphql presentation
 
React & GraphQL
React & GraphQLReact & GraphQL
React & GraphQL
 
SignalR Overview
SignalR OverviewSignalR Overview
SignalR Overview
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
Spring GraphQL
Spring GraphQLSpring GraphQL
Spring GraphQL
 
GraalVM: Run Programs Faster Everywhere
GraalVM: Run Programs Faster EverywhereGraalVM: Run Programs Faster Everywhere
GraalVM: Run Programs Faster Everywhere
 
Kubernetes Secrets Management on Production with Demo
Kubernetes Secrets Management on Production with DemoKubernetes Secrets Management on Production with Demo
Kubernetes Secrets Management on Production with Demo
 

Viewers also liked

Viewers also liked (14)

The Gremlin Graph Traversal Language
The Gremlin Graph Traversal LanguageThe Gremlin Graph Traversal Language
The Gremlin Graph Traversal Language
 
Intro to Graph Databases Using Tinkerpop, TitanDB, and Gremlin
Intro to Graph Databases Using Tinkerpop, TitanDB, and GremlinIntro to Graph Databases Using Tinkerpop, TitanDB, and Gremlin
Intro to Graph Databases Using Tinkerpop, TitanDB, and Gremlin
 
Gremlin: A Graph-Based Programming Language
Gremlin: A Graph-Based Programming LanguageGremlin: A Graph-Based Programming Language
Gremlin: A Graph-Based Programming Language
 
Gremlin's Graph Traversal Machinery
Gremlin's Graph Traversal MachineryGremlin's Graph Traversal Machinery
Gremlin's Graph Traversal Machinery
 
DataStax: What's New in Apache TinkerPop - the Graph Computing Framework
DataStax: What's New in Apache TinkerPop - the Graph Computing FrameworkDataStax: What's New in Apache TinkerPop - the Graph Computing Framework
DataStax: What's New in Apache TinkerPop - the Graph Computing Framework
 
The Gremlin in the Graph
The Gremlin in the GraphThe Gremlin in the Graph
The Gremlin in the Graph
 
Solving Problems with Graphs
Solving Problems with GraphsSolving Problems with Graphs
Solving Problems with Graphs
 
Problem-Solving using Graph Traversals: Searching, Scoring, Ranking, and Reco...
Problem-Solving using Graph Traversals: Searching, Scoring, Ranking, and Reco...Problem-Solving using Graph Traversals: Searching, Scoring, Ranking, and Reco...
Problem-Solving using Graph Traversals: Searching, Scoring, Ranking, and Reco...
 
Graph Processing with Apache TinkerPop
Graph Processing with Apache TinkerPopGraph Processing with Apache TinkerPop
Graph Processing with Apache TinkerPop
 
What are systems and how does this apply to school leadership
What are systems and how does this apply to school leadership What are systems and how does this apply to school leadership
What are systems and how does this apply to school leadership
 
The Graph Traversal Programming Pattern
The Graph Traversal Programming PatternThe Graph Traversal Programming Pattern
The Graph Traversal Programming Pattern
 
System concepts, elements and types of systems ppt
System concepts, elements and types of systems pptSystem concepts, elements and types of systems ppt
System concepts, elements and types of systems ppt
 
Knowledge representation and Predicate logic
Knowledge representation and Predicate logicKnowledge representation and Predicate logic
Knowledge representation and Predicate logic
 
ACM DBPL Keynote: The Graph Traversal Machine and Language
ACM DBPL Keynote: The Graph Traversal Machine and LanguageACM DBPL Keynote: The Graph Traversal Machine and Language
ACM DBPL Keynote: The Graph Traversal Machine and Language
 

Similar to Traversing Graph Databases with Gremlin

1st UIM-GDB - Connections to the Real World
1st UIM-GDB - Connections to the Real World1st UIM-GDB - Connections to the Real World
1st UIM-GDB - Connections to the Real World
Achim Friedland
 
Fosdem 2011 - A Common Graph Database Access Layer for .Net and Mono
Fosdem 2011 - A Common Graph Database Access Layer for .Net and MonoFosdem 2011 - A Common Graph Database Access Layer for .Net and Mono
Fosdem 2011 - A Common Graph Database Access Layer for .Net and Mono
Achim Friedland
 
JSPP: Morphing C++ into Javascript
JSPP: Morphing C++ into JavascriptJSPP: Morphing C++ into Javascript
JSPP: Morphing C++ into Javascript
Christopher Chedeau
 
Application Modeling with Graph Databases
Application Modeling with Graph DatabasesApplication Modeling with Graph Databases
Application Modeling with Graph Databases
Josh Adell
 
Rapid Development with Ruby/JRuby and Rails
Rapid Development with Ruby/JRuby and RailsRapid Development with Ruby/JRuby and Rails
Rapid Development with Ruby/JRuby and Rails
elliando dias
 
A walk in graph databases v1.0
A walk in graph databases v1.0A walk in graph databases v1.0
A walk in graph databases v1.0
Pierre De Wilde
 

Similar to Traversing Graph Databases with Gremlin (20)

The Path-o-Logical Gremlin
The Path-o-Logical GremlinThe Path-o-Logical Gremlin
The Path-o-Logical Gremlin
 
Gremlin
Gremlin Gremlin
Gremlin
 
1st UIM-GDB - Connections to the Real World
1st UIM-GDB - Connections to the Real World1st UIM-GDB - Connections to the Real World
1st UIM-GDB - Connections to the Real World
 
Fosdem 2011 - A Common Graph Database Access Layer for .Net and Mono
Fosdem 2011 - A Common Graph Database Access Layer for .Net and MonoFosdem 2011 - A Common Graph Database Access Layer for .Net and Mono
Fosdem 2011 - A Common Graph Database Access Layer for .Net and Mono
 
ソーシャルグラフ分析
ソーシャルグラフ分析ソーシャルグラフ分析
ソーシャルグラフ分析
 
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
 
J
JJ
J
 
JSPP: Morphing C++ into Javascript
JSPP: Morphing C++ into JavascriptJSPP: Morphing C++ into Javascript
JSPP: Morphing C++ into Javascript
 
Neo4j Nosqllive
Neo4j NosqlliveNeo4j Nosqllive
Neo4j Nosqllive
 
Application Modeling with Graph Databases
Application Modeling with Graph DatabasesApplication Modeling with Graph Databases
Application Modeling with Graph Databases
 
Rapid Development with Ruby/JRuby and Rails
Rapid Development with Ruby/JRuby and RailsRapid Development with Ruby/JRuby and Rails
Rapid Development with Ruby/JRuby and Rails
 
In The Land Of Graphs...
In The Land Of Graphs...In The Land Of Graphs...
In The Land Of Graphs...
 
Groovy & Grails
Groovy & GrailsGroovy & Grails
Groovy & Grails
 
Concurrent Stream Processing
Concurrent Stream ProcessingConcurrent Stream Processing
Concurrent Stream Processing
 
A walk in graph databases v1.0
A walk in graph databases v1.0A walk in graph databases v1.0
A walk in graph databases v1.0
 
ruby1_6up
ruby1_6upruby1_6up
ruby1_6up
 
ruby1_6up
ruby1_6upruby1_6up
ruby1_6up
 
BUILDING WHILE FLYING
BUILDING WHILE FLYINGBUILDING WHILE FLYING
BUILDING WHILE FLYING
 
Neo4j -- or why graph dbs kick ass
Neo4j -- or why graph dbs kick assNeo4j -- or why graph dbs kick ass
Neo4j -- or why graph dbs kick ass
 
JavaOne報告会 Java SE/JavaFX 編 - JJUG CCC 2010 Fall
JavaOne報告会 Java SE/JavaFX 編 - JJUG CCC 2010 FallJavaOne報告会 Java SE/JavaFX 編 - JJUG CCC 2010 Fall
JavaOne報告会 Java SE/JavaFX 編 - JJUG CCC 2010 Fall
 

More from Marko Rodriguez

Memoirs of a Graph Addict: Despair to Redemption
Memoirs of a Graph Addict: Despair to RedemptionMemoirs of a Graph Addict: Despair to Redemption
Memoirs of a Graph Addict: Despair to Redemption
Marko Rodriguez
 
The Network Data Structure in Computing
The Network Data Structure in ComputingThe Network Data Structure in Computing
The Network Data Structure in Computing
Marko Rodriguez
 
A Model of the Scholarly Community
A Model of the Scholarly CommunityA Model of the Scholarly Community
A Model of the Scholarly Community
Marko Rodriguez
 

More from Marko Rodriguez (20)

mm-ADT: A Virtual Machine/An Economic Machine
mm-ADT: A Virtual Machine/An Economic Machinemm-ADT: A Virtual Machine/An Economic Machine
mm-ADT: A Virtual Machine/An Economic Machine
 
mm-ADT: A Multi-Model Abstract Data Type
mm-ADT: A Multi-Model Abstract Data Typemm-ADT: A Multi-Model Abstract Data Type
mm-ADT: A Multi-Model Abstract Data Type
 
Open Problems in the Universal Graph Theory
Open Problems in the Universal Graph TheoryOpen Problems in the Universal Graph Theory
Open Problems in the Universal Graph Theory
 
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
 
Quantum Processes in Graph Computing
Quantum Processes in Graph ComputingQuantum Processes in Graph Computing
Quantum Processes in Graph Computing
 
The Path Forward
The Path ForwardThe Path Forward
The Path Forward
 
Faunus: Graph Analytics Engine
Faunus: Graph Analytics EngineFaunus: Graph Analytics Engine
Faunus: Graph Analytics Engine
 
Titan: The Rise of Big Graph Data
Titan: The Rise of Big Graph DataTitan: The Rise of Big Graph Data
Titan: The Rise of Big Graph Data
 
The Pathology of Graph Databases
The Pathology of Graph DatabasesThe Pathology of Graph Databases
The Pathology of Graph Databases
 
Memoirs of a Graph Addict: Despair to Redemption
Memoirs of a Graph Addict: Despair to RedemptionMemoirs of a Graph Addict: Despair to Redemption
Memoirs of a Graph Addict: Despair to Redemption
 
Graph Databases: Trends in the Web of Data
Graph Databases: Trends in the Web of DataGraph Databases: Trends in the Web of Data
Graph Databases: Trends in the Web of Data
 
A Perspective on Graph Theory and Network Science
A Perspective on Graph Theory and Network ScienceA Perspective on Graph Theory and Network Science
A Perspective on Graph Theory and Network Science
 
The Network Data Structure in Computing
The Network Data Structure in ComputingThe Network Data Structure in Computing
The Network Data Structure in Computing
 
A Model of the Scholarly Community
A Model of the Scholarly CommunityA Model of the Scholarly Community
A Model of the Scholarly Community
 
General-Purpose, Internet-Scale Distributed Computing with Linked Process
General-Purpose, Internet-Scale Distributed Computing with Linked ProcessGeneral-Purpose, Internet-Scale Distributed Computing with Linked Process
General-Purpose, Internet-Scale Distributed Computing with Linked Process
 
Collective Decision Making Systems: From the Ideal State to Human Eudaimonia
Collective Decision Making Systems: From the Ideal State to Human EudaimoniaCollective Decision Making Systems: From the Ideal State to Human Eudaimonia
Collective Decision Making Systems: From the Ideal State to Human Eudaimonia
 
Distributed Graph Databases and the Emerging Web of Data
Distributed Graph Databases and the Emerging Web of DataDistributed Graph Databases and the Emerging Web of Data
Distributed Graph Databases and the Emerging Web of Data
 
An Overview of Data Management Paradigms: Relational, Document, and Graph
An Overview of Data Management Paradigms: Relational, Document, and GraphAn Overview of Data Management Paradigms: Relational, Document, and Graph
An Overview of Data Management Paradigms: Relational, Document, and Graph
 
Graph Databases and the Future of Large-Scale Knowledge Management
Graph Databases and the Future of Large-Scale Knowledge ManagementGraph Databases and the Future of Large-Scale Knowledge Management
Graph Databases and the Future of Large-Scale Knowledge Management
 
Automatic Metadata Generation using Associative Networks
Automatic Metadata Generation using Associative NetworksAutomatic Metadata Generation using Associative Networks
Automatic Metadata Generation using Associative Networks
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

Traversing Graph Databases with Gremlin

  • 1. Traversing Graph Databases with Gremlin Marko A. Rodriguez Graph Systems Architect http://markorodriguez.com NoSQL New York City Meetup – May 16, 2011 Gremlin G = (V, E) May 10, 2011
  • 2. Thank You Sponsors Short Slideshow + Live Demo = This Presentation
  • 3. TinkerPop Productions 1 1 TinkerPop (http://tinkerpop.com), Marko A. Rodriguez (http://markorodriguez.com), Peter Neubauer (http://www.linkedin.com/in/neubauer), Joshua Shinavier (http://fortytwo.net/), Pavel Yaskevich (https://github.com/xedin), Darrick Wiebe (http://ofallpossibleworlds.wordpress. com/), Stephen Mallette (http://stephen.genoprime.com/), Alex Averbuch (http://se.linkedin. com/in/alexaverbuch)
  • 4. TinkerPop Graph Stack http://host:8182/graph/vertices/1 RESTful Server Traversal Language Traversal Engine Graph-to-Object Mapper Generic Interface TinkerGraph Graph Database
  • 5. TinkerPop Graph Stack – Focus http://host:8182/graph/vertices/1 Traversal Language Traversal Engine Generic Interface TinkerGraph
  • 6. Blueprints –> Pipes –> Groovy –> Gremlin To understand Gremlin, its important to understand Groovy, Blueprints, and Pipes. Bl ue s pr ip e in P ts
  • 7. Gremlin is a Domain Specific Language • Gremlin 0.7+ uses Groovy as its host language.2 • Gremlin 0.7+ takes advantage of Groovy’s meta-programming, dynamic typing, and closure properties. • Groovy is a superset of Java and as such, natively exposes the full JDK to Gremlin. 2 Groovy available at http://groovy.codehaus.org/.
  • 8. Gremlin is for Property Graphs name = "lop" lang = "java" weight = 0.4 3 name = "marko" age = 29 created weight = 0.2 9 1 created 8 created 12 7 weight = 1.0 weight = 0.5 weight = 0.4 6 knows knows 11 name = "peter" age = 35 name = "josh" 4 age = 32 2 10 name = "vadas" age = 27 weight = 1.0 created 5 name = "ripple" lang = "java" A graph is composed of vertices (nodes), edges (links), and properties (keys/values).
  • 9. Gremlin is for Blueprints-enabled Graph Databases • Blueprints can be seen as the JDBC for property graph databases.3 • Provides a collection of interfaces for graph database providers to implement. • Provides tests to ensure the operational semantics of any implementation are correct. • Provides numerous “helper utilities” to make working with graph databases easy. Blueprints 3 Blueprints is available at http://blueprints.tinkerpop.com.
  • 10. A Blueprints Detour - Implementations TinkerGraph
  • 11. A Blueprints Detour - Ouplementations JUNG Java Universal Network/Graph Framework
  • 12. Gremlin Compiles Down to Pipes • Pipes is a data flow framework for evaluating lazy graph traversals.4 • A Pipe extends Iterator, Iterable and can be chained together to create processing pipelines. • A Pipe can be embedded into another Pipe to allow for nested processing. Pipes 4 Pipes is available at http://pipes.tinkerpop.com.
  • 13. A Pipes Detour - Chained Iterators • This Pipeline takes objects of type A and turns them into objects of type D. D D A A A Pipe1 B Pipe2 C Pipe3 D D A D A Pipeline Pipe<A,D> pipeline = new Pipeline<A,D>(Pipe1<A,B>, Pipe2<B,C>, Pipe3<C,D>)
  • 14. A Pipes Detour - Simple Example “What are the names of the people that marko knows?” B name=peter knows A knows C name=pavel name=marko created created D name=gremlin
  • 15. A Pipes Detour - Simple Example Pipe<Vertex,Edge> pipe1 = new OutEdgesPipe("knows"); Pipe<Edge,Vertex> pipe2 = new InVertexPipe(); Pipe<Vertex,String> pipe3 = new PropertyPipe<String>("name"); Pipe<Vertex,String> pipeline = new Pipeline(pipe1,pipe2,pipe3); pipeline.setStarts(new SingleIterator<Vertex>(graph.getVertex("A")); InVertexPipe() OutEdgesPipe("knows") PropertyPipe("name") B name=peter knows A knows C name=pavel name=marko created created D name=gremlin HINT: The benefit of Gremlin is that this Java verbosity is reduced to g.v(‘A’).outE(‘knows’).inV.name.
  • 16. A Pipes Detour - Pipes Library [ GRAPHS ] [ SIDEEFFECTS ] [ FILTERS ] OutEdgesPipe AggregatorPipe AndFilterPipe InEdgesPipe GroupCountPipe BackFilterPipe OutVertexPipe CountPipe CollectionFilterPipe InVertexPip SideEffectCapPipe ComparisonFilterPipe IdFilterPipe DuplicateFilterPipe IdPipe [ UTILITIES ] FutureFilterPipe LabelFilterPipe GatherPipe ObjectFilterPipe LabelPipe PathPipe OrFilterPipe PropertyFilterPipe ScatterPipe RandomFilterPipe PropertyPipe Pipeline RangeFilterPipe ...
  • 17. A Pipes Detour - Creating Pipes public class NumCharsPipe extends AbstractPipe<String,Integer> { public Integer processNextStart() { String word = this.starts.next(); return word.length(); } } When extending the base class AbstractPipe<S,E> all that is required is an implementation of processNextStart().
  • 18. Now onto Gremlin proper...
  • 19. The Gremlin Architecture Neo4j OrientDB DEX
  • 20. The Many Ways of Using Gremlin • Gremlin has a REPL to be run from the shell. • Gremlin can be natively integrated into any Groovy class. • Gremlin can be interacted with indirectly through Java, via Groovy. • Gremlin has a JSR 223 ScriptEngine as well.
  • 21. Pipe = Step: 3 Generic Steps In general a Pipe is a “step” in Gremlin. Gremlin is founded on a collection of atomic steps. The syntax is generally seen as step.step.step. There are 3 categories of steps. • transform: map the input to some output. S → T outE, inV, paths, copySplit, fairMerge, . . . • filter: either output the input or not. S → (S ∪ ∅) back, except, uniqueObject, andFilter, orFilter, . . . • sideEffect: output the input and yield a side-effect. S → S aggregate, groupCount, . . .
  • 22. Abstract/Derived/Inferred Adjacency outE in outE V loop(2){..} back(3) {i t. sa la } ry } friend_of_a_friend_who_earns_less_than_friend_at_work • outE, inV, etc. is low-level graph speak (the domain is the graph). • codeveloper is high-level domain speak (the domain is software development).5 5 In this way, Gremlin can be seen as a DSL (domain-specific language) for creating DSL’s for your graph applications. Gremlin’s domain is “the graph.” Build languages for your domain on top of Gremlin (e.g. “software development domain”).
  • 23. Developer's FOAF Import Graph Friend-Of-A-Friend Graph Developer Imports Friends at Work Graph Graph You need not make Software Imports Friendship derived graphs explicit. Graph Graph You can, at runtime, compute them. Moreover, generate them locally, not Developer Created globally (e.g. ``Marko's Employment Graph friends from work Graph relations"). This concept is related to automated reasoning and whether reasoned relations are inserted into the explicit graph or Explicit Graph computed at query time.
  • 24. Integrating the JDK (Java API) • Groovy is the host language for Gremlin. Thus, the JDK is natively available in a path expression. gremlin> v.out(‘friend’){it.name.matches(‘M.*’)}.name ==>Mattias ==>Marko ==>Matt ... gremlin> x.out(‘rated’).transform{JSONParser.get(it.uri).stars}.mean() ... gremlin> y.outE(‘rated’).filter{TextAnalysis.isElated(it.review)}.inV ...
  • 25. Time for a demo marko$ gremlin ,,,/ (o o) -----oOOo-(_)-oOOo----- gremlin> Gremlin G = (V, E) http://gremlin.tinkerpop.com http://groups.google.com/group/gremlin-users http://tinkerpop.com
  • 26. Graph Bootcamp http://markorodriguez.com/services/workshops/graph-bootcamp/ • June 23-24th in Chicago, Illinois. • August X-Yth in Denver, Colorado. • Book a private gig for your organization.