0
Rapid development with Neo4J         under Grails
About Myself•   Located in Riga/Latvia•   Technical Architect in Accenture•   Experience since 10 years•   C#/Java/Groovy/...
no:sqlMarket has significantly different challenges indealing with data that the traditional RDBMSsolutions could not cope...
Issues•   size data sets•   data relations are connected•   distributed processing•   Data Model -> semi-structured approach
brings to diversity of solutions                       Data Model        Distribution                Disk Data           M...
types Document store        Graph  Key-value storeMultivalue databases Object database       Tabular     Tuple store
hard to integrate in industrialized            companies
Grails SupportName               TypeRIAK               Eventually‐consistent key‐value   +REDIS              Key-value ca...
Graph DB implemetations                      LanguageDEX                   C++FlockDB               ScalaInfiniteGraph    ...
Graph on(in) GrailsNeo4j is (as of now) the only graph databasethat fits nicely in a Grails application.
Data is connected
Why Graph DB?Insufficient RDBMS performance in hierarchicalstructures. The graph database storage shineswhen storing richl...
SQL addonsSome DBs has even special DSL:SELECT empno,   ename,   job,   mgr,   hiredate,   LEVELFROM empWHERE LEVEL <= 2ST...
Where Graph DB•   Network Management•   Master Data Management•   Social•   Finance•   Spatial    – Map Routing• Bio
Why Neo4J?•   true ACID transactions•   high availability•   scales to billions of nodes and relationships•   high speed q...
Why neo4j - details• Disk ready  – Native graph storage engine with custom (SSD-    ready) binary on-disk format• Transact...
Access & Implementation Types1. EmbeddedGraphDatabase: just to local JVM2. RestGraphDatabase: rest-binding3. HighAvaibleGr...
When Grails shinesRuby platform isn’t a case, Java is too expensive,Scala is too smart.Startups & prototypesModel-driven a...
Groovy & Grails Architecture                   Controller   View GSP        Service        Domain                    Plug-...
GORMAbstraction on abstractions, wraps:  – Hibernate  – JPA  – Gemfire, Redis, Riak  – MongoDB, JCR  – Neo4JIntegration te...
Neo4j plug-in
Plugin features• Neo4j -> Groovy/Java• GORM dynamic finders, criteria and named  queries• Session-managed transactions• Be...
Jump into Neo4J                                     name:staff                                     type:weaponname:Splinte...
Nodes
Relationships
Properties                                              name:staff                                              type:weapo...
Mapping                      Reference Node                                  SubreferenceDomain Class/Type                ...
Compatibility with GORM                     ✔                                          ✗Simple persistence methods        ...
Getting Startedgrails install-plugin neo4jgrails uninstall-plugin hibernate
Create Domaingrails create-domain-class Hero
Exampleshero.save()Hero.findByWeightGreaterThan( 100 )Hero.findAllByFullNameNotNull()hero.weapons.each {   …}
Combining Neo4j And Hibernatestatic mapWith = "neo4j”def hibernateHero = Hero.get(1)hibernateHero.neo4j.save()def neo4jHer...
Advanced Configurationgrails-app/conf/DataSource.groovy       grails {         neo4j {            type = "embedded"       ...
Via RESTtype = "rest”grails {  neo4j {     type = "rest"     location = "http://localhost:7474/db/data/"  }}
High Availabiletype = "ha”grails {  neo4j {     type = "ha"     location = "/var/neo4j"     params = [ // see http://docs....
Referencesno:sql   http://nosql-database.org/neo4j   http://neo4j.orggrails-neo4j plug-in  http://jira.grails.org/browse/G...
QuestionsQ are guaranteed in life – answers aren’t.
Upcoming SlideShare
Loading in...5
×

Neo4J and Grails

3,681

Published on

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,681
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
43
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Transcript of "Neo4J and Grails"

  1. 1. Rapid development with Neo4J under Grails
  2. 2. About Myself• Located in Riga/Latvia• Technical Architect in Accenture• Experience since 10 years• C#/Java/Groovy/Scala/Erlang
  3. 3. no:sqlMarket has significantly different challenges indealing with data that the traditional RDBMSsolutions could not cope with.
  4. 4. Issues• size data sets• data relations are connected• distributed processing• Data Model -> semi-structured approach
  5. 5. brings to diversity of solutions Data Model Distribution Disk Data Model Structure
  6. 6. types Document store Graph Key-value storeMultivalue databases Object database Tabular Tuple store
  7. 7. hard to integrate in industrialized companies
  8. 8. Grails SupportName TypeRIAK Eventually‐consistent key‐value +REDIS Key-value cache in RAM +MemcacheDB Ordered key-value stores +-Apache CouchDB Document store +MongoDB Document store +Apache Hadoop Tabular/Big Table +Apache Cassandra Eventually‐consistent key‐value +Neo4J Graph +
  9. 9. Graph DB implemetations LanguageDEX C++FlockDB ScalaInfiniteGraph JavaHyperGraphDB JavaNeo4J JavaOpenLink Virtuoso C++, C#, Java, SPARQLOrientDB JavaSones GraphDB C#
  10. 10. Graph on(in) GrailsNeo4j is (as of now) the only graph databasethat fits nicely in a Grails application.
  11. 11. Data is connected
  12. 12. Why Graph DB?Insufficient RDBMS performance in hierarchicalstructures. The graph database storage shineswhen storing richly-connected data. Querying isperformed through traversals, which canperform millions of traversal steps per second. Atraversal step resembles a join in a RDBMS.
  13. 13. SQL addonsSome DBs has even special DSL:SELECT empno, ename, job, mgr, hiredate, LEVELFROM empWHERE LEVEL <= 2START WITH mgr IS NULLCONNECT BY PRIOR empno = mgr
  14. 14. Where Graph DB• Network Management• Master Data Management• Social• Finance• Spatial – Map Routing• Bio
  15. 15. Why Neo4J?• true ACID transactions• high availability• scales to billions of nodes and relationships• high speed querying through traversals• well documented• Java• licenses
  16. 16. Why neo4j - details• Disk ready – Native graph storage engine with custom (SSD- ready) binary on-disk format• Transactional – JTA/JTS, XA, 2PC, Tx Recovery, deadlock detection …• Scalable – Billions of nodes on single JVM
  17. 17. Access & Implementation Types1. EmbeddedGraphDatabase: just to local JVM2. RestGraphDatabase: rest-binding3. HighAvaibleGraphDatabase: uses Zookeeper
  18. 18. When Grails shinesRuby platform isn’t a case, Java is too expensive,Scala is too smart.Startups & prototypesModel-driven architecture where GORM isfundament.
  19. 19. Groovy & Grails Architecture Controller View GSP Service Domain Plug-in Gant GORM Site Mesh Spring Hibernate DB Java EE Groovy JVM
  20. 20. GORMAbstraction on abstractions, wraps: – Hibernate – JPA – Gemfire, Redis, Riak – MongoDB, JCR – Neo4JIntegration testing via TCK
  21. 21. Neo4j plug-in
  22. 22. Plugin features• Neo4j -> Groovy/Java• GORM dynamic finders, criteria and named queries• Session-managed transactions• Bean Validation• Neo4js traversal• Embedded, REST and HA
  23. 23. Jump into Neo4J name:staff type:weaponname:SplinterfullName:Hamato Yoshitype: rat type: interact type:knows name:Shredder fullName:Oroku Saki
  24. 24. Nodes
  25. 25. Relationships
  26. 26. Properties name:staff type:weaponname:SplinterfullName:Hamato Yoshitype: rat type: interact type:knows
  27. 27. Mapping Reference Node SubreferenceDomain Class/Type SubreferenceNode Domain Class Instance Instance Domain Class Properties Instance Properties Assocoation
  28. 28. Compatibility with GORM ✔ ✗Simple persistence methods HQL queriesDynamic finders Dirty checking methodsCriteria queries Composite primary keysNamed queries Any direct interaction with the Hibernate APIInheritance Custom Hibernate user typesEmbedded typesQuery by exampleMany-to-many associations (these can bemodelled with a mapping class)
  29. 29. Getting Startedgrails install-plugin neo4jgrails uninstall-plugin hibernate
  30. 30. Create Domaingrails create-domain-class Hero
  31. 31. Exampleshero.save()Hero.findByWeightGreaterThan( 100 )Hero.findAllByFullNameNotNull()hero.weapons.each { …}
  32. 32. Combining Neo4j And Hibernatestatic mapWith = "neo4j”def hibernateHero = Hero.get(1)hibernateHero.neo4j.save()def neo4jHero = Person.neo4j.get(1)
  33. 33. Advanced Configurationgrails-app/conf/DataSource.groovy grails { neo4j { type = "embedded" location = "/var/neo4j" params = [] } }
  34. 34. Via RESTtype = "rest”grails { neo4j { type = "rest" location = "http://localhost:7474/db/data/" }}
  35. 35. High Availabiletype = "ha”grails { neo4j { type = "ha" location = "/var/neo4j" params = [ // see http://docs.neo4j.org/chunked/stable/ha-configuration.html ha.server_id: 1, ha.coordinators: localhost:2181,localhost:2182,localhost:2183 ] }}
  36. 36. Referencesno:sql http://nosql-database.org/neo4j http://neo4j.orggrails-neo4j plug-in http://jira.grails.org/browse/GPNEO4J http://springsource.github.com/grails-data- mapping/neo4j/manual/guide/index.html
  37. 37. QuestionsQ are guaranteed in life – answers aren’t.
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×