What’s next

September 29, 2008

Mavenized Neo4J example

Filed under: Java — stigl @ 10:12 am
Tags: , , ,

The weekend after JavaZone, I was one of the participants on a “GeekCruise”, where we looked into emerging technologies such as Qi4J, Neo4J and Enterpricy stuff.
Matrix diagram
In short, Neo4J is a network/graph database that promises to deliver Web 3.0, Semantic Web and RDF greatness. Its advantages are fast specific types of search, graph traversal and shortest route. It can also store partially structured information, eg. V1.0 and v1.1 of Person in the DB at the same time. It also integrates well with Qi4J, you don’t need ORMaping, and the graph can be read from and persisted to RDF.

//Setting up the database in a folder called myNeoDB
NeoService neoDb = new EmbeddedNeo("myNeoDB");
//Create test dataset
Node neo = neoDb.createNode();
neo.setProperty("name", "Thomas Andersson");
Node trinity = neoDb.createNode();
neo.createRelationshipTo(trinity, MyRelationShipTypes.KNOWS);

Queries can be done with SPARQL, or a traverser:

Traverser friendFinder(Node person) {
return person.traverse(
Traverser.Order.BREADTH_FIRST,
StopEvaluator.END_OF_NETWORK,
ReturnableEvaluator.ALL_BUT_START_NODE,
MyRelationShipTypes.KNOWS,
Direction.OUTGOING);
}

The Matrix demo is as simple as Unzip og “mvn test”!

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: