Your SlideShare is downloading. ×

Neo4 j, what else?

575
views

Published on

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
575
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. NEO4J, WHAT ELSE?! Ron van Weverwijk
  • 2. AGENDA• Positionering binnen NoSql• Waarom een Graph database?• Neo4j• Cypher• Vragen?
  • 3. VIER NOSQL CATEGORIEËN
  • 4. KEY-VALUE STORE
  • 5. COLUMN FAMILYKEY-VALUE STORE (BIGTABLE)
  • 6. COLUMN FAMILYKEY-VALUE STORE (BIGTABLE) DOCUMENT DATABASES
  • 7. COLUMN FAMILYKEY-VALUE STORE (BIGTABLE) DOCUMENT DATABASES GRAPH DATABASES
  • 8. WAAR IS EENGRAPHDATABASE GOED IN?
  • 9. http://inmaps.linkedinlabs.com/
  • 10. PageRank is gebouwd met 15 regels code!Bron:http://www.royans.net/arch/pregel-googles-other-data-processing-infrastructure/
  • 11. WAAROM EENGRAPHDATABASE?
  • 12. WAAROM EENGRAPHDATABASE?
  • 13. WAAROM EENGRAPHDATABASE?
  • 14. Experiment: Hoe zijn 2 nodes verbonden?• 1000 personen• gemiddeld 50 relaties• Zijn 2 personen verbonden met maximaal 4 stappen?• Warme cache
  • 15. Experiment: Hoe zijn 2 nodes verbonden?• 1000 personen Relationeel Neo4j• gemiddeld 50 relaties• Zijn 1000 2000ms 2ms 2 personen verbonden met maximaal 4 stappen?• Warme cache 1 000 000 ? 2ms
  • 16. Experiment: Hoe zijn 2 nodes verbonden?• 1000 personen Relationeel Neo4j• gemiddeld 50 relaties• Zijn 1000 2000ms 2ms 2 personen verbonden met maximaal 4 stappen?• Warme cache 1 000 000 ? 2ms
  • 17. NODES (VERTICES)RELATIONS (EDGES)
  • 18. PROPERTIES OP NODES type: persoon type: team name: Ron name: S2 type: persoon name: Corjan
  • 19. GETYPEERDE RELATIES speelt_in type: persoon type: team name: Ron name: S2 coach_van type: persoon name: Corjan
  • 20. PROPERTIES OP RELATIES speelt_in type: persoon type: team name: Ron name: S2 jaar: 2011 coach_van jaar: 2011 type: persoon name: Corjan
  • 21. PROPERTIES• Alle Java primitieven kunnen gebruikt worden: • String • boolean • int • double • ...
  • 22. SCHEMA-LESS DATABASE !=DATABASE WITHOUT DESIGN
  • 23. Doctor Who (Jim Webber)
  • 24. FILEBASED
  • 25. EMBEDDABLE, SERVER HIGH AVAILABLE• new EmbeddedGraphDatabase("/tmp/neodb");• GET http://localhost:7474/db/data/node/123• Map<String,String> config = HighlyAvailableGraphDatabase.loadConfigurations( configFile ); GraphDatabaseService db = new HighlyAvailableGraphDatabase( path, config );
  • 26. TRANSACTIONS
  • 27. TRANSACTIONSTransaction tx = db.beginTx();try { ... tx.success();} finally { tx.finish();}
  • 28. SHOW ME THE CODE! Start database Maak nodes Maak relaties Maak lucene index
  • 29. TRAVERSINGTraversalDescription traversal = new TraversalDescriptionImpl() .depthFirst() .uniqueness(Uniqueness.RELATIONSHIP_PATH);Iterable<Path> paths = traversal.traverse(startNode); Ron Lindy Adres
  • 30. ALGORITHMS• find all paths• find all simple paths• find the shortest path• Dijkstra algorithm• The a* search algorithm
  • 31. DEMO!Neo4j webconsoleCypher viewer: Friso van Vollenhovenhttps://github.com/friso/graphs
  • 32. player_ofMathieu coach_of S2 Corjan player_of commission_member_of Ron Webcommissie commission_member_of Dennis
  • 33. GELEERDE LESSEN• Blijf tekenen: Maak het netwerk visueel• Maak proefopzetjes en refactor• Pas node wrapping toe om het domein simpel te houden• Typeer nodes• gebruik BatchInsert voor veel data
  • 34. NODE WRAPPINGpublic interface Member { String getName(); void setName(String name); // .....}
  • 35. NODE WRAPPINGpublic class MemberNode implements Member { private Node node; public static final String MEMBER_NAME_KEY = "name"; public MemberNode(Node node) { this.node = node; } public String getName() { return (String) getNode().getProperty(MEMBER_NAME_KEY); } public void setName(String name) { getNode().setProperty(MEMBER_NAME_KEY, name); }}
  • 36. NODE WRAPPINGpublic Team getMyTeam() { Relationship teamRelationship = getNode().getSingleRelationship(PLAYER_OF, Direction.OUTGOING); Node teamNode = teamRelationship.getEndNode(); return new Team(teamNode);}
  • 37. Ron van Weverwijkrvanweverwijk@xebia.com