Neo4 + Grails
Upcoming SlideShare
Loading in...5

Neo4 + Grails






Total Views
Slideshare-icon Views on SlideShare
Embed Views



0 Embeds 0

No embeds



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Neo4 + Grails Neo4 + Grails Presentation Transcript

    • Rapid development with Neo4J under Grails
    • About Myself• Stanislav Shevchenko• Located in Riga/Latvia• Technical Architect in Accenture• Experience since 10 years• C#/Java/Groovy/Scala/Erlang
    • no:sqlMarket has significantly different challenges indealing with data that the traditional RDBMSsolutions could not cope with.
    • 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 Model Structure
    • 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 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 +
    • Graph DB implemetations LanguageDEX C++FlockDB ScalaInfiniteGraph JavaHyperGraphDB JavaNeo4J JavaOpenLink Virtuoso C++, C#, Java, SPARQLOrientDB JavaSones GraphDB C#
    • 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 richly-connected data. Querying isperformed through traversals, which canperform millions of traversal steps per second. Atraversal step resembles a join in a RDBMS.
    • 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
    • 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 querying through traversals• well documented• Java• licenses
    • 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
    • Access & Implementation Types1. EmbeddedGraphDatabase: just to local JVM2. RestGraphDatabase: rest-binding3. HighAvaibleGraphDatabase: uses Zookeeper
    • When Grails shinesRuby platform isn’t a case, Java is too expensive,Scala is too smart.Startups & prototypesModel-driven architecture where GORM isfundament.
    • Groovy & Grails Architecture Controller View GSP Service Domain Plug-in Gant GORM Site Mesh Spring Hibernate DB Java EE Groovy JVM
    • GORMAbstraction on abstractions, wraps: – Hibernate – JPA – Gemfire, Redis, Riak – MongoDB, JCR – Neo4JIntegration testing via TCK
    • Neo4j plug-in
    • Plugin features• Neo4j -> Groovy/Java• GORM dynamic finders, criteria and named queries• Session-managed transactions• Bean Validation• Neo4js traversal• Embedded, REST and HA
    • Jump into Neo4J name:staff type:weaponname:SplinterfullName:Hamato Yoshitype: rat type: interact type:knows name:Shredder fullName:Oroku Saki
    • Nodes
    • Relationships
    • Properties name:staff type:weaponname:SplinterfullName:Hamato Yoshitype: rat type: interact type:knows
    • Mapping Reference Node SubreferenceDomain Class/Type SubreferenceNode Domain Class Instance Instance Domain Class Properties Instance Properties Assocoation
    • 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)
    • Getting Startedgrails install-plugin neo4jgrails uninstall-plugin hibernate
    • Create Domaingrails create-domain-class Hero
    • 100 )Hero.findAllByFullNameNotNull()hero.weapons.each { …}
    • Combining Neo4j And Hibernatestatic mapWith = "neo4j”def hibernateHero = Hero.get(1) neo4jHero = Person.neo4j.get(1)
    • Advanced Configurationgrails-app/conf/DataSource.groovy grails { neo4j { type = "embedded" location = "/var/neo4j" params = [] } }
    • 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 ha.server_id: 1, ha.coordinators: localhost:2181,localhost:2182,localhost:2183 ] }}
    • Referencesno:sql http://neo4j.orggrails-neo4j plug-in mapping/neo4j/manual/guide/index.html
    • QuestionsQ are guaranteed in life – answers aren’t.