Grails and Neo4jStefan Armbruster      gr8confCPH, 2011 May 19th
About myself●    located in Munich/Germany●    freelancer since 10 years●    cofounder of Netjay●    Java +10 years, Groov...
Whats wrong with SQL?Whats about the hype of NoSQL?
4 trendsmuch larger data sets:●    ●        IDC comparison: 2010 to 2007 is 40 : 1data gets more connected●semi-structured...
One size fits all?
exploring the nosql-landscapeKey-Value:                                     Bigtable:➢    RIAK *                          ...
nosql is not the silver bullet
neo4j basic building blocks                  1) nodes              2) relationships3) properties on both, nodes and relati...
neo4j
querying neo4jsimple way: navigate the relationships●more powerful: use a traverser with callbacks for●    ●        decide...
SQL querying vs traversingSQL challenge: SQL statement that retrieves friends up to nth grade. Anyone?Neo4j: using a trave...
query performancesome benchmark     data:    – each Person has 50 friends in avg       Database          # persons       ...
accessing the databaseChoosing an implementation of GraphDatabase:   ●       EmbeddedGraphDatabase: just local to JVM   ● ...
neo4j - Licensing3 editions:community:    GPL or $advanced:     AGPL or $enterprise:   AGPL or $
history of nosql & neo4j for Grailsend 2009: first version of neo4j pluginduring 2010: GORM for nosql     – inconsequentia...
GORM: spring-data-mappingprovides abstraction layer●TCK●various implementations:●      ●          hibernate, jpa      ●   ...
dependencies
interfaces/abstract base classes in GORM●   Datastore:        ●   create sessions        ●   manage connection to low-leve...
mapping domain model to nodespace                                                reference node   domain class            ...
praying to the demo god....
currently working in neo4j pluginpassing >90% of GORM TCK (hurray!)●accessing embedded, REST and [HA datasources]●property...
currently not working in neo4j pluginnasty bug: some trouble if a domain class● references itself -> StackOverflowExceptio...
roadmap●    Write docs & publish●    Handle relationship to self (Neo4j 1.4?)●    Support for arbitrary attributes●    Sup...
Q&A
Referencesgeneral overview of nosql:     – http://www.nosql-databases.org/http://www.neo4j.orgneo4j grails plugin:     – s...
Grails and Neo4j
Grails and Neo4j
Upcoming SlideShare
Loading in...5
×

Grails and Neo4j

4,580

Published on

Talk given at http://eu.gr8conf.org 2011 regarding integrating Neo4j as a full GORM compliant Datastore for Grails applications.

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

No Downloads
Views
Total Views
4,580
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
57
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Grails and Neo4j

  1. 1. Grails and Neo4jStefan Armbruster gr8confCPH, 2011 May 19th
  2. 2. About myself● located in Munich/Germany● freelancer since 10 years● cofounder of Netjay● Java +10 years, Groovy ~5 years, Grails 3+ years● author of some Grails plugins● cofounder of the usergroup in Munich● passionate volunteer firefighter● twitter: darthvader42● http://blog.armbruster-it.de
  3. 3. Whats wrong with SQL?Whats about the hype of NoSQL?
  4. 4. 4 trendsmuch larger data sets:● ● IDC comparison: 2010 to 2007 is 40 : 1data gets more connected●semi-structured data●horizontal scalability – distributed architecture●
  5. 5. One size fits all?
  6. 6. exploring the nosql-landscapeKey-Value: Bigtable:➢ RIAK * ➢ Hadoop / Hbase *➢ Redis * ➢ SimpleDB➢ Membase ➢ Cassandra **Document:Document Graph:➢ CouchDB * ➢ InfiniteGraph➢ Mongo * ➢ Neo4j * *: GORM compliant implementation, **: Grails support without GORM
  7. 7. nosql is not the silver bullet
  8. 8. neo4j basic building blocks 1) nodes 2) relationships3) properties on both, nodes and relationship thats it!
  9. 9. neo4j
  10. 10. querying neo4jsimple way: navigate the relationships●more powerful: use a traverser with callbacks for● ● decide where to end ● decide if node should be part of the result
  11. 11. SQL querying vs traversingSQL challenge: SQL statement that retrieves friends up to nth grade. Anyone?Neo4j: using a traverser: Node node = // retrieve the starting poing def myFriendsAndFriends = node.traverse( BREADTH_FIRST, { it.depth()<3 } as StopEvaluator, { true } as RetrunableEvaluator, DynamicRelationshipType.withName(friend), Direction.OUTGOING ).allNodes
  12. 12. query performancesome benchmark data: – each Person has 50 friends in avg Database # persons query time Relational 1.000 2000 ms Neo4j 1.000 2 ms Neo4j 1.000.000 2 ms
  13. 13. accessing the databaseChoosing an implementation of GraphDatabase: ● EmbeddedGraphDatabase: just local to JVM ● RestGraphDatabase (https://github.com/jexp/neo4j-java-rest-binding) ● HighAvailableGraphDatabase: uses Zookeeper
  14. 14. neo4j - Licensing3 editions:community: GPL or $advanced: AGPL or $enterprise: AGPL or $
  15. 15. history of nosql & neo4j for Grailsend 2009: first version of neo4j pluginduring 2010: GORM for nosql – inconsequential -> spring-data-mappingend 2010: spring-data-graph – aspectj based injection of JPA like methods – focussed at Roo an POWAs – "not the right approach for Grails" (IMHO)May 2011: Neo4j for Grails using spring-data- mapping
  16. 16. GORM: spring-data-mappingprovides abstraction layer●TCK●various implementations:● ● hibernate, jpa ● gemfire, redis, riak ● mongo, jcr ● neo4j <- the new child on the block
  17. 17. dependencies
  18. 18. interfaces/abstract base classes in GORM● Datastore: ● create sessions ● manage connection to low-level storage● MappingContext: ● holds metainformation about mapping domain classes to the underlying datastore (type conversion, list of EntityPersisters,...)● EntityPersister: ● does the dirty work: interact with low level datastore● Session: ● similar HibernateSession● Query: ● knows how to query the datastore by criteria (criterion, projections,...)
  19. 19. mapping domain model to nodespace reference node domain class subreference subreference node domain class instance instance domain instance properties property association
  20. 20. praying to the demo god....
  21. 21. currently working in neo4j pluginpassing >90% of GORM TCK (hurray!)●accessing embedded, REST and [HA datasources]●property type conversion●access to native API●<DomainClass>.traverseStatic, <instance>.traverse●
  22. 22. currently not working in neo4j pluginnasty bug: some trouble if a domain class● references itself -> StackOverflowExceptionTransactions●Optimistic Locking●Query performance not as good as could be●Indexing●
  23. 23. roadmap● Write docs & publish● Handle relationship to self (Neo4j 1.4?)● Support for arbitrary attributes● Support for indexing (and its usage in criteria queries)● Embed some controller/servlet to visually navigate the nodespace (SVG?)● Support for migrations?● ... your suggestions?
  24. 24. Q&A
  25. 25. Referencesgeneral overview of nosql: – http://www.nosql-databases.org/http://www.neo4j.orgneo4j grails plugin: – source: https://github.com/sarmbruster/spring-data-mapping – issues: http://jira.grails.org/browse/GPNEO4Jhttps://github.com/jexp/neo4j-java-rest-bindingsite running grails w/ neo4j: http://www.fanorakel.demy blog: http://blog.armbruster-it.de,twitter: darthvader42
  1. A particular slide catching your eye?

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

×