Neo4j - ODBMS.org · Why Spatial? Complex data Multiple indexing ... Shapefiles suck. Persistence...
Transcript of Neo4j - ODBMS.org · Why Spatial? Complex data Multiple indexing ... Shapefiles suck. Persistence...
NOSQL data models
Bigtable clones
Key-value stores
Document databases
Graph databases
Data complexity
Dat
a si
ze
The Neo4j model: Property GraphCore abstractions:
NodesRelationships between nodesProperties on both
name = “Emil”age = 29sex = “yes”
type = KNOWStime = 4 years
type = carvendor = “SAAB”model = “95 Aero”
11 22
33
Neo4j – Nodes, Relationships, Properties
Nodes have different propertiesMatrix characters: People vs. Programs
Build structure as you goWho loves Neo?
Building a node spaceGraphDatabaseService graphDb = ... // Get factory
// Create Thomas 'Neo' AndersonNode mrAnderson = graphDb.createNode();mrAnderson.setProperty( "name", "Thomas Anderson" );mrAnderson.setProperty( "age", 29 );
// Create MorpheusNode morpheus = graphDb.createNode();morpheus.setProperty( "name", "Morpheus" );morpheus.setProperty( "rank", "Captain" );morpheus.setProperty( "occupation", "Total bad ass" );
// Create a relationship representing that they know each othermrAnderson.createRelationshipTo( morpheus, RelTypes.KNOWS );// ...create Trinity, Cypher, Agent Smith, Architect similarly
Building a node spaceGraphDatabaseService graphDb = ... // Get factoryTransaction tx = graphdb.beginTx();
// Create Thomas 'Neo' AndersonNode mrAnderson = graphDb.createNode();mrAnderson.setProperty( "name", "Thomas Anderson" );mrAnderson.setProperty( "age", 29 );
// Create MorpheusNode morpheus = graphDb.createNode();morpheus.setProperty( "name", "Morpheus" );morpheus.setProperty( "rank", "Captain" );morpheus.setProperty( "occupation", "Total bad ass" );
// Create a relationship representing that they know each othermrAnderson.createRelationshipTo( morpheus, RelTypes.KNOWS );// ...create Trinity, Cypher, Agent Smith, Architect similarlytx.commit();
Code (2): Traversing a node space
// Instantiate a traverser that returns Mr Anderson's friendsTraverser friendsTraverser = mrAnderson.traverse(
Traverser.Order.BREADTH_FIRST,StopEvaluator.END_OF_GRAPH,ReturnableEvaluator.ALL_BUT_START_NODE,RelTypes.KNOWS,Direction.OUTGOING );
// Traverse the node space and print out the resultSystem.out.println( "Mr Anderson's friends:" );for ( Node friend : friendsTraverser ){
System.out.printf( "At depth %d => %s%n",friendsTraverser.currentPosition().getDepth(),friend.getProperty( "name" ) );
}
Rubygem install neo4j
require ”rubygems”require 'neo4j'
class Person include Neo4j::NodeMixin property :name, :age, :occupation index :name has_n :friendsend
Neo4j::Transactoin.run do neo = Person.new :name=>'Neo', :age=>29 morpheus = Person.new :name=>'Morpheus', :occupation=>'badass' neo.friends << morpheusend
neo.friends.each {|p|...}
Why Spatial?Complex data
Multiple indexing (domain, Spatial, temporal)Location entering many domainsGIS going mainstream, topologies explodeNo good systems out thereProprietary stacks rule (ESRI, Oracle)Open Government DataShapefiles suck.
Persistence backends in GISShapefilesPostGISMySQLOracle SpatialESRIGeoCouchCassandra (?)Neo4j Spatial
Current challenges in SpatialDomain and Spatial interconnectionsUnstructured domain dataRoutingTopology handlingNo good OSS full GIS stack
The Neo4j Spatial stack
Neo4j
GeoTools
GeoServer uDig GeoMaya
Neo4j Spatial
REST Java Scripting
OpenLayersWMSWMF
AJAXEditing
PHPJSC#
RailsDjangoSpring
Roo
The OpenStreetMap datasetWiki for Spatial infoFreely available dataVery unstructured, free tagging
Points, Ways, Relations, Tags, ChangesetsChanges can be pushed back
Used for other purposesGreat coverage in interesting places (towns, disasters etc)
Connecting and Splitting
Why have layers at all?Simpler renderersHistoricalData sources
Layer1
Layer2
Layer3
Layer1
Layer2
Layer3
Neo4j dynamic layers
Layer1
Layer2
Layer3
GeometryEncoder
DynamicQuery
DynamicStyles
DynamicMeta-Inf
Connected domain data Neo4j Spatial GIS and Spatial stacks
FutureComplex spatial mapping and analytics made easyEditing
Fine Grained Geotools Feature EditingOSM Editor
OSMCaching sub-graphs (desktop & mobile)More Dynamic Layers & Shapefile export
TopologyPersist all topological results in graph
Benchmarking & PerformanceImproved indexingComposite index
API ReferencesWiki, Code, API references
http://wiki.neo4j.org/content/Neo4j_Spatialhttp://github.com/neo4j/neo4j-spatialhttp://components.neo4j.org/neo4j-spatialMailing list: [email protected]://neo4j.org/community/list/